दस्तावेज़ पर जाएँ
SDK

openemail.calendar

इस नेमस्पेस का हर मेथड: उसका सिग्नेचर, उसके पैरामीटर, वह क्या लौटाता है और एक उदाहरण।

मेथड

Calendar events found in mail, expanded into occurrences.

calendar.listEvents()

List one page of event occurrences inside a time window

स्कोपcalendar:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
listEvents(options: CalendarRangeOptions): Promise<Page<CalendarOccurrenceResource>>

Expands every event in the workspace into its occurrences between from and to and returns one page of them, sorted by start time and then by event id. A recurring series gives one row per instance in the window, with its excluded dates left out, and every row points back to its event through eventId. The window is required because a repeating series has no end to list up to. Follow nextCursor while hasMore is true, with the same from, to and timezone, to read every occurrence, or let listAllEvents and iterateEvents do that walk.

to must be after from and at most 366 days later. A missing from or to is a 422 invalid_parameter, while a value that does not parse, a reversed or overlong window, or an unknown zone is a 400 invalid_parameter naming the field. Both bounds take a Date or an ISO 8601 string, and the SDK converts a Date with toISOString().

timezone is an IANA zone and defaults to UTC on the server. It is used to expand any event stored without a zone of its own, which is what decides the day an all day event lands on.

पैरामीटर

options.fromDate | stringआवश्यक

Start of the window.

options.toDate | stringआवश्यक

End of the window, after from and at most 366 days later.

options.timezonestring

IANA zone such as Europe/London, at most 64 characters. Defaults to UTC.

options.limitnumber

Occurrences per page, a whole number from 1 to 100. The server defaults to 25.

options.cursorstring

The nextCursor of the previous page, sent with the same window. It is opaque, so never build one yourself.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

Page<CalendarOccurrenceResource> with items, hasMore and nextCursor. Each item has eventId, uid, start, end, allDay, summary, location, status, transparency, isOrganizer, organizerEmail, recurring, myPartstat and attendeeCount.

उदाहरण

const from = new Date()const to = new Date(from.getTime() + 7 * 24 * 60 * 60 * 1000) const page = await openemail.calendar.listEvents({ from, to, timezone: 'Europe/London', limit: 50 }) for (const occurrence of page.items) {    console.log(occurrence.start, occurrence.summary, occurrence.myPartstat ?? 'not invited')} console.log(page.hasMore, page.nextCursor)

टिप्पणियाँ

  • myPartstat is the response recorded for any address this workspace holds on its own domains, or for the addresses a narrowed key covers, and null when none of them is an attendee. A workspace with no address on its own domains matches no attendee, so every row reads null.

  • A narrowed key only sees occurrences whose organiser is one of the addresses it covers or where one of them is an attendee.

  • Cancelled events are not filtered out. Check status for CANCELLED.

  • Nothing in the window is dropped. A series repeats at most once a day, so one series gives at most one row per day of the window, and every one of them is reachable through the pages.

  • The cursor holds the start time and event id of the last row, so an event deleted or moved between pages never breaks the walk. A cursor this list did not hand out is a 400 invalid_cursor.

इनमें भी उपलब्ध

API
GET /calendar/events
CLI
openemail calendar list-events

calendar.listAllEvents()

Collect every occurrence inside a time window into one array

स्कोपcalendar:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
listAllEvents(options: CalendarRangeOptions): Promise<Array<CalendarOccurrenceResource>>

Walks every page of listEvents for one window and resolves with all of its occurrences, sorted by start time and then by event id. It follows nextCursor until hasMore is false, sending the same from, to and timezone with each request.

A window of up to 366 days of a busy calendar can hold thousands of occurrences, so prefer iterateEvents when you can stop early.

पैरामीटर

options.fromDate | stringआवश्यक

Start of the window.

options.toDate | stringआवश्यक

End of the window, after from and at most 366 days later.

options.timezonestring

IANA zone such as Europe/London, at most 64 characters. Defaults to UTC.

options.limitnumber

Page size for each request, 1 to 100. The server defaults to 25.

options.cursorstring

Starts the walk from this cursor instead of the start of the window.

options.signalAbortSignal

Cancels the request in flight and the walk with it.

options.apiKeystring

Overrides the client API key for every page of this walk.

लौटाता है

Array<CalendarOccurrenceResource> holding every occurrence in the window, earliest first.

उदाहरण

const occurrences = await openemail.calendar.listAllEvents({    from: '2026-10-01T00:00:00Z',    to: '2026-11-01T00:00:00Z',    limit: 100}) const busy = occurrences.filter((occurrence) => occurrence.transparency === 'OPAQUE') console.log(`${busy.length} busy blocks in October`)

टिप्पणियाँ

  • If any page fails the promise rejects and the occurrences already fetched are discarded.

