client.calendar
Every method in this namespace: its signature, its parameters, what it returns and an example.
Methods
Calendar events found in mail, expanded into occurrences.
calendar.list_eventscalendar.list_all_eventscalendar.iterate_eventscalendar.get_eventcalendar.get_event_icscalendar.create_eventcalendar.update_eventcalendar.delete_eventcalendar.cancel_eventcalendar.respond_to_eventcalendar.decline_proposalcalendar.hide_eventcalendar.unhide_eventcalendar.free_busycalendar.list_calendarscalendar.get_calendarcalendar.create_calendarcalendar.update_calendarcalendar.delete_calendarcalendar.set_calendar_membercalendar.remove_calendar_membercalendar.list_calendar_loginscalendar.create_calendar_logincalendar.revoke_calendar_logincalendar.create_calendar_login_profile_linkcalendar.list_todoscalendar.list_all_todoscalendar.iterate_todoscalendar.get_todocalendar.create_todocalendar.update_todocalendar.delete_todocalendar.list_feedscalendar.create_feedcalendar.reset_feedcalendar.delete_feedcalendar.list_subscriptionscalendar.create_subscriptioncalendar.update_subscriptioncalendar.refresh_subscriptioncalendar.delete_subscriptioncalendar.import_icscalendar.list_importscalendar.list_all_importscalendar.iterate_importscalendar.get_importcalendar.undo_import
calendar.list_events
List one page of event occurrences inside a time window
list_events(from:, to:, timezone: nil, include_team: nil, q: nil, calendar_ids: nil, limit: nil, cursor: nil, api_key: nil) -> Nextmail::PageExpands your events into their 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 next_cursor while has_more? is true, with the same from:, to: and timezone:, to read every occurrence, or let list_all_events and iterate_events 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 Time, DateTime, Date or ISO 8601 String, and the SDK sends a Time or DateTime as a UTC ISO 8601 instant.
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.
Parameters
fromTime, DateTime, Date or StringRequiredStart of the window.
toTime, DateTime, Date or StringRequiredEnd of the window, after
fromand at most 366 days later.timezoneStringIANA zone such as
Europe/London, at most 64 characters. Defaults toUTC.include_teamBooleantrueadds the events of the rest of the workspace, apart from the ones marked private. Only a key of the workspace owner sees more with it. Defaults tofalse.qStringWords to look for in the title, the place and the organiser, at most 200 characters. Only events that hold every word come back, so pass a long window to find an event by name.
calendar_idsArray<String>Only the events in these calendars, by the ids
list_calendarsgives. Events from calendar subscriptions are left out when you name calendars.limitIntegerOccurrences per page, a whole number from 1 to 100. The server defaults to 25.
cursorStringThe
next_cursorof the previous page, sent with the same window. It is opaque, so never build one yourself.api_keyStringOverrides the client's API key for this call only.
Returns
The Nextmail::Page of occurrence Hashes, with items, has_more? and next_cursor. Each item has eventId, uid, start, end, allDay, summary, location, status, transparency, isOrganizer, organizerEmail, recurring, myPartstat and attendeeCount.
Example
from = Time.nowto = from + 7 * 24 * 60 * 60 page = client.calendar.list_events(from:, to:, timezone: "Europe/London", limit: 50) page.items.each do |occurrence| puts "#{occurrence[:start]} #{occurrence[:summary]} #{occurrence[:myPartstat] || "not invited"}"end p page.has_more?, page.next_cursorNotes
The list holds your own events: the ones you made and the ones an address of yours organises or attends. For the workspace owner and their keys, an address counts as theirs unless it was given to a teammate, and
include_team: trueadds the rest of the workspace, apart from events somebody marked private. A member's app and a narrowed key always get their own view.myPartstatis the response recorded for one of your own addresses, or for the addresses a narrowed key covers, and nil when none of them is an attendee.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
statusforCANCELLED.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.
Also available in
calendar.list_all_events
Collect every occurrence inside a time window into one array
list_all_events(from:, to:, timezone: nil, include_team: nil, q: nil, calendar_ids: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>Walks every page of list_events for one window and returns all of its occurrences, sorted by start time and then by event id. It follows next_cursor until has_more? 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 iterate_events when you can stop early.
Parameters
fromTime, DateTime, Date or StringRequiredStart of the window.
toTime, DateTime, Date or StringRequiredEnd of the window, after
fromand at most 366 days later.timezoneStringIANA zone such as
Europe/London, at most 64 characters. Defaults toUTC.include_teamBooleantrueadds the events of the rest of the workspace, apart from the ones marked private. Only a key of the workspace owner sees more with it. Defaults tofalse.qStringWords to look for in the title, the place and the organiser, at most 200 characters. Only events that hold every word come back, so pass a long window to find an event by name.
calendar_idsArray<String>Only the events in these calendars, by the ids
list_calendarsgives. Events from calendar subscriptions are left out when you name calendars.limitIntegerPage size for each request, 1 to 100. The server defaults to 25.
cursorStringStarts the walk from this cursor instead of the start of the window.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Array of occurrence Hashes holding every occurrence in the window, earliest first.
Example
occurrences = client.calendar.list_all_events( from: "2026-10-01T00:00:00Z", to: "2026-11-01T00:00:00Z", limit: 100) busy = occurrences.select { |occurrence| occurrence[:transparency] == "OPAQUE" } puts "#{busy.length} busy blocks in October"Notes
If any page fails the call raises, and the occurrences already fetched are discarded.
Also available in
calendar.iterate_events
Stream the occurrences inside a time window one at a time
iterate_events(from:, to:, timezone: nil, include_team: nil, q: nil, calendar_ids: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>Returns an Enumerator over the occurrences in one window that yields them individually, earliest first, or yields each one to a block when given one, and fetches the next page only when the current one is drained. Without a block 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 has_more? is false, when a page carries no next_cursor, or when the server repeats a cursor.
Parameters
fromTime, DateTime, Date or StringRequiredStart of the window.
toTime, DateTime, Date or StringRequiredEnd of the window, after
fromand at most 366 days later.timezoneStringIANA zone such as
Europe/London, at most 64 characters. Defaults toUTC.include_teamBooleantrueadds the events of the rest of the workspace, apart from the ones marked private. Only a key of the workspace owner sees more with it. Defaults tofalse.qStringWords to look for in the title, the place and the organiser, at most 200 characters. Only events that hold every word come back, so pass a long window to find an event by name.
calendar_idsArray<String>Only the events in these calendars, by the ids
list_calendarsgives. Events from calendar subscriptions are left out when you name calendars.limitIntegerPage size per request, 1 to 100. The server defaults to 25.
cursorStringStarts the walk from this cursor instead of the start of the window.
api_keyStringOverrides the client API key for every page of this walk.
Returns
An Enumerator of occurrence Hashes (or yields each one to a block), one occurrence per step.
Example
from = Time.nowto = from + 30 * 24 * 60 * 60 meeting = client.calendar.iterate_events(from:, to:).find { |occurrence| occurrence[:myPartstat] } puts "next meeting #{meeting[:start]} #{meeting[:summary]}" if meetingNotes
A page request that fails raises out of the loop, after every occurrence of the pages before it has been yielded.
Also available in
calendar.get_event
Read an event with its attendees
get_event(id, api_key: nil) -> HashReturns 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, each a Hash with minutesBefore and action. The raw iCalendar source is not included, and get_event_ics 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.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash 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.
Example
event = client.calendar.get_event("cal_3f9a1c7e5b2d48a06c1e9f4b") puts event[:summary], event[:recurrence] || "one off"p event[:attendees].map { |attendee| "#{attendee[:email]}: #{attendee[:partstat]}" }Notes
status,transparencyandvisibilitycarry iCalendar values, and default toCONFIRMED,OPAQUEandPUBLIC.An attendee's
partstatdefaults toNEEDS-ACTIONandroletoREQ-PARTICIPANTuntil a response is recorded.
Also available in
calendar.get_event_ics
Download an event as an iCalendar document
get_event_ics(id, api_key: nil) -> StringReturns the event serialised as an .ics document, as a raw String rather than a parsed Hash. 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 as a UTF-8 String without parsing it.
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.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence.api_keyStringOverrides the client's API key for this call only.
Returns
A String, the iCalendar text from BEGIN:VCALENDAR to END:VCALENDAR.
Example
ics = client.calendar.get_event_ics("cal_8d3f0a2b9c4e41f7a6b5c2d1")summary = ics.split("\r\n").find { |line| line.start_with?("SUMMARY:") } puts summaryNotes
Errors still come back as JSON and raise
Nextmail::ApiError, so a failure never comes back as a String.Timed events are written in the zone they were created in, as local times with a
TZIDand aVTIMEZONEthat carries the rules of that zone, and all day events asDATEvalues.A narrowed key gets a 404 on the same terms as
get_event.
Also available in
calendar.create_event
Put an event on the calendar
create_event(body = nil, api_key: nil, **fields) -> HashCreates an event, as New event on the Calendar page of the app does. start and end take a Time or ISO 8601 with a zone, and the SDK sends a Time as a UTC instant. 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.
Parameters
summaryStringRequiredThe title, 1 to 255 characters.
startTime, DateTime, Date or StringRequiredWhen it starts, a
Timeor ISO 8601 with a zone.endTime, DateTime, Date or StringRequiredWhen it ends, after
startand at most two years later.descriptionStringNotes about the event, up to 8,000 characters.
locationStringWhere it is: a room, an address or a link.
urlStringA link that belongs to the event.
meetingUrlStringThe link to the video call, such as a Zoom, Meet or Teams address. The invitation carries it, so guests get a Join button in their calendar too.
allDayBooleanWhether it fills whole days.
startandendthen mark the days.timezoneStringThe IANA zone the event belongs to,
UTCunless you say.recurrenceStringAn RRULE such as
FREQ=WEEKLY;BYDAY=MOwhen it repeats.attendeesArray<Hash>Up to 200 people to invite, each a Hash with
emailand, if you like,nameandoptional.remindersArray<Hash>Up to five reminders, each a Hash with
minutesBeforeand, if you like,action.transparencyStringOPAQUEshows you busy andTRANSPARENTfree.visibilityStringPUBLIC,PRIVATEorCONFIDENTIAL.sendInvitesBooleanFalse keeps the change to your own calendar, and sends nothing.
fromStringThe address the invitations come from. It has to be one the key may send as.
calendarIdStringThe calendar to put it in: one you keep, or one you are a member of with write access. Your default calendar unless you say.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash for the new event, shaped like the one get_event returns, with its attendees and their responses.
Example
event = client.calendar.create_event( summary: "Planning", start: Time.utc(2026, 10, 12, 9, 0), end: Time.utc(2026, 10, 12, 9, 30), attendees: [{email: "[email protected]"}], from: "[email protected]") puts event[:id], event[:attendees].lengthNotes
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
fromis refused with 403from_address_forbidden, and an event with attendees and nofromwith 422invalid_parameter. Invitations withoutemails:sendare a 403insufficient_scope.
Also available in
calendar.update_event
Change an event
update_event(id, patch = nil, api_key: nil, **fields) -> HashChanges 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.
For a repeating event, scope says which dates change, as the app asks when you edit one date: occurrence changes only the date that starts at occurrenceStart, following that date and every one after it, and series all of them. With following the later dates become a new series with its own id, which is what comes back, and the old one ends the day before.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.summaryStringThe title, 1 to 255 characters.
startTime, DateTime, Date or StringWhen it starts, a
Timeor ISO 8601 with a zone.endTime, DateTime, Date or StringWhen it ends, after
startand at most two years later.descriptionStringNotes about the event, up to 8,000 characters.
locationStringWhere it is: a room, an address or a link.
urlStringA link that belongs to the event.
meetingUrlStringThe link to the video call. An empty string takes it off.
allDayBooleanWhether it fills whole days.
startandendthen mark the days.timezoneStringThe IANA zone the event belongs to,
UTCunless you say.recurrenceStringAn RRULE such as
FREQ=WEEKLY;BYDAY=MOwhen it repeats.attendeesArray<Hash>Up to 200 people to invite, each a Hash with
emailand, if you like,nameandoptional. It replaces the whole list.remindersArray<Hash>Up to five reminders, each a Hash with
minutesBeforeand, if you like,action.transparencyStringOPAQUEshows you busy andTRANSPARENTfree.visibilityStringPUBLIC,PRIVATEorCONFIDENTIAL.sendInvitesBooleanFalse keeps the change to your own calendar, and sends nothing.
fromStringThe address the invitations come from. It has to be one the key may send as.
calendarIdStringMoves the event, with every date of a repeating one, to this calendar: one you keep, or one you are a member of with write access. A move on its own tells nobody.
scopeStringoccurrence,followingorseries: which dates of a repeating event change. Left out, the change reaches the event or date the id names.occurrenceStartTime, DateTime, Date or StringThe start of the date you mean, as
list_eventsgives it. Needed withoccurrenceandfollowing.api_keyStringOverrides the client's API key for this call only.
Returns
The event Hash as it stands after the change, shaped like the one get_event returns, with sequence one higher.
Example
event = client.calendar.update_event( "cal_3f9a1c7e5b2d48a06c1e9f4b", start: "2026-10-12T10:00:00Z", end: "2026-10-12T10:30:00Z") puts event[:start], event[:sequence]Notes
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 withrespond_to_eventinstead. An event the key does not reach is a 404.
Also available in
calendar.delete_event
Remove an event from the calendar
delete_event(id, scope: nil, occurrence_start: nil, api_key: nil) -> HashRemoves an event for good, as Remove does in the app. Nobody else is told, so call off a meeting with others in it with cancel_event instead. For a repeating event, scope: occurrence with occurrence_start: removes one date, and following that date and every one after it.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.scopeStringoccurrence,followingorseries: which dates of a repeating event go.occurrence_startTime, DateTime, Date or StringThe start of the date you mean, as
list_eventsgives it. Needed withoccurrenceandfollowing.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id and deleted set to true.
Example
client.calendar.delete_event("cal_3f9a1c7e5b2d48a06c1e9f4b", scope: "occurrence", occurrence_start: "2026-10-19T09:00:00Z")Notes
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. An event you may not remove can still be taken off your own calendar withhide_event.
Also available in
calendar.cancel_event
Call off a meeting
cancel_event(id, body = nil, api_key: nil, **fields) -> HashCancels 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.
For a repeating meeting, scope occurrence with occurrenceStart calls off one date, and following that date and every one after it. Guests get the matching update.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.fromStringThe address the cancellation comes from. It has to be one the key may send as.
scopeStringoccurrence,followingorseries: which dates of a repeating meeting are called off.occurrenceStartTime, DateTime, Date or StringThe start of the date you mean, as
list_eventsgives it. Needed withoccurrenceandfollowing.api_keyStringOverrides the client's API key for this call only.
Returns
The event Hash, shaped like the one get_event returns, with status set to CANCELLED.
Example
event = client.calendar.cancel_event("cal_3f9a1c7e5b2d48a06c1e9f4b", from: "[email protected]") puts event[:status]Notes
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.
Also available in
calendar.respond_to_event
Answer an invitation
respond_to_event(id, body = nil, api_key: nil, **fields) -> HashAccepts, 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.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.responseStringRequiredACCEPTED,DECLINEDorTENTATIVE.respondingAsStringWhich of your invited addresses answers, when there is more than one.
proposedStartTime, DateTime, Date or StringA new start to propose with your answer, a
Timeor ISO 8601 with a zone, sent together withproposedEnd.proposedEndTime, DateTime, Date or StringThe end of the proposed time.
api_keyStringOverrides the client's API key for this call only.
Returns
The event Hash, shaped like the one get_event returns, with your answer on your attendee row.
Example
event = client.calendar.respond_to_event("cal_3f9a1c7e5b2d48a06c1e9f4b", response: "ACCEPTED") p event[:attendees].map { |attendee| "#{attendee[:email]}: #{attendee[:partstat]}" }Notes
An event that invited none of the addresses the key may send as is refused with 403
not_invited, and a cancelled meeting with 409event_cancelled.When the organiser cannot be reached, nothing changes and the call is a 409
reply_not_sent.With
proposedStartandproposedEndthe organiser gets a counter-proposal, as Propose a new time sends from Google Calendar and Outlook, and decides whether to move the meeting.
Also available in
calendar.decline_proposal
Decline a proposed time
decline_proposal(id, body = nil, api_key: nil, **fields) -> HashKeeps the original time of a meeting you organise after a guest proposed another one, as Keep the original does on the event in the app. The guest is told by email from from, or from the organising address, so it needs emails:send as well. To take the proposed time instead, change the event with update_event.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.attendeeStringRequiredThe guest whose proposal you decline, by email address.
fromStringThe address the answer is sent from, when it is not the organising address.
api_keyStringOverrides the client's API key for this call only.
Returns
The event Hash, shaped like the one get_event returns, with the guest's proposedStart and proposedEnd cleared.
Example
event = client.calendar.decline_proposal("cal_3f9a1c7e5b2d48a06c1e9f4b", attendee: "[email protected]") puts "#{event[:summary]} keeps its time"Notes
A guest who has not proposed a new time is refused with 404
proposal_not_found, and an event somebody else organises with 403not_organizer.
Also available in
calendar.hide_event
Hide an event from your calendar
hide_event(id, api_key: nil) -> HashTakes an event off your own calendar and leaves it for everyone else, as Hide from my calendar does in the app. Use it for an invitation that reached you through a shared address, or an event you may not remove. It hides every date of a repeating event, and stops its reminders for you. unhide_event brings it back.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id, uid and hidden set to true.
Example
hidden = client.calendar.hide_event("cal_3f9a1c7e5b2d48a06c1e9f4b") puts hidden[:hidden]Notes
Hiding an event that is already hidden changes nothing, so it is safe to repeat. An event the key does not reach is a 404.
It hides the event for the person the key or app acts for, and nobody else.
list_eventsleaves it out from then on, andget_eventstill finds it, withhiddentrue.
Also available in
calendar.unhide_event
Show a hidden event again
unhide_event(id, api_key: nil) -> HashPuts an event you hid back on your calendar, as Show on my calendar does on the invitation in the app.
Parameters
idStringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id, uid and hidden set to false.
Example
client.calendar.unhide_event("cal_3f9a1c7e5b2d48a06c1e9f4b")Notes
An event that was not hidden stays as it was, so it is safe to repeat.
Also available in
calendar.free_busy
Free and busy times
free_busy(emails:, from:, to:, timezone: nil, duration_minutes: nil, api_key: nil) -> HashWhen the people you name are busy, as Find a time in the event editor of the app shows it. An address of the workspace shows the busy times of the person who holds it, from their events, the invitations they have not declined, their subscribed calendars and their bookings, without any detail. Any other address comes back with known false.
With duration_minutes:, suggestions lists up to five times when everyone known is free, on weekdays between 09:00 and 17:00 in timezone:. from: and to: take a Time or an ISO 8601 string and may be at most 31 days apart.
Parameters
emailsArray<String>RequiredThe addresses to look up, at most 20.
fromTime, DateTime, Date or StringRequiredThe start of the window.
toTime, DateTime, Date or StringRequiredThe end of the window, at most 31 days after
from.timezoneStringThe IANA zone the suggested times keep to working hours in,
UTCunless you say.duration_minutesIntegerThe length of the meeting, 5 to 480 minutes. Send it to get
suggestions.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with people, each with email, known and busy, its busy times as Hashes with start and end, and suggestions in the same shape.
Example
times = client.calendar.free_busy( emails: ["[email protected]", "[email protected]"], from: Time.now, to: Time.now + (7 * 24 * 60 * 60), timezone: "Europe/London", duration_minutes: 30) times[:suggestions].each { |time| puts time[:start] }Notes
A key or an app limited to particular addresses or domains is refused with 422
capability_unsupported, because the answer reads whole calendars.It reads the calendars as they are now and holds nothing, so a suggested time can be gone a moment later.
Also available in
calendar.list_calendars
List your calendars
list_calendars(kind: nil, api_key: nil) -> Array<Hash>Every calendar you keep, your default one among them, then the calendars other members of the workspace gave you access to, as the calendar list beside the Calendar page shows them. Each event is in one calendar, new events and invitations go to your default calendar, and calendar apps that sync over CalDAV show each calendar as one of its own. Your to-do lists are calendars too: kind: "todos" lists them instead.
Parameters
kindStringeventsfor your calendars of events, ortodosfor your to-do lists, fromNextmail::CALENDAR_KINDS.eventsunless you say.api_keyStringOverrides the client's API key for this call only.
Returns
An Array of calendar Hashes, the ones you keep first, each with id, name, color, description, isDefault, position, access, owner and members. access is one of Nextmail::COLLECTION_RIGHTS. A calendar you keep lists its members, and one you are a member of has members set to nil and the access its keeper gave you.
Example
client.calendar.list_calendars.each do |calendar| label = calendar[:isDefault] ? "#{calendar[:name]} (default)" : calendar[:name] puts "#{label}: #{calendar[:access]}"endNotes
A key or app limited to some addresses is refused with 422
capability_unsupported, because calendars belong to a person, not to an address.An API key lists the calendars of the workspace owner, and an app those of the person who connected it.
Also available in
calendar.get_calendar
Get one calendar
get_calendar(id, api_key: nil) -> HashOne calendar you keep or are a member of, with its members when you keep it.
Parameters
idStringRequiredThe calendar id,
cln_followed by 24 hex characters, aslist_calendarsgives it.api_keyStringOverrides the client's API key for this call only.
Returns
The calendar Hash, with id, name, color, description, isDefault, position, access, owner and members.
Example
calendar = client.calendar.get_calendar("cln_3f9a1c7e5b2d48a06c1e9f4b") puts calendar[:name], Array(calendar[:members]).lengthNotes
A calendar you neither keep nor are a member of is a 404
calendar_not_found.
Also available in
calendar.create_calendar
Create a calendar
create_calendar(body = nil, api_key: nil, **fields) -> HashMakes a new calendar of yours, such as Work or Family, as New calendar does in the app. Put events in it with calendarId on create_event, or move them there with update_event. With kind: "todos" it is a to-do list instead, for create_todo.
Parameters
nameStringRequiredThe name the apps show, 1 to 100 characters.
kindStringeventsfor a calendar of events, ortodosfor a to-do list, fromNextmail::CALENDAR_KINDS.eventsunless you say.colorStringThe colour its events are drawn in, from
Nextmail::CALENDAR_COLORS. Blue unless you say.descriptionStringWhat the calendar is for, up to 1,000 characters.
api_keyStringOverrides the client's API key for this call only.
Returns
The calendar Hash for the new calendar, which is never your default one.
Example
calendar = client.calendar.create_calendar(name: "Family", color: "green") client.calendar.create_event( summary: "School play", start: "2026-12-04T17:00:00Z", end: "2026-12-04T19:00:00Z", calendarId: calendar[:id])Notes
One person may keep 50 calendars and 50 to-do lists. One more is refused with 409
calendar_limit.
Also available in
calendar.update_calendar
Change a calendar
update_calendar(id, patch = nil, api_key: nil, **fields) -> HashRenames a calendar you keep, describes it, gives it another colour, moves it in your list or makes it your default. For a calendar you are a member of, color and position are your own and change only for you.
Parameters
idStringRequiredThe calendar id,
cln_followed by 24 hex characters, aslist_calendarsgives it.nameStringThe new name, 1 to 100 characters.
colorStringThe new colour, from
Nextmail::CALENDAR_COLORS.descriptionStringWhat the calendar is for.
nilclears it.positionIntegerIts place in your list, from 0 at the top. The calendars you keep and the ones you are a member of are ordered apart.
isDefaultBooleantruemakes it your default calendar, where new events and invitations go.api_keyStringOverrides the client's API key for this call only.
Returns
The calendar Hash as it stands now.
Example
calendar = client.calendar.update_calendar( "cln_3f9a1c7e5b2d48a06c1e9f4b", name: "Work", color: "purple", isDefault: true) puts calendar[:name], calendar[:isDefault]Notes
Renaming or describing a calendar you are a member of is a 403
calendar_not_owned.isDefault: falseon your default calendar is a 409calendar_is_default: make another calendar the default instead.
Also available in
calendar.delete_calendar
Delete a calendar
delete_calendar(id, notify_guests: nil, api_key: nil) -> HashDeletes a calendar you keep and the events in it, as Delete calendar does in the app. Everyone invited to an upcoming meeting you organised in it is sent a cancellation from the address that invited them, as cancel_event does, unless notify_guests: is false. A meeting that came in through a calendar import is cancelled quietly unless notify_guests: is true. Its members lose it, and calendar links that publish it stop working. A to-do list goes with its to-dos. For a calendar you are a member of, you leave it, it stays with its keeper and nobody is told.
Parameters
idStringRequiredThe calendar id,
cln_followed by 24 hex characters, aslist_calendarsgives it.notify_guestsBooleanfalsedeletes it without telling anyone. Left out ortrue, the guests of its upcoming meetings are sent a cancellation, andtruetells the guests of imported meetings too.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id, deleted set to true and cancelledMeetings, how many meetings had their guests told.
Example
gone = client.calendar.delete_calendar("cln_3f9a1c7e5b2d48a06c1e9f4b") puts "#{gone[:cancelledMeetings]} meetings cancelled"Notes
Your default calendar cannot be deleted: that is a 409
calendar_is_default.Sending the cancellations needs
emails:sendas well. A key without it passesnotify_guests: false.
Also available in
calendar.set_calendar_member
Give a member access to a calendar
set_calendar_member(id, member_id, body = nil, api_key: nil, **fields) -> HashGives a member of the workspace access to a calendar you keep, or changes what they may do. With read they see its events beside their own calendars, and with write they also add, change, move and remove them. Their phones and computers show it as a calendar of its own over CalDAV. Events marked private stay out of their view.
Parameters
idStringRequiredThe calendar id,
cln_followed by 24 hex characters, aslist_calendarsgives it.member_idStringRequiredThe member id of the person, as
members.listgives it.accessStringRequiredreadorwrite.Nextmail::COLLECTION_ACCESS_LEVELSholds the values.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash for the member, with calendarId, memberId, name, email and the access they now have.
Example
member = client.calendar.set_calendar_member( "cln_3f9a1c7e5b2d48a06c1e9f4b", "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E", access: Nextmail::COLLECTION_ACCESS_LEVELS[:WRITE]) puts member[:email], member[:access]Notes
Setting it again changes the access, so retrying is safe, and the SDK retries it after a network failure.
A calendar may have 100 members. One more is a 409
calendar_member_limit.Someone outside the workspace is a 422
member_not_found, and yourself a 422member_is_keeper.
Also available in
calendar.remove_calendar_member
Take away a member's access to a calendar
remove_calendar_member(id, member_id, api_key: nil) -> HashTakes away a member's access to a calendar you keep. Your own member id leaves a calendar you are a member of.
Parameters
idStringRequiredThe calendar id,
cln_followed by 24 hex characters, aslist_calendarsgives it.member_idStringRequiredThe member id of the person, as
members.listgives it.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, calendarId, memberId and deleted set to true.
Example
client.calendar.remove_calendar_member("cln_3f9a1c7e5b2d48a06c1e9f4b", "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E")Notes
Removing someone who is not a member is a 422
member_not_found.
Also available in
calendar.list_calendar_logins
List calendar sign-ins
list_calendar_logins(member: nil, api_key: nil) -> Array<Hash>The calendar sign-ins one person holds, newest first: their names, usernames, the last four letters of each password, who made each one and when a calendar or contacts app last used it. The passwords are never shown again.
A calendar sign-in belongs to a person, not to an address. Its username is cal- and ten letters and digits, never an address, so it can never take one, and it signs calendar and contacts apps in over CalDAV and CardDAV to that person's calendars, the calendars and address books other members gave them access to, and their contacts. IMAP, POP3 and SMTP refuse it, and nothing it does sends mail.
Parameters
memberStringThe user id of a member, as
members.listgives it, for the owner or someone whose role manages members. Leave it out for your own, which for an API key are the workspace owner's and for an access token those of the person who connected the app. Another member's takesmembers:writeinstead ofaccount:read.api_keyStringOverrides the client's API key for this call only.
Returns
An Array of sign-in Hashes, newest first, each with object set to calendar_login, id, name, username, last4, member and createdBy with id, name and email (createdBy is nil when nobody is known to have made it), createdAt, lastUsedAt, lastUsedProtocol (caldav or carddav) and lastUsedClient. Revoked sign-ins are left out.
Example
client.calendar.list_calendar_logins.each do |login| puts "#{login[:name]} #{login[:username]} #{login[:lastUsedAt] || "never used"}"endNotes
A key or app limited to some addresses is refused with 422
capability_unsupported, because a sign-in covers the whole calendar and address book.Someone outside the workspace is a 422
member_not_found, and another member's sign-ins without the authority to manage members a 403insufficient_authority.
Also available in
calendar.create_calendar_login
Create a calendar sign-in
create_calendar_login(body = nil, api_key: nil, **fields) -> HashMakes a calendar sign-in and returns its username, its password in password, the CalDAV and CardDAV servers in servers and an Apple configuration profile in appleProfile. That is the only time the password is shown, so hand it over or store it then.
A calendar sign-in belongs to a person, not to an address. Its username is cal- and ten letters and digits, never an address, so it can never take one, and it signs calendar and contacts apps in over CalDAV and CardDAV to that person's calendars, the calendars and address books other members gave them access to, and their contacts. IMAP, POP3 and SMTP refuse it, and nothing it does sends mail.
Besides account:write, or members:write for another member, the key or access token has to hold itself each of calendar:read, calendar:write, contacts:read and contacts:write that the person's role holds, because the sign-in carries them. Without one of them the call is refused with 403 insufficient_authority. It writes an entry in the workspace security log.
Parameters
nameStringRequiredWhat to call it, such as the device it is for, 1 to 64 characters. It is trimmed.
memberStringThe user id of a member, as
members.listgives it, for the owner or someone whose role manages members. Leave it out for your own, which an API key makes for the workspace owner and an access token for the person who connected the app. The owner's own sign-ins are made only by the owner.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with the fields list_calendar_logins returns for each sign-in, plus password, shown this once, servers with username, caldav and carddav (each with url, principalUrl, host, port and security, or nil when the person's role does not reach the calendar or contacts), and appleProfile, an Apple configuration profile with the password inside. Saved as a .mobileconfig file and opened on an iPhone, iPad or Mac, it adds the calendars to Calendar and the contacts to Contacts in one step, and no mail account. It holds the password, so keep it like one.
Example
created = client.calendar.create_calendar_login(name: "Kitchen iPad") puts "Server #{created.dig(:servers, :caldav, :url)}"puts "Sign in as #{created[:username]} with #{created[:password]}"Notes
One person holds at most 20 calendar sign-ins in a workspace, and the 21st is refused with 422
calendar_login_limit_reached, so revoke one withrevoke_calendar_loginfirst. A role that reaches neither the calendar nor contacts is refused with 403calendar_login_no_reach.A key or an access token limited to particular addresses or domains is refused with 422
capability_unsupported.An OAuth access token needs a verification code for this call, and is refused with 403
step_up_requireduntil the app has verified one in the last 60 minutes.step_up_required?on the error says so. An API key is never asked for a code.Not retried automatically by the SDK, since a lost attempt may already have made a sign-in. The success status is 201.
Also available in
calendar.revoke_calendar_login
Revoke a calendar sign-in
revoke_calendar_login(id, api_key: nil) -> HashRevokes one calendar sign-in, so the calendar and contacts apps using it are signed out within minutes. The calendars and contacts stay. Your own takes account:write, and another member's takes members:write, held by the owner or someone whose role manages members. It writes an entry in the workspace security log.
Parameters
idStringRequiredThe sign-in id,
cdl_followed by 24 hex characters, aslist_calendar_loginsgives it.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to calendar_login, id and deleted set to true.
Example
client.calendar.revoke_calendar_login("cdl_6b1e0f9a3c7d48e25a0b9c14")Notes
A sign-in you may not manage, or one already revoked, is a 404
calendar_login_not_found.
Also available in
calendar.create_calendar_login_profile_link
Make a link that sets up calendars and contacts on an Apple device
create_calendar_login_profile_link(body = nil, api_key: nil, **fields) -> HashMakes a one-time link that sets calendars and contacts up on an iPhone, iPad or Mac in one step. Opening it on the device downloads an Apple configuration profile with a new calendar sign-in inside, with CalDAV and CardDAV only and never mail. The link works once and expires within minutes, so hand it over straight away and treat it as a secret until it is used. It takes what create_calendar_login takes.
Parameters
nameStringRequiredWhat to call the sign-in it makes, such as the device it is for, 1 to 64 characters.
displayNameStringRequiredThe name the device shows for the profile, 1 to 160 characters.
descriptionStringRequiredThe line the device shows under that name, 1 to 160 characters.
memberStringThe user id of a member, as
members.listgives it, for the owner or someone whose role manages members. Leave it out for your own, which an API key makes for the workspace owner and an access token for the person who connected the app.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object set to calendar_login_profile_link, url, the link to open on the device, expiresAt, when it stops working, and member, the person the sign-in will belong to, with id, name and email.
Example
link = client.calendar.create_calendar_login_profile_link( name: "iPhone", displayName: "Work calendar", description: "Your calendars and contacts") puts "Open #{link[:url]} on the iPhone before #{link[:expiresAt]}"Notes
A person can make 10 of these links an hour, counted together with the links that set up an address on an Apple device. One more is a 429
profile_link_rate_limited.An OAuth access token needs a verification code for this call, as
create_calendar_logindoes. An API key is never asked for a code.Not retried automatically by the SDK. The success status is 201.
Also available in
- API
POST /calendar/logins/profile-link- TypeScript
calendar.createCalendarLoginProfileLink()- Python
calendar.create_calendar_login_profile_link()- PHP
calendar->createCalendarLoginProfileLink- Go
Calendar.CreateCalendarLoginProfileLink- Java
calendar().createCalendarLoginProfileLink- C#
Calendar.CreateCalendarLoginProfileLinkAsync
calendar.list_todos
List to-dos
list_todos(calendar_ids: nil, state: nil, due_before: nil, due_after: nil, limit: nil, cursor: nil, api_key: nil) -> Nextmail::PageReturns one page of the to-dos in your to-do lists and in the ones other members of the workspace gave you access to, as the To-dos view of the Calendar page shows them. A to-do list is a calendar of kind todos, and calendar apps such as Reminders, Thunderbird and tasks.org sync each one over CalDAV.
Open to-dos come soonest due first, with the ones without a due date last. Done ones come most recently done first, and all lists the newest first. Paging is keyset. limit: takes 1 to 500 and defaults to 100, and next_cursor goes back as cursor: while has_more? is true. list_all_todos and iterate_todos do that walk for you.
Parameters
calendar_idsArray<String>Only the to-dos in these to-do lists, by the ids
list_calendars(kind: "todos")gives. Every to-do list you keep or are a member of unless you say.stateStringopenfor to-dos still to do,donefor completed and cancelled ones, orall, fromNextmail::TODO_STATES.openunless you say.due_beforeTime, DateTime, Date or StringOnly to-dos due before this moment.
due_afterTime, DateTime, Date or StringOnly to-dos due at or after this moment.
limitIntegerTo-dos per page, a whole number from 1 to 500. The server defaults to 100.
cursorStringThe
next_cursorfrom the previous page. Never build one yourself.api_keyStringOverrides the client's API key for this call only.
Returns
The Nextmail::Page with items, has_more? and next_cursor. Each to-do is a Hash shaped like the one get_todo returns.
Example
page = client.calendar.list_todos(due_before: Time.now + (7 * 24 * 60 * 60)) page.items.each do |todo| puts "#{todo[:due] || "someday"} #{todo[:title]}"endNotes
A list id that is a calendar of events is a 422
calendar_wrong_kind, and one you cannot reach a 404calendar_not_found.A cursor that names no to-do in these lists is a 400
invalid_cursor.A key or app limited to some addresses is refused with 422
capability_unsupported, because to-do lists belong to a person, not to an address.
Also available in
calendar.list_all_todos
Collect every to-do into one array
list_all_todos(calendar_ids: nil, state: nil, due_before: nil, due_after: nil, limit: nil, cursor: nil, api_key: nil) -> Array<Hash>Follows next_cursor from page to page and returns every to-do that matches, in the order list_todos gives them.
Everything is held in memory before the call returns. Prefer iterate_todos when you can stop early. limit: sets the page size of each request, not the total.
Parameters
calendar_idsArray<String>Only the to-dos in these to-do lists, by the ids
list_calendars(kind: "todos")gives. Every to-do list you keep or are a member of unless you say.stateStringopenfor to-dos still to do,donefor completed and cancelled ones, orall, fromNextmail::TODO_STATES.openunless you say.due_beforeTime, DateTime, Date or StringOnly to-dos due before this moment.
due_afterTime, DateTime, Date or StringOnly to-dos due at or after this moment.
limitIntegerPage size per request, from 1 to 500, defaulting to 100 on the server.
cursorStringA cursor from an earlier page to start after.
api_keyStringOverrides the client's API key for every page of this walk.
Returns
An Array of Hashes holding every matching to-do across all pages.
Example
done = client.calendar.list_all_todos(state: Nextmail::TODO_STATES[:DONE]) puts "#{done.size} to-dos done"Notes
A failure on any page raises out of the whole call, and the to-dos already fetched are discarded.
Also available in
calendar.iterate_todos
Stream to-dos one at a time
iterate_todos(calendar_ids: nil, state: nil, due_before: nil, due_after: nil, limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>Returns an Enumerator that yields to-dos individually, in the order list_todos gives them, or yields each one to a block when given one, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.
Parameters
calendar_idsArray<String>Only the to-dos in these to-do lists, by the ids
list_calendars(kind: "todos")gives. Every to-do list you keep or are a member of unless you say.stateStringopenfor to-dos still to do,donefor completed and cancelled ones, orall, fromNextmail::TODO_STATES.openunless you say.due_beforeTime, DateTime, Date or StringOnly to-dos due before this moment.
due_afterTime, DateTime, Date or StringOnly to-dos due at or after this moment.
limitIntegerPage size per request, from 1 to 500, defaulting to 100 on the server.
cursorStringA cursor from an earlier page to start after.
api_keyStringOverrides the client's API key for every page of this walk.
Returns
An Enumerator of Hashes, one to-do per step, or yields each one to a block.
Example
client.calendar.iterate_todos do |todo| next unless (1..4).cover?(todo[:priority]) puts "urgent #{todo[:title]}"endNotes
The Enumerator is lazy, so an abandoned loop costs only the pages you consumed.
Also available in
calendar.get_todo
Get a to-do
get_todo(id, api_key: nil) -> HashOne to-do in a to-do list you keep or are a member of.
Parameters
idStringRequiredThe to-do id,
tdo_followed by 24 hex characters, aslist_todosgives it.api_keyStringOverrides the client's API key for this call only.
Returns
The to-do Hash, with id, calendarId, uid, title, notes, status, start, due, allDay, timezone, completedAt, priority, percentComplete, categories, parentId, recurrence, createdAt and updatedAt. status is one of Nextmail::TODO_STATUSES, and start and due are a day as YYYY-MM-DD when allDay is true, otherwise an ISO 8601 date-time in UTC.
Example
todo = client.calendar.get_todo("tdo_8c1e0f3a9b7d42e65a1c0d9e") puts todo[:title], todo[:status], todo[:due]Notes
A to-do that is gone, or that is in a list you cannot reach, is a 404
todo_not_found.
Also available in
calendar.create_todo
Create a to-do
create_todo(body = nil, api_key: nil, **fields) -> HashAdds a to-do to a to-do list, as the quick add box of the To-dos view does in the app. It goes in your default to-do list unless you name one with calendarId: one you keep, or one you are a member of with write access. Calendar apps that sync the list show it on their next sync.
Parameters
titleStringRequiredWhat has to be done, 1 to 500 characters.
calendarIdStringThe to-do list to put it in. Your default to-do list unless you say.
notesStringNotes on the to-do, up to 8,000 characters.
statusStringFrom
Nextmail::TODO_STATUSES:NEEDS-ACTION,IN-PROCESS,COMPLETEDorCANCELLED.startTime, DateTime, Date or StringWhen work on it can start, in the same form as
due.dueTime, DateTime, Date or StringWhen it is due: a day as
YYYY-MM-DD, or a moment as aTimeor an ISO 8601 date-time. The SDK sends aTimeor DateTime as a UTC instant, and a Ruby Date as its day.timezoneStringThe IANA time zone a moment is written in for calendar apps, such as
Europe/Berlin. UTC unless you say.priorityIntegerFrom 1, the most urgent, to 9, the least. 0 means none.
percentCompleteIntegerHow far along it is, from 0 to 100.
categoriesArray<String>Up to 20 labels of up to 64 characters each.
parentIdStringMakes it a step of another to-do in the same list.
recurrenceStringAn RRULE, such as
FREQ=WEEKLY;BYDAY=MO, that makes it repeat from its start or due date.api_keyStringOverrides the client's API key for this call only.
Returns
The to-do Hash for the new to-do.
Example
lists = client.calendar.list_calendars(kind: Nextmail::CALENDAR_KINDS[:TODOS])home = lists.find { |list| list[:isDefault] } || lists.first client.calendar.create_todo(title: "Renew the passport", calendarId: home[:id], due: "2026-11-20", priority: 1)Notes
startanddueare both days or both moments, and a to-do cannot be due before it starts: otherwise a 400invalid_time.A to-do list holds at most 5,000 to-dos. One more is a 409
todo_limit.calendarIdthat names a calendar of events is a 422calendar_wrong_kind.
Also available in
calendar.update_todo
Change a to-do
update_todo(id, patch = nil, api_key: nil, **fields) -> HashChanges a to-do, checks it off or opens it again, as the To-dos view does in the app. Send only the fields that change, and nil to clear one. status COMPLETED stamps completedAt, and on a repeating to-do it moves the to-do to its next date and keeps it open instead. calendarId moves it, with its steps, to another to-do list.
Parameters
idStringRequiredThe to-do id,
tdo_followed by 24 hex characters.titleStringWhat has to be done, 1 to 500 characters.
calendarIdStringMoves it, with its steps, to this to-do list.
notesStringNotes on the to-do, up to 8,000 characters.
statusStringFrom
Nextmail::TODO_STATUSES:NEEDS-ACTION,IN-PROCESS,COMPLETEDorCANCELLED.startTime, DateTime, Date or StringWhen work on it can start, in the same form as
due.dueTime, DateTime, Date or StringWhen it is due: a day as
YYYY-MM-DD, or a moment as aTimeor an ISO 8601 date-time. The SDK sends aTimeor DateTime as a UTC instant, and a Ruby Date as its day.timezoneStringThe IANA time zone a moment is written in for calendar apps, such as
Europe/Berlin. UTC unless you say.priorityIntegerFrom 1, the most urgent, to 9, the least. 0 means none.
percentCompleteIntegerHow far along it is, from 0 to 100.
categoriesArray<String>Up to 20 labels of up to 64 characters each.
parentIdStringMakes it a step of another to-do in the same list.
recurrenceStringAn RRULE, such as
FREQ=WEEKLY;BYDAY=MO, that makes it repeat from its start or due date.api_keyStringOverrides the client's API key for this call only.
Returns
The to-do Hash as it stands now.
Example
todo = client.calendar.update_todo("tdo_8c1e0f3a9b7d42e65a1c0d9e", status: Nextmail::TODO_STATUSES[:COMPLETED]) puts todo[:status], todo[:completedAt]Notes
A to-do in a list you are a member of with read access is a 403
calendar_read_only.parentIdthat names a to-do in another list, or one of its own steps, is a 422todo_parent_invalid.
Also available in
calendar.delete_todo
Delete a to-do
delete_todo(id, api_key: nil) -> HashDeletes a to-do and its steps. Calendar apps that sync the list drop them on their next sync.
Parameters
idStringRequiredThe to-do id,
tdo_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id, deleted set to true and removed, how many to-dos went: the one you named and its steps.
Example
gone = client.calendar.delete_todo("tdo_8c1e0f3a9b7d42e65a1c0d9e") puts "#{gone[:removed]} to-dos deleted"Notes
A to-do in a list you are a member of with read access is a 403
calendar_read_only.
Also available in
calendar.list_feeds
List calendar links
list_feeds(api_key: nil) -> Array<Hash>Returns the secret links that publish your calendar to other calendar apps, as the Share tab of the calendar settings in the app lists them. Anyone with a link can read what it shows, so treat url and webcalUrl like passwords.
Parameters
api_keyStringOverrides the client's API key for this call only.
Returns
An Array of Hashes, each with id, name, mode, url, webcalUrl and when calendar apps last read it.
Example
client.calendar.list_feeds.each do |feed| puts "#{feed[:name]} (#{feed[:mode]}): #{feed[:url]}"endNotes
A key limited to particular addresses or domains is refused with 422
capability_unsupported, because a link covers the whole calendar.
Also available in
calendar.create_feed
Create a calendar link
create_feed(body = nil, api_key: nil, **fields) -> HashMakes a secret link that publishes your calendar as an iCalendar feed, for Google Calendar (From URL), Outlook (Subscribe from web) or Apple Calendar (New subscription). full shows every detail, busy only the times you are busy. The calendar app reads the link again on its own schedule, usually every few hours.
Parameters
nameStringRequiredThe name calendar apps show for the calendar, up to 100 characters.
modeStringRequiredfullfor every detail,busyfor busy times only.calendarIdStringThe one calendar you keep that the link publishes. Left out, it publishes every calendar you keep or are a member of, with the events you are invited to.
api_keyStringOverrides the client's API key for this call only.
Returns
The link Hash with the new url and webcalUrl.
Example
feed = client.calendar.create_feed(name: "Work (busy)", mode: "busy") puts "Paste into Google Calendar: #{feed[:url]}"Notes
One person may keep 10 links. One more is refused with 409
calendar_feed_limit.
Also available in
calendar.reset_feed
Reset a calendar link
reset_feed(id, api_key: nil) -> HashReplaces the secret in a calendar link, so the old address stops working everywhere it was shared. Paste the new address into the calendar apps you still want to update.
Parameters
idStringRequiredCalendar link id,
cfd_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
The link Hash with its new url and webcalUrl.
Example
feed = client.calendar.reset_feed("cfd_3f9a1c7e5b2d48a06c1e9f4b") puts feed[:url]Notes
A link that is not yours is a 404
calendar_feed_not_found.
Also available in
calendar.delete_feed
Delete a calendar link
delete_feed(id, api_key: nil) -> HashTurns a calendar link off for good. Calendar apps that subscribed to it stop getting updates.
Parameters
idStringRequiredCalendar link id,
cfd_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id and deleted set to true.
Example
client.calendar.delete_feed("cfd_3f9a1c7e5b2d48a06c1e9f4b")Notes
A link that is not yours is a 404
calendar_feed_not_found.
Also available in
calendar.list_subscriptions
List calendar subscriptions
list_subscriptions(api_key: nil) -> Array<Hash>Returns the other calendars you subscribe to by link, such as a Google or Outlook calendar address, a team rota or public holidays, as Other calendars in the app lists them. Their events show on your calendar, read-only.
Parameters
api_keyStringOverrides the client's API key for this call only.
Returns
An Array of Hashes, each with name, url, color, status, lastError and how many events it holds.
Example
client.calendar.list_subscriptions.each do |subscription| puts "#{subscription[:name]}: #{subscription[:status]}, #{subscription[:eventCount]} events"endNotes
statusisfailingwhile reads fail and are retried, andstoppedafter ten failures in a row until you refresh it.
Also available in
calendar.create_subscription
Subscribe to a calendar
create_subscription(body = nil, api_key: nil, **fields) -> HashAdds a calendar by its iCalendar link, an https, http or webcal address, such as the secret address of a Google calendar or a published Outlook calendar. It is read at once, then again about every half hour. name defaults to the name the calendar gives itself.
Parameters
urlStringRequiredThe calendar link,
https,httporwebcal.nameStringThe name to show, up to 100 characters.
colorStringThe colour of its events, from
Nextmail::CALENDAR_COLORS.api_keyStringOverrides the client's API key for this call only.
Returns
The subscription Hash with its first events read.
Example
holidays = client.calendar.create_subscription(url: "webcal://example.com/holidays.ics", color: "green") puts "#{holidays[:name]}: #{holidays[:eventCount]} events"Notes
An address that does not answer with a calendar is refused with 422
calendar_subscription_unreadable, and one you already subscribe to with 409calendar_subscription_exists.One person may subscribe to 20 calendars.
Also available in
calendar.update_subscription
Change a calendar subscription
update_subscription(id, patch = nil, api_key: nil, **fields) -> HashRenames a subscription or gives it another colour.
Parameters
idStringRequiredSubscription id,
csb_followed by 24 hex characters.nameStringThe new name, up to 100 characters.
colorStringThe new colour, from
Nextmail::CALENDAR_COLORS.api_keyStringOverrides the client's API key for this call only.
Returns
The subscription Hash as it stands now.
Example
client.calendar.update_subscription("csb_3f9a1c7e5b2d48a06c1e9f4b", name: "Team rota", color: "purple")Notes
A subscription that is not yours is a 404
calendar_subscription_not_found.
Also available in
calendar.refresh_subscription
Refresh a calendar subscription
refresh_subscription(id, api_key: nil) -> HashReads a subscribed calendar again now instead of waiting for the next half-hourly read, and restarts one that stopped after repeated failures.
Parameters
idStringRequiredSubscription id,
csb_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
The subscription Hash after the read, with status and lastError.
Example
subscription = client.calendar.refresh_subscription("csb_3f9a1c7e5b2d48a06c1e9f4b") puts "Could not read it: #{subscription[:lastError]}" if subscription[:lastError]Notes
A calendar read less than a minute ago is refused with 429
calendar_subscription_refresh_too_soon.
Also available in
calendar.delete_subscription
Unsubscribe from a calendar
delete_subscription(id, api_key: nil) -> HashRemoves a subscription and every event it brought onto your calendar.
Parameters
idStringRequiredSubscription id,
csb_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id and deleted set to true.
Example
client.calendar.delete_subscription("csb_3f9a1c7e5b2d48a06c1e9f4b")Notes
A subscription that is not yours is a 404
calendar_subscription_not_found.
Also available in
calendar.import_ics
Import a calendar file
import_ics(data, filename: nil, calendar_id: nil, api_key: nil) -> HashSends an iCalendar (.ics) file as the request body and queues it. Its events become events of your own that you can edit, and nobody on them is sent anything, now or when you change them later, unless you ask for that on the change. Poll get_import until status is completed.
The file may be 10 MB and hold 25,000 events. Several calendars in one file are merged, and the report keeps their names. An event whose UID is already in the workspace is skipped and counted, never overwritten, so sending the same file twice adds nothing.
data is a binary String, an IO or a Pathname, and it goes out as text/calendar. Left out, filename: falls back to an upload's original_filename or the file's own name, so only plain bytes need it.
Parameters
dataString, IO or PathnameRequiredThe .ics file: a binary
String, anIOor aPathname.filenameStringThe name to show for the file in the list of imports, at most 255 characters. Left out, it is an upload's
original_filenameor the file's own name, and plain bytes are listed without a name.calendar_idStringThe calendar the events go into: one you keep, or one you are a member of with write access. Your default calendar unless you say.
api_keyStringOverrides the client's API key for this call only.
Returns
A Hash for the import, shaped like the one get_import returns, with status set to queued.
Example
queued = client.calendar.import_ics(File.binread("work.ics"), filename: "work.ics") puts queued[:id], queued[:status]Notes
A body that is not an iCalendar file is a 400
not_a_calendar_file, an empty one a 400item_import_empty, and one holding more than 25,000 events a 400too_many_events.A file over 10 MB is a 413
item_import_too_large.Text you already hold, such as what
get_event_icsreturns, goes in as it is, since a String is sent byte for byte.An upload that outlasts the client
timeoutfails as a network error, so raise it on the client for a large file on a slow connection.Not retried automatically.
Also available in
calendar.list_imports
List calendar imports
list_imports(limit: nil, cursor: nil, api_key: nil) -> Nextmail::PageReturns one page of the calendar files and calendars brought in, newest first, each with what it added and what it left out. Beside the files sent with import_ics it lists the calendars that came with a mailbox import, and those carry the id of that import in parentImportId.
Paging is keyset. limit: takes 1 to 100 and defaults to 25, and next_cursor goes back as cursor: while has_more? is true. list_all_imports and iterate_imports do that walk for you.
Parameters
limitIntegerImports per page, a whole number from 1 to 100. The server defaults to 25.
cursorStringThe
next_cursorfrom the previous page. Never build one yourself.api_keyStringOverrides the client's API key for this call only.
Returns
The Nextmail::Page with items, has_more? and next_cursor. Each import is a Hash shaped like the one get_import returns.
Example
page = client.calendar.list_imports(limit: 50) page.items.each do |item| puts "#{item[:fileName]} #{item[:status]} #{item[:counts][:imported]} #{item[:counts][:skipped]}"endNotes
sourceisfilefor an upload.takeout,caldavandmicrosoftcame with a mailbox import.A cursor that names no import is a 400
invalid_cursor.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's
max_retries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
calendar.list_all_imports
Collect every calendar import into one array
list_all_imports(limit: nil, cursor: nil, api_key: nil) -> Array<Hash>Follows next_cursor from page to page and returns every calendar import, newest first.
Everything is held in memory before the call returns. Prefer iterate_imports when you can stop early. limit: sets the page size of each request, not the total.
Parameters
limitIntegerPage size per request, from 1 to 100, defaulting to 25 on the server.
cursorStringA cursor from an earlier page to start after.
api_keyStringOverrides the client's API key for every page of this walk.
Returns
An Array of Hashes holding every import across all pages.
Example
imports = client.calendar.list_all_imports added = imports.sum { |item| item[:counts][:imported] } puts "#{added} events came from #{imports.size} imports"Notes
A failure on any page raises out of the whole call, and the imports already fetched are discarded.
Also available in
calendar.iterate_imports
Stream calendar imports one at a time
iterate_imports(limit: nil, cursor: nil, api_key: nil, &block) -> Enumerator<Hash>Returns an Enumerator that yields calendar imports individually, newest first, or yields each one to a block when given one, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.
Parameters
limitIntegerPage size per request, from 1 to 100, defaulting to 25 on the server.
cursorStringA cursor from an earlier page to start after.
api_keyStringOverrides the client's API key for every page of this walk.
Returns
An Enumerator of Hashes, one import per step, or yields each one to a block.
Example
running = client.calendar.iterate_imports.find { |item| item[:status] == "running" } puts "still running #{running[:id]} #{running[:counts][:total]}" if runningNotes
The Enumerator is lazy, so an abandoned loop costs only the pages you consumed.
Also available in
calendar.get_import
Get a calendar import
get_import(id, api_key: nil) -> HashReturns one calendar import with its counts and its report: the calendars it read, how many events it left out and why, and up to 20 of the events it left out. Poll it after import_ics until status is completed or failed.
counts[:imported] is what was added and counts[:skipped] what was left out, which report[:skipped] breaks down by reason: uid-taken for an event that was already here, no-start for one with no start time, invalid for one that could not be read and empty for a file or calendar that held no events.
Parameters
idStringRequiredCalendar import id,
iimp_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
A Hash with object, id, kind, source, one of Nextmail::ITEM_IMPORT_SOURCES, status, one of Nextmail::ITEM_IMPORT_STATUSES, fileName, fileBytes, parentImportId, counts, report, lastError, undoable and when it was created, started, finished and undone in createdAt, startedAt, finishedAt and undoneAt. counts holds total, imported, merged, skipped and failed. report holds collections, an Array of Hashes with name and items, skipped, a Hash of counts keyed by reason, and samples, an Array of Hashes with name and reason.
Example
item = client.calendar.get_import("iimp_3f9c2a7b1e4d8f60a5c7b92d") puts item[:status], item[:counts][:imported], item[:counts][:skipped], item[:report][:skipped][:"uid-taken"] || 0 item[:report][:samples].each { |sample| puts "#{sample[:name]} #{sample[:reason]}" }Notes
An id that names no calendar import is a 404
item_import_not_found.The reasons in
report[:skipped]are Symbol keys like every other key, so one with a hyphen is read asreport[:skipped][:"uid-taken"].A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's
max_retries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
calendar.undo_import
Remove what a calendar import added
undo_import(id, api_key: nil) -> HashDeletes every event the import added, changed since or not, and marks the import undone. Nobody is told. Events that were skipped because they were already here are not touched.
Parameters
idStringRequiredCalendar import id,
iimp_followed by 24 hex characters.api_keyStringOverrides the client's API key for this call only.
Returns
The import Hash, shaped like the one get_import returns, with status set to undone and undoneAt set.
Example
undone = client.calendar.undo_import("iimp_3f9c2a7b1e4d8f60a5c7b92d") puts undone[:status], undone[:undoneAt], undone[:counts][:imported]Notes
An import that is still running, or was already removed, is a 409
item_import_not_undoable.undoableon the import says whether the call would remove anything.An id that names no calendar import is a 404
item_import_not_found.Not retried automatically.