# Import events

> **GET** `https://api.us.nylas.com/v3/grants/{grant_id}/events/import`

Source: https://developer.nylas.com/docs/reference/api/events/import-events/

Returns a list of recurring events, recurring event exceptions, and single events from the
specified calendar within a given time frame. This is useful when you want to import, store, and
synchronize events from the time frame to your application (for example, to enrich events with
custom data or integrate events into your own calendaring solution).

If you want to retrieve a list of all events from a calendar, use the
[Get all Events endpoint](/docs/reference/api/events/get-all-events/) instead.

### Limitations

- Nylas might return multiple instances of a single recurring event if the results are paginated.
- The number of events Nylas returns might be lower than `max_results`, even if others match your
query parameters.
- Events are not guaranteed to be sorted by their start time.
- Nylas does not support [metadata](/docs/reference/api/#metadata) for this endpoint.
- Support for Microsoft Graph is in beta.

**Authentication:** NYLAS_API_KEY, ACCESS_TOKEN

## Parameters

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | No | Specifies the maximum number of events Nylas returns in a single page of results. The actual number of events Nylas returns might be lower than this limit, even if other events match your query parameters. |
| `page_token` | string | No | An identifier that specifies which page of data to return. You can get this value from the `next_cursor` response field. See [Pagination](/docs/reference/api/#pagination) for more information. |
| `calendar_id` | string | Yes | Filter for the specified calendar ID.  (Not supported for iCloud) You can use `primary` to query the user's primary calendar. |
| `start` | integer | No | Filter for events that start at or after the specified time, in seconds using the Unix timestamp format. For example, if you filter for events that start at 9:00a.m., and the calendar includes an event that runs from 8:30–9:30a.m., Nylas returns that event.  Defaults to the time that you make the request.  The `start` value cannot be later than `end`. For iCloud accounts, the difference between `start` and `end` can't be greater than one year. |
| `end` | integer | No | Filter for events that end at or before the specified time, in seconds using the Unix timestamp format. For example, if you filter for events that end at 5:00p.m., and the calendar includes an event that runs from 4:30–5:30p.m., Nylas returns that event.  Defaults to one month from the time you make the request.  The `end` value cannot be earlier than `start`. For iCloud accounts, the difference between `start` and `end` can't be greater than one year. |
| `select` | string | No | Specify fields that you want Nylas to return, as a comma-separated list (for example, `select=id,updated_at`). This allows you to receive only the portion of object data that you're interested in. You can use `select` to optimize response size and reduce latency by limiting queries to only the information that you need. |

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `grant_id` | string | Yes | ID of the grant to access. Use `/me/` to refer to the grant associated with an access token. |

## Responses

### 200 - Events Response

- `request_id` (string) - The request ID.
- `data` (array)
  - `busy` (boolean) - If `true`, shows the event's time block as `busy` on shared or public calendars. This may be
called "transparency" in some systems.
  - `calendar_id` (string,null) - The calendar ID associated with the event. If you used the `calendar_id=primary` query parameter in
your request, Nylas returns the real calendar ID instead of `primary`.

For Microsoft calendars, there are some cases where the event Nylas returns isn't associated with
a calendar ID. This happens most often when the event is created in a shared calendar.

This field may be `null` for certain event types (for example, virtual calendar events).
  - `conferencing` (object) - An object that contains event conferencing details. Nylas appends the conference information to the
Event `description`.
    - `provider` (string)
    - **Auto-conferencing**
      - `autocreate` (object) - The autocreate settings you specified for the meeting, plus the details created by the
conferencing provider. The autocreated conference details are also appended to the Event
description.
    - **Google Meet**
      - `details` (object) - An object that contains Google Meet conferencing details.
        - `url` (string) - The URL for the Google Meet conference.
        - `phone` (array) - The phone number associated with the Google Meet conference.
        - `pin` (string) - The PIN associated with the Google Meet conference, if applicable.
    - **Zoom Meeting**
      - `details` (object) - An object that contains Zoom conferencing details.
        - `url` (string) - The URL for the Zoom conference.
        - `meeting_code` (string) - A unique ID associated with the Zoom conference.
        - `password` (string) - The password for the Zoom conference, if applicable.
    - **Microsoft Teams**
      - `details` (object) - An object that contains Microsoft Teams conferencing details.
        - `url` (string) - The URL for the Microsoft Teams conference.
    - **WebEx**
      - `details` (object) - An object that contains WebEx conferencing details.
        - `url` (string) - The URL for the WebEx conference.
        - `password` (string) - The password for the WebEx conference, if applicable.
        - `pin` (string) - The PIN for the WebEx conference, if applicable.
        - `phone` (array) - The phone number associated with the WebEx conference.
    - **GoToMeeting**
      - `details` (object) - An object that contains GoToMeeting conferencing details.
        - `url` (string) - The URL for the GoToMeeting conference.
        - `meeting_code` (string) - A unique ID associated with the GoToMeeting conference.
        - `password` (string) - The password for the GoToMeeting conference, if applicable.
        - `phone` (array) - The phone number associated with the GoToMeeting conference.
  - `created_at` (integer,null) - When the event was created, in seconds using the Unix timestamp format.
  - `description` (string,null) - A brief description of the event (for example, its agenda). The description might be returned
as an HTML string, depending on how the provider formats it.
For Google accounts, this field accepts a maximum of 8,192 characters.
  - `text_description` (string,null) - A brief text description of the event (for example, its agenda). If the description is HTML-formatted,
this field will contain the text version of the description.
  - `hide_participants` (boolean) - (Not supported for iCloud or EWS events) When `true`, hides the event's list of participants.
  - `grant_id` (string) - The ID of grant for the connected user.
  - `html_link` (string) - (Not supported for EWS events) A link to the event on the provider.
  - `ical_uid` (string,null) - A unique ID that you can use to identify events across calendaring systems, in
[iCalendar format](https://datatracker.ietf.org/doc/html/rfc5545#section-3.8.4.7).
Recurring events might share the same ID.

Can be `null` for events synced before the year 2020.
  - `id` (string) - The ID of the event. Event IDs are usually unique to each user, except for Google which maintains the same event ID for an event regardless of the user querying it.
  - `location` (string,null) - The location of the event (for example, a physical address or the name of a meeting room).
  - `master_event_id` (string,null) - If the event is an instance of a recurring event series, this field lists the ID of the parent
event. If the parent event belongs to a different calendar that you don't have access to, or it's
been deleted or cancelled, you can't retrieve it using this ID.
  - `metadata` (object) - The metadata associated with the object. For more information, see
[Metadata](/docs/reference/api/#metadata).
  - `object` (string) - The type of object.
  - `organizer` (object) - An object that contains information about an event's organizer.
    - `name` (string) - The organizer's full name.
    - `email` (string) - The organizer's email address. 

For an event in a Google calendar, Nylas returns the `email` based on the calender type.
- For a primary calendar, `email` is the same as the `calendar_id`.
- For a non-primary calendar, `email` is set to the actual ID of the calendar.
  - `participants` (array) - An array of participants invited to the event. The organizer doesn't need to be explicitly
included in this list.
    - `comment` (string) - A note or comment about the participant (for example, their nickname).
    - `email` (string) - The participant's email address. For Microsoft Graph, this field can be missing.
    - `name` (string) - The participant's name.
    - `phone_number` (string) - The participant's phone number.
    - `status` (string) - The participant's RSVP status.
  - `resources` (array) - An array of room resource bookings added to the event.
    - `email` (string) **(required)** - The resource's email address.
    - `name` (string) - The resource's full name.
  - `read_only` (boolean) - If `true`, indicates that the event is read-only. The provider sets the `read_only` value based on
the connected calendar, and you can't modify it.

In cases where you _can_ update this field on a cloned event (for example, an event imported to your
calendar from an email invitation), `read_only` is `true`.

If the calendar is read-only, all events on the calendar have `read_only` set to `true`.
  - `reminders` (object) - A list of reminders to generate for the event. If not defined, Nylas uses the provider's default
settings.
    - `use_default` (boolean,null) - When `true`, the event uses the calendar's default reminder settings.
This field may be `null` if reminders are not explicitly configured.

- **Google**: Generates a `popup`-style reminder 10 minutes before the event begins.
- **Microsoft**: Generates a reminder 15 minutes before the event begins.
- **iCloud**: Does not generate a reminder.
- **EWS**: Generates a `display`-style reminder 15 minutes before the event begins.
    - `overrides` (array,null) - A list of reminders for the event to use when `use_default` is `false`. If this field is empty
or omitted, and `use_default` is `false`, the event does not send reminders. If `true`, Nylas
generates both the default event reminder and any reminders in the `overrides` list.

You cannot set reminder overrides if `use_default` is `true`.

For Microsoft Graph, EWS, and iCloud, you can set only one reminder per event.

This field may be `null` if no reminder overrides have been set. Treat `null` the same as an
empty array.
  - `recurrence` (array) - An array of `RRULE` and `EXDATE` strings. Nylas includes this field only if the event is the main
(master) event. See [RFC-5545](https://tools.ietf.org/html/rfc5545#section-3.8.5) for more details.
You can use [this tool](https://jkbrzt.github.io/rrule/) to learn more about the `RRULE` spec.

Events inherit their timezone from the `when` object. Nylas recommends that you use the `when`
object to specify the event's start and end time.

Provider specifics:
- On some providers, `EXDATE` might not include exception or cancelled event timestamps. When this
happens, Nylas represents those event instances as separate objects in its responses.
- Virtual calendars don't support `DTSTART` or `TZID`.
- iCloud accounts do _not_ support changing an event from recurring to non-recurring. You can create,
update, or delete information on recurring events.
- Microsoft Graph adds one day to the `UNTIL` date.
  - `status` (string) - (Not supported for iCloud) The status of the event. You can't set this field when creating or updating
an event. If you're the organizer of the event and you want to reply "maybe" or "no" to the
invitation, use the
[Send RSVP endpoint](/docs/reference/api/events/send-rsvp/)
instead.

For Google events, a `cancelled` status indicates that the event was an occurrence of a recurring
event, and that the occurrence has been cancelled by the event organizer.

For Microsoft and EWS events, a `cancelled` status indicates that the event was organized by someone
else, and the organizer cancelled or deleted the event.
  - `title` (string) - The name of the event.
  - `updated_at` (integer,null) - When the event was last updated, in seconds using the Unix timestamp format.
  - `visibility` (string,null) - (Not supported for iCloud events) Specifies whether the event is `public` or `private`. If not
defined, Nylas uses the account's default provider settings. For Google and Microsoft, event visibility is `public` by default.

For virtual calendar events, you can explicitly set `visibility` to `private` or `public` on create and update requests. If not set, virtual calendar events default to `public` behavior.
  - `when` (object,null) - An object that represents the time and duration of an event. Nylas might format `when` as one of three
sub-objects: `timespan`, `date`, or `datespan`. These sub-objects allow Nylas to capture and represent
specific points in time.

`timespan` objects include optional timezone support.

This field may be `null` when event timing data is unavailable (for example, when using field selection
that excludes the underlying time fields).
  - `original_start_time` (integer) - (Not supported for virtual calendars) The original start time of the event, in seconds using the Unix timestamp
format. This field is present only if the event is an instance of a recurring event.
  - `notetaker` (object)
    - `id` (string) - The Notetaker bot ID. Read-only; returned in responses but not required in create or update requests.
    - `meeting_settings` (object) - A collection of settings for the Notetaker bot.
      - `action_items` (boolean) - When `true`, Notetaker generates a list of action items from the meeting. If `action_items` is
`true`, `video_recording`, `audio_recording`, and `transcription` must also be `true`.
      - `action_items_settings` (object)
        - `custom_instructions` (string) - A custom prompt to pass to Nylas' AI model and specify settings for the list of action items
it generates. `action_items` must be `true` to use this field.
      - `audio_recording` (boolean) - When `true`, Notetaker records the meeting's audio.
      - `leave_after_silence_seconds` (integer) - The number of seconds of silence after which the Notetaker bot automatically leaves
the meeting. This helps end recordings when meetings have concluded but participants
haven't disconnected the call. Must be between 10 and 3600 seconds (1 hour).
      - `summary` (boolean) - When `true`, Notetaker generates a summary of the meeting. If `summary` is `true`,
`video_recording`, `audio_recording`, and `transcription` must also be `true`.
      - `summary_settings` (object)
        - `custom_instructions` (string) - A custom prompt to pass to Nylas' AI model and specify settings for the summary it generates.
`summary` must be `true` to use this field.
      - `transcription` (boolean) - When `true`, Notetaker transcribes the meeting's audio. If `transcription` is `true`,
`video_recording` and `audio_recording` must also be `true`.
      - `video_recording` (boolean) - When `true`, Notetaker records the meeting's video.
      - `transcription_settings` (object) - Optional settings that tune how Notetaker transcribes audio. `transcription` must be
`true` for these settings to take effect. Provide any combination of the fields below.

The fields fall into two independent groups:

- **Language hints** (`expected_languages`, `fallback_language`) constrain automatic
  language detection. This declares the languages you expect; it does not translate
  transcripts or force the recording into a specific language.
- **Keyword hints** (`keywords`, `use_speaker_names_as_keywords`) bias recognition toward
  domain-specific terms such as names, acronyms, and product names.

Set on individual Notetakers, on calendar sync, or on event sync. When set on a calendar,
events inherit the value unless the event's own request overrides it. Send `null` or `{}`
to clear inherited settings and return to default transcription behavior.

See [Set transcription languages](/docs/v3/notetaker/#set-transcription-languages) for
supported language codes and validation rules.
        - `expected_languages` (array) - Language codes the audio is expected to contain. Optional. When provided, it must
contain at least one supported code and cannot be `null` or empty. When omitted,
transcription considers all supported languages.
        - `fallback_language` (string) - Language to use if Notetaker does not detect one of the `expected_languages`. Optional.
When `expected_languages` is set, the fallback must be one of those codes. When
`expected_languages` is omitted, transcription considers all supported languages and
the fallback may be any supported code. When `fallback_language` is omitted, the
transcriber auto-detects the language. The field is not stored, so responses do not
return it.
        - `keywords` (array) - Domain-specific terms that bias transcription toward recognizing them correctly, such
as names, acronyms, and product names. Optional. Up to 200 terms; each term must be
1 to 200 characters and cannot contain control characters. Cannot be `null`.
        - `use_speaker_names_as_keywords` (boolean) - When `true`, Notetaker adds known speaker names to the keyword set so they are
transcribed accurately. Optional. Cannot be `null`.
    - `name` (string) - The display name for the Notetaker bot.
- `next_cursor` (string,null) - A cursor pointing to the next page of results for the request.

### 400 - Bad Request

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 401 - Unauthorized

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 429 - Rate Limit

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

### 504 - Provider Failure

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

## Code samples

### cURL

```bash
curl --compressed --request GET \
  --url 'https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/events/import?calendar_id=<CALENDAR_ID>&start=<TIMESTAMP>&end=<TIMESTAMP>' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json'
```

### Node.js SDK

```javascript
import Nylas from "nylas";

const nylas = new Nylas({
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
});

async function importEvents() {
  try {
    const events = await nylas.events.listImportEvents({
      identifier: "<NYLAS_GRANT_ID>",
      queryParams: {
        calendarId: "primary",
        start: 1748908800,
        end: 1748995200,
      },
    });

    console.log("Imported events:", events);
  } catch (error) {
    console.error("Error importing events:", error);
  }
}

importEvents();

```

### Python SDK

```python
from nylas import Client

nylas = Client(
    "<NYLAS_API_KEY>",
    "<NYLAS_API_URI>",
)

events = nylas.events.list_import_events(
    identifier="<NYLAS_GRANT_ID>",
    query_params={
        "calendar_id": "<CALENDAR_ID>",
        "start": 1763119800,
        "end": 1765711800,
    },
)

print("Imported events:", events)

```

### Java SDK

```java
import com.nylas.NylasClient;
import com.nylas.models.Event;
import com.nylas.models.ListImportEventQueryParams;
import com.nylas.models.ListResponse;
import com.nylas.models.NylasApiError;
import com.nylas.models.NylasSdkTimeoutError;

public class ImportEvents {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();

    ListImportEventQueryParams queryParams = new ListImportEventQueryParams.Builder("primary")
        .start(1748908800)
        .end(1748995200)
        .build();

    ListResponse<Event> events = nylas.events().listImportEvents("<NYLAS_GRANT_ID>", queryParams);

    System.out.println("Imported events: " + events.getData());
  }
}

```

### Kotlin SDK

```kotlin
import com.nylas.NylasClient
import com.nylas.models.ListImportEventQueryParams

fun main() {
  val nylas = NylasClient.Builder("<NYLAS_API_KEY>").build()

  val queryParams = ListImportEventQueryParams.Builder("primary")
      .start(1748908800)
      .end(1748995200)
      .build()

  val events = nylas.events().listImportEvents("<NYLAS_GRANT_ID>", queryParams)

  println("Imported events: ${events.data}")
}

```