इनमें भी उपलब्ध

API
GET /calendar/events

calendar.iterateEvents()

Stream the occurrences inside a time window one at a time

स्कोपcalendar:readनतीजों को पेज दर पेज लाता है
सिग्नेचर
iterateEvents(options: CalendarRangeOptions): AsyncGenerator<CalendarOccurrenceResource, void, undefined>

Returns an async generator over the occurrences in one window that yields them individually, earliest first, and fetches the next page only when the current one is drained. Nothing is requested until you consume it, and breaking out of the loop stops further requests, which makes it the way to find the next free slot or the next meeting without reading the whole window.

The walk ends when hasMore is false, when a page comes back empty, or when the server repeats a cursor.

पैरामीटर

options.fromDate | stringआवश्यक

Start of the window.

options.toDate | stringआवश्यक

End of the window, after from and at most 366 days later.

options.timezonestring

IANA zone such as Europe/London, at most 64 characters. Defaults to UTC.

options.limitnumber

Page size per request, 1 to 100. The server defaults to 25.

options.cursorstring

Starts the walk from this cursor instead of the start of the window.

options.signalAbortSignal

Cancels the request in flight and ends the iteration.

options.apiKeystring

Overrides the client API key for every page of this walk.

लौटाता है

AsyncGenerator<CalendarOccurrenceResource, void, undefined> yielding one occurrence per step.

उदाहरण

const from = new Date()const to = new Date(from.getTime() + 30 * 24 * 60 * 60 * 1000) for await (const occurrence of openemail.calendar.iterateEvents({ from, to })) {    if (occurrence.myPartstat === null) continue    console.log('next meeting', occurrence.start, occurrence.summary)    break}

टिप्पणियाँ

  • An aborted options.signal rejects the pending page request, which throws out of the for await loop.

इनमें भी उपलब्ध

API
GET /calendar/events

calendar.getEvent()

Read an event with its attendees

स्कोपcalendar:read
सिग्नेचर
getEvent(id: string, options?: RequestScope): Promise<CalendarEventResource>

Returns a stored event with its attendees and their responses. What the server understood from the iCalendar data is structured here: recurrence holds the RRULE text, exdates the excluded instances, organizer the organiser and alarms the reminders as { minutesBefore, action }. The raw iCalendar source is not included, and getEventIcs serves the event as a document.

id is the event id, the eventId on an occurrence, and not the iCalendar uid. A recurring series is one event however many occurrences it has, so start and end describe its first instance. messageId and threadId link the event to mail in the mailbox when there is any.

Attendees come back in the order they were added, each with partstat, role, rsvp, cutype and respondedAt. A narrowed key gets a 404 unless one of the addresses it covers organises the event or is on the attendee list, and a key that holds a whole domain covers every address on it.

पैरामीटर

idstringआवश्यक

Event id, the eventId of an occurrence, such as cal_ followed by 24 hex characters.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

CalendarEventResource with id, uid, sequence, summary, description, location, url, start, end, allDay, timezone, recurrence, exdates, status, transparency, visibility, organizer, isOrganizer, source, messageId, threadId, alarms, attendees, createdAt and updatedAt.

उदाहरण

const { items: [first] } = await openemail.calendar.listEvents({ from: '2026-09-14T00:00:00Z', to: '2026-09-21T00:00:00Z' }) if (first) {    const event = await openemail.calendar.getEvent(first.eventId)    console.log(event.summary, event.recurrence ?? 'one off')    console.log(event.attendees.map((attendee) => `${attendee.email}: ${attendee.partstat}`))}

टिप्पणियाँ

  • status, transparency and visibility carry iCalendar values, and default to CONFIRMED, OPAQUE and PUBLIC.

  • An attendee's partstat defaults to NEEDS-ACTION and role to REQ-PARTICIPANT until a response is recorded.

इनमें भी उपलब्ध

API
GET /calendar/events/{id}
CLI
openemail calendar get-event

calendar.getEventIcs()

Download an event as an iCalendar document

स्कोपcalendar:read
सिग्नेचर
getEventIcs(id: string, options?: RequestScope): Promise<string>

Resolves with the event serialised as an .ics document, as a raw string rather than parsed JSON. The server sends it as text/calendar; charset=utf-8 with a download filename built from the event's uid, and the SDK requests that type and returns the body untouched.

The document declares METHOD:PUBLISH, and the content type carries no method parameter. That is deliberate: a REQUEST document makes a calendar client offer accept and decline and reply to the organiser, and this endpoint has no authority to invite anyone. Import it to show what the event currently is, not to send an invitation.

It holds one VEVENT with the attendees and their participation status, the recurrence rule, excluded dates and alarms. Lines end in CRLF and long lines are folded. DTSTAMP is the time of the request, so two downloads of an unchanged event differ on that line.

पैरामीटर

idstringआवश्यक

Event id, the eventId of an occurrence.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

string, the iCalendar text from BEGIN:VCALENDAR to END:VCALENDAR.

उदाहरण

const ics = await openemail.calendar.getEventIcs('cal_8d3f0a2b9c4e41f7a6b5c2d1')const summary = ics.split('\r\n').find((line) => line.startsWith('SUMMARY:')) console.log(summary)

टिप्पणियाँ

  • Errors still come back as JSON and throw OpenEmailApiError, so a failure never resolves as a string.

  • Timed events are written as UTC instants and all day events as DATE values, never as local times with a TZID.

  • A narrowed key gets a 404 on the same terms as getEvent.

इनमें भी उपलब्ध

API
GET /calendar/events/{id}/ics
CLI
openemail calendar get-event-ics

calendar.createEvent()

Put an event on the calendar

स्कोपcalendar:write
सिग्नेचर
createEvent(body: CalendarEventCreate, options?: RequestScope): Promise<CalendarEventResource>

Creates an event, as New event on the Calendar page of the app does. start and end take a Date or ISO 8601 with a zone, and timezone is the IANA zone the event belongs to, which decides what an all-day event means.

With attendees, an invitation goes to each of them by email from from, which has to be an address the key may send as, so the call also needs emails:send. Send sendInvites: false to keep it to your own calendar.

पैरामीटर

body.summarystringआवश्यक

The title, 1 to 255 characters.

body.startDate | stringआवश्यक

When it starts, a Date or ISO 8601 with a zone.

body.endDate | stringआवश्यक

When it ends, after start and at most two years later.

body.descriptionstring

Notes about the event, up to 8,000 characters.

body.locationstring

Where it is: a room, an address or a link.

body.urlstring

A link that belongs to the event.

body.allDayboolean

Whether it fills whole days. start and end then mark the days.

body.timezonestring

The IANA zone the event belongs to, UTC unless you say.

body.recurrencestring

An RRULE such as FREQ=WEEKLY;BYDAY=MO when it repeats.

body.attendeesArray<CalendarAttendeeInput>

Up to 200 people to invite, each { email, name?, optional? }.

body.remindersArray<CalendarReminderInput>

Up to five reminders, each { minutesBefore, action? }.

body.transparencyCalendarTransparency

OPAQUE shows you busy and TRANSPARENT free.

body.visibilityCalendarVisibility

PUBLIC, PRIVATE or CONFIDENTIAL.

body.sendInvitesboolean

False keeps the change to your own calendar, and sends nothing.

body.fromstring

The address the invitations come from. It has to be one the key may send as.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

CalendarEventResource for the new event, with its attendees and their responses.

उदाहरण

const event = await openemail.calendar.createEvent({    summary: 'Planning',    start: '2026-10-12T09:00:00Z',    end: '2026-10-12T09:30:00Z',    attendees: [{ email: '[email protected]' }],    from: '[email protected]'}) console.log(event.id, event.attendees.length)

टिप्पणियाँ

  • The SDK does not retry it, because a second call makes a second event and invites everybody again.

  • A key that may not send as from is refused with 403 from_address_forbidden, and an event with attendees and no from with 422 invalid_parameter. Invitations without emails:send are a 403 insufficient_scope.

इनमें भी उपलब्ध

API
POST /calendar/events
CLI
openemail calendar create-event

calendar.updateEvent()

Change an event

स्कोपcalendar:write
सिग्नेचर
updateEvent(id: string, patch: CalendarEventPatch, options?: RequestScope): Promise<CalendarEventResource>

Changes an event you organise. A field you leave out keeps its value, and attendees replaces the whole list. Everyone invited gets the updated invitation by email from from, so a change to an event with attendees needs emails:send too, unless sendInvites is false.

पैरामीटर

idstringआवश्यक

Event id, the eventId of an occurrence, such as cal_ followed by 24 hex characters.

patch.summarystring

The title, 1 to 255 characters.

patch.startDate | string

When it starts, a Date or ISO 8601 with a zone.

patch.endDate | string

When it ends, after start and at most two years later.

patch.descriptionstring

Notes about the event, up to 8,000 characters.

patch.locationstring

Where it is: a room, an address or a link.

patch.urlstring

A link that belongs to the event.

patch.allDayboolean

Whether it fills whole days. start and end then mark the days.

patch.timezonestring

The IANA zone the event belongs to, UTC unless you say.

patch.recurrencestring

An RRULE such as FREQ=WEEKLY;BYDAY=MO when it repeats.

patch.attendeesArray<CalendarAttendeeInput>

Up to 200 people to invite, each { email, name?, optional? }. It replaces the whole list.

patch.remindersArray<CalendarReminderInput>

Up to five reminders, each { minutesBefore, action? }.

patch.transparencyCalendarTransparency

OPAQUE shows you busy and TRANSPARENT free.

patch.visibilityCalendarVisibility

PUBLIC, PRIVATE or CONFIDENTIAL.

patch.sendInvitesboolean

False keeps the change to your own calendar, and sends nothing.

patch.fromstring

The address the invitations come from. It has to be one the key may send as.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

CalendarEventResource as it stands after the change, with sequence one higher.

उदाहरण

const event = await openemail.calendar.updateEvent('cal_3f9a1c7e5b2d48a06c1e9f4b', {    start: '2026-10-12T10:00:00Z',    end: '2026-10-12T10:30:00Z'}) console.log(event.start, event.sequence)

टिप्पणियाँ

  • The SDK does not retry it, because a retry after a lost response sends the update to everybody again.

  • An event organised by somebody else is refused with 403 not_organizer: answer it with respondToEvent instead. An event the key does not reach is a 404.

इनमें भी उपलब्ध

API
PATCH /calendar/events/{id}
CLI
openemail calendar update-event

calendar.deleteEvent()

Remove an event from the calendar

स्कोपcalendar:write
सिग्नेचर
deleteEvent(id: string, options?: RequestScope): Promise<DeletedCalendarEventResource>

Removes an event for good, as Remove does in the app. Nobody else is told, so call off a meeting with others in it with cancelEvent instead.

पैरामीटर

idstringआवश्यक

Event id, the eventId of an occurrence, such as cal_ followed by 24 hex characters.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

DeletedCalendarEventResource: { object, id, deleted: true }.

उदाहरण

await openemail.calendar.deleteEvent('cal_3f9a1c7e5b2d48a06c1e9f4b')

टिप्पणियाँ

  • An event organised by somebody else is refused with 403 not_organizer, and an event that is gone or that the key does not reach is a 404.

इनमें भी उपलब्ध

API
DELETE /calendar/events/{id}
CLI
openemail calendar delete-event

calendar.cancelEvent()

Call off a meeting

स्कोपcalendar:write
सिग्नेचर
cancelEvent(id: string, body?: CalendarEventCancel, options?: RequestScope): Promise<CalendarEventResource>

Cancels a meeting you organise, as Cancel meeting does in the app. It stays on the calendar with status CANCELLED, and everyone invited is told it is off by email from from, so a meeting with attendees also needs emails:send.

पैरामीटर

idstringआवश्यक

Event id, the eventId of an occurrence, such as cal_ followed by 24 hex characters.

body.fromstring

The address the cancellation comes from. It has to be one the key may send as.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

CalendarEventResource with status CANCELLED.

उदाहरण

const event = await openemail.calendar.cancelEvent('cal_3f9a1c7e5b2d48a06c1e9f4b', { from: '[email protected]' }) console.log(event.status)

टिप्पणियाँ

  • The SDK does not retry it, because a retry sends the cancellation again.

  • An event organised by somebody else is refused with 403 not_organizer.

इनमें भी उपलब्ध

API
POST /calendar/events/{id}/cancel
CLI
openemail calendar cancel-event

calendar.respondToEvent()

Answer an invitation

स्कोपcalendar:writeemails:send
सिग्नेचर
respondToEvent(id: string, body: CalendarEventAnswer, options?: RequestScope): Promise<CalendarEventResource>

Accepts, declines or tentatively accepts an invitation, as the buttons of an invitation do in the app. The answer goes to the organiser by email from the invited address the key may send as, or from respondingAs when the invitation went to more than one of yours, so it needs emails:send as well.

पैरामीटर

idstringआवश्यक

Event id, the eventId of an occurrence, such as cal_ followed by 24 hex characters.

body.responseCalendarResponseआवश्यक

ACCEPTED, DECLINED or TENTATIVE.

body.respondingAsstring

Which of your invited addresses answers, when there is more than one.

options.signalAbortSignal

Cancels the request.

options.apiKeystring

Overrides the client's API key for this call only.

लौटाता है

CalendarEventResource with your answer on your attendee row.

उदाहरण

const event = await openemail.calendar.respondToEvent('cal_3f9a1c7e5b2d48a06c1e9f4b', { response: 'ACCEPTED' }) console.log(event.attendees.map((attendee) => `${attendee.email}: ${attendee.partstat}`))

टिप्पणियाँ

  • An event that invited none of the addresses the key may send as is refused with 403 not_invited, and a cancelled meeting with 409 event_cancelled.

  • When the organiser cannot be reached, nothing changes and the call is a 409 reply_not_sent.

इनमें भी उपलब्ध

API
POST /calendar/events/{id}/respond
CLI
openemail calendar respond-to-event