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.ListEventsCalendar.ListAllEventsCalendar.IterateEventsCalendar.GetEventCalendar.GetEventIcsCalendar.CreateEventCalendar.UpdateEventCalendar.DeleteEventCalendar.CancelEventCalendar.RespondToEventCalendar.DeclineProposalCalendar.HideEventCalendar.UnhideEventCalendar.FreeBusyCalendar.ListCalendarsCalendar.GetCalendarCalendar.CreateCalendarCalendar.UpdateCalendarCalendar.DeleteCalendarCalendar.SetCalendarMemberCalendar.RemoveCalendarMemberCalendar.ListCalendarLoginsCalendar.CreateCalendarLoginCalendar.RevokeCalendarLoginCalendar.CreateCalendarLoginProfileLinkCalendar.ListTodosCalendar.ListAllTodosCalendar.IterateTodosCalendar.GetTodoCalendar.CreateTodoCalendar.UpdateTodoCalendar.DeleteTodoCalendar.ListFeedsCalendar.CreateFeedCalendar.ResetFeedCalendar.DeleteFeedCalendar.ListSubscriptionsCalendar.CreateSubscriptionCalendar.UpdateSubscriptionCalendar.RefreshSubscriptionCalendar.DeleteSubscriptionCalendar.ImportIcsCalendar.ListImportsCalendar.ListAllImportsCalendar.IterateImportsCalendar.GetImportCalendar.UndoImport
Calendar.ListEvents
List one page of event occurrences inside a time window
ListEvents(ctx context.Context, from time.Time, to time.Time, opts ...nextmail.RequestOption) (*nextmail.Page, error)Expands 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 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 time.Time or an ISO 8601 string.
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.TimeRequiredStart of the window.
totime.TimeRequiredEnd of the window, after
fromand at most 366 days later.nextmail.WithTimezonestringIANA zone such as
Europe/London, at most 64 characters. Defaults toUTC.nextmail.WithIncludeTeambooltrueadds 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.nextmail.WithQstringWords 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.
nextmail.WithCalendarIDs...stringOnly the events in these calendars, by the ids
ListCalendarsgives, sent comma-separated. Events from calendar subscriptions are left out when you name calendars.nextmail.WithLimitintOccurrences per page, a whole number from 1 to 100. The server defaults to 25.
nextmail.WithCursorstringThe
NextCursorof the previous page, sent with the same window. It is opaque, so never build one yourself.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The *nextmail.Page with Items, HasMore and NextCursor. Each item has eventId, uid, start, end, allDay, summary, location, status, transparency, isOrganizer, organizerEmail, recurring, myPartstat and attendeeCount.
Example
page, err := client.Calendar.ListEvents( ctx, time.Now().Add(24*time.Hour), time.Now().Add(24*time.Hour), nextmail.WithTimezone("Europe/London"), nextmail.WithLimit(50),)if err != nil { return err} for _, occurrence := range page.Items { fmt.Println(occurrence.String("start"), occurrence.String("summary"), occurrence.String("myPartstat"))} fmt.Println(page.HasMore, page.NextCursor)Notes
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
nextmail.WithIncludeTeam(true)adds 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 null 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.ListAllEvents
Collect every occurrence inside a time window into one slice
ListAllEvents(ctx context.Context, from time.Time, to time.Time, opts ...nextmail.RequestOption) ([]nextmail.Object, error)Walks every page of ListEvents for one window and returns 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.
Parameters
fromtime.TimeRequiredStart of the window.
totime.TimeRequiredEnd of the window, after
fromand at most 366 days later.nextmail.WithTimezonestringIANA zone such as
Europe/London, at most 64 characters. Defaults toUTC.nextmail.WithIncludeTeambooltrueadds 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.nextmail.WithQstringWords 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.
nextmail.WithCalendarIDs...stringOnly the events in these calendars, by the ids
ListCalendarsgives, sent comma-separated. Events from calendar subscriptions are left out when you name calendars.nextmail.WithLimitintPage size for each request, 1 to 100. The server defaults to 25.
nextmail.WithCursorstringStarts the walk from this cursor instead of the start of the window.
nextmail.WithAPIKeystringOverrides the client API key for every page of this walk.
Returns
A []nextmail.Object holding every occurrence in the window, earliest first.
Example
occurrences, err := client.Calendar.ListAllEvents( ctx, time.Date(2026, time.October, 1, 0, 0, 0, 0, time.UTC), time.Date(2026, time.November, 1, 0, 0, 0, 0, time.UTC), nextmail.WithLimit(100),)if err != nil { return err} for _, occurrence := range occurrences { fmt.Println(occurrence.String("transparency"))}Notes
If any page fails the call fails and the occurrences already fetched are discarded.
Also available in
Calendar.IterateEvents
Stream the occurrences inside a time window one at a time
IterateEvents(ctx context.Context, from time.Time, to time.Time, opts ...nextmail.RequestOption) *nextmail.IteratorReturns an iterator 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 the server stops offering a cursor, or when it repeats one.
Parameters
fromtime.TimeRequiredStart of the window.
totime.TimeRequiredEnd of the window, after
fromand at most 366 days later.nextmail.WithTimezonestringIANA zone such as
Europe/London, at most 64 characters. Defaults toUTC.nextmail.WithIncludeTeambooltrueadds 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.nextmail.WithQstringWords 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.
nextmail.WithCalendarIDs...stringOnly the events in these calendars, by the ids
ListCalendarsgives, sent comma-separated. Events from calendar subscriptions are left out when you name calendars.nextmail.WithLimitintPage size per request, 1 to 100. The server defaults to 25.
nextmail.WithCursorstringStarts the walk from this cursor instead of the start of the window.
nextmail.WithAPIKeystringOverrides the client API key for every page of this walk.
Returns
The *nextmail.Iterator yielding one occurrence per step.
Example
for occurrence, err := range client.Calendar.IterateEvents(ctx, time.Now().Add(24*time.Hour), time.Now().Add(24*time.Hour)).All() { if err != nil { return err } fmt.Println(occurrence.String("myPartstat"), occurrence.String("start"), occurrence.String("summary"))}Notes
A cancelled context fails the pending page request, and the loop ends with that error.
Also available in
Calendar.GetEvent
Read an event with its attendees
GetEvent(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)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 a map with minutesBefore and 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.
Parameters
idstringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object 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, err := client.Calendar.GetEvent(ctx, "cal_8d3f0a2b9c4e41f7a6b5c2d1")if err != nil { return err} fmt.Println(event.String("summary"), event.String("recurrence"))Notes
status,transparencyandvisibilitycarry iCalendar values, and default toCONFIRMED,OPAQUEandPUBLIC.An attendee's
partstatdefaults toNEEDS-ACTIONandroletoREQ-PARTICIPANTuntil a response is recorded.
Also available in
Calendar.GetEventIcs
Download an event as an iCalendar document
GetEventIcs(ctx context.Context, id string, opts ...nextmail.RequestOption) (string, error)Returns 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.
Parameters
idstringRequiredEvent id, the
eventIdof an occurrence.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
A string, the iCalendar text from BEGIN:VCALENDAR to END:VCALENDAR.
Example
text, err := client.Calendar.GetEventIcs(ctx, "cal_8d3f0a2b9c4e41f7a6b5c2d1")if err != nil { return err} fmt.Println(text)Notes
Errors still come back as JSON and return
*nextmail.Error, so a failure is never returned as text.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
GetEvent.
Also available in
Calendar.CreateEvent
Put an event on the calendar
CreateEvent(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Creates an event, as New event on the Calendar page of the app does. start and end take a time.Time 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.
Parameters
summarystringRequiredThe title, 1 to 255 characters.
starttime.Time | stringRequiredWhen it starts, a
time.Timeor ISO 8601 with a zone.endtime.Time | 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.
allDayboolWhether 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.attendees[]nextmail.BodyUp to 200 people to invite, each a map with
emailand optionallynameandoptional.reminders[]nextmail.BodyUp to five reminders, each a map with
minutesBeforeand optionallyaction.transparencystringOPAQUEshows you busy andTRANSPARENTfree.visibilitystringPUBLIC,PRIVATEorCONFIDENTIAL.sendInvitesboolFalse 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.
nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object for the new event, with its attendees and their responses.
Example
event, err := client.Calendar.CreateEvent(ctx, nextmail.Body{ "summary": "Planning", "start": "2026-10-12T09:00:00Z", "end": "2026-10-12T09:30:00Z", "attendees": []nextmail.Body{ {"email": "[email protected]"}, }, "from": "[email protected]",})if err != nil { return err} fmt.Println(event.String("id"))Notes
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.UpdateEvent
Change an event
UpdateEvent(ctx context.Context, id string, patch nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)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.
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.Time | stringWhen it starts, a
time.Timeor ISO 8601 with a zone.endtime.Time | 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.
allDayboolWhether 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.attendees[]nextmail.BodyUp to 200 people to invite, each a map with
emailand optionallynameandoptional. It replaces the whole list.reminders[]nextmail.BodyUp to five reminders, each a map with
minutesBeforeand optionallyaction.transparencystringOPAQUEshows you busy andTRANSPARENTfree.visibilitystringPUBLIC,PRIVATEorCONFIDENTIAL.sendInvitesboolFalse 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.Time | stringThe start of the date you mean, as
ListEventsgives it. Needed withoccurrenceandfollowing.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object as it stands after the change, with sequence one higher.
Example
event, err := client.Calendar.UpdateEvent( ctx, "cal_3f9a1c7e5b2d48a06c1e9f4b", nextmail.Body{"start": "2026-10-12T10:00:00Z", "end": "2026-10-12T10:30:00Z"},)if err != nil { return err} fmt.Println(event.String("start"), event.Int("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 withRespondToEventinstead. An event the key does not reach is a 404.
Also available in
Calendar.DeleteEvent
Remove an event from the calendar
DeleteEvent(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)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. For a repeating event, nextmail.WithScope("occurrence") with nextmail.WithOccurrenceStart 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.nextmail.WithScopestringoccurrence,followingorseries: which dates of a repeating event go.nextmail.WithOccurrenceStarttime.TimeThe start of the date you mean, as
ListEventsgives it. Needed withoccurrenceandfollowing.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with object, id and deleted set to true.
Example
event, err := client.Calendar.DeleteEvent(ctx, "cal_3f9a1c7e5b2d48a06c1e9f4b", nextmail.WithScope("occurrence"), nextmail.WithOccurrenceStart(time.Date(2026, time.October, 19, 9, 0, 0, 0, time.UTC)),)if err != nil { return err} fmt.Println(event.String("id"), event.String("object"))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 withHideEvent.
Also available in
Calendar.CancelEvent
Call off a meeting
CancelEvent(ctx context.Context, id string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)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.
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.Time | stringThe start of the date you mean, as
ListEventsgives it. Needed withoccurrenceandfollowing.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with status CANCELLED.
Example
event, err := client.Calendar.CancelEvent(ctx, "cal_3f9a1c7e5b2d48a06c1e9f4b", nextmail.Body{"from": "[email protected]"})if err != nil { return err} fmt.Println(event.String("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.RespondToEvent
Answer an invitation
RespondToEvent(ctx context.Context, id string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)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.
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.Time | stringA new start to propose with your answer, sent together with
proposedEnd.proposedEndtime.Time | stringThe end of the proposed time.
nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with your answer on your attendee row.
Example
event, err := client.Calendar.RespondToEvent(ctx, "cal_3f9a1c7e5b2d48a06c1e9f4b", nextmail.Body{"response": "ACCEPTED"})if err != nil { return err} fmt.Println(event.String("id"), event.String("status"))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.DeclineProposal
Decline a proposed time
DeclineProposal(ctx context.Context, id string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Keeps the original time of a meeting you organise after a guest proposed another one, as Decline in the proposal on the event does 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 UpdateEvent.
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.
nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with the guest's proposedStart and proposedEnd cleared.
Example
event, err := client.Calendar.GetEvent(ctx, "cal_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} for _, attendee := range event.Objects("attendees") { if !attendee.Has("proposedStart") { continue } if _, err := client.Calendar.DeclineProposal(ctx, event.ID(), nextmail.Body{"attendee": attendee.String("email")}); err != nil { return err } break}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.HideEvent
Hide an event from your calendar
HideEvent(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Takes 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. UnhideEvent brings it back.
Parameters
idstringRequiredEvent id, the
eventIdof an occurrence, such ascal_followed by 24 hex characters.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with object, id, uid and hidden set to true.
Example
hidden, err := client.Calendar.HideEvent(ctx, "cal_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(hidden.String("id"), hidden.Bool("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.
ListEventsleaves it out from then on, andGetEventstill finds it, withhiddentrue.
Also available in
Calendar.UnhideEvent
Show a hidden event again
UnhideEvent(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Puts 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.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with object, id, uid and hidden set to false.
Example
shown, err := client.Calendar.UnhideEvent(ctx, "cal_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(shown.String("id"), shown.Bool("hidden"))Notes
An event that was not hidden stays as it was, so it is safe to repeat.
Also available in
Calendar.FreeBusy
Free and busy times
FreeBusy(ctx context.Context, emails []string, from time.Time, to time.Time, opts ...nextmail.RequestOption) (nextmail.Object, error)When 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 nextmail.WithDurationMinutes, suggestions lists up to five times when everyone known is free, on weekdays between 09:00 and 17:00 in the zone of nextmail.WithTimezone. from and to may be at most 31 days apart.
Parameters
emails[]stringRequiredThe addresses to look up, at most 20.
fromtime.TimeRequiredThe start of the window.
totime.TimeRequiredThe end of the window, at most 31 days after
from.nextmail.WithTimezonestringThe IANA zone the suggested times keep to working hours in,
UTCunless you say.nextmail.WithDurationMinutesintThe length of the meeting, 5 to 480 minutes. Send it to get
suggestions.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with people, each with email, known and busy, its busy times as objects with start and end, and suggestions in the same shape.
Example
from := time.Now() times, err := client.Calendar.FreeBusy(ctx, []string{"[email protected]", "[email protected]"}, from, from.Add(7*24*time.Hour), nextmail.WithTimezone("Europe/London"), nextmail.WithDurationMinutes(30),)if err != nil { return err} for _, suggestion := range times.Objects("suggestions") { fmt.Println("Free:", suggestion.String("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.ListCalendars
List your calendars
ListCalendars(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)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: nextmail.WithKind(constants.CalendarKindsTodos) lists them instead.
Parameters
nextmail.WithKindstringeventsfor your calendars of events, ortodosfor your to-do lists, one ofconstants.CalendarKindsValues.eventsunless you say.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
A []nextmail.Object, the ones you keep first, each with id, kind, name, color, description, isDefault, position, access, owner and members, where kind is one of constants.CalendarKindsValues. access, one of constants.CollectionRightsValues, is owner on a calendar you keep, which lists its members, and the access its keeper gave you on one you are a member of, whose members is null.
Example
calendars, err := client.Calendar.ListCalendars(ctx)if err != nil { return err} for _, calendar := range calendars { fmt.Println(calendar.String("name"), calendar.String("access"), calendar.Bool("isDefault"))}Notes
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.GetCalendar
Get one calendar
GetCalendar(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)One 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, asListCalendarsgives it.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object for the calendar.
Example
calendar, err := client.Calendar.GetCalendar(ctx, "cln_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(calendar.String("name"), len(calendar.Objects("members")))Notes
A calendar you neither keep nor are a member of is a 404
calendar_not_found.
Also available in
Calendar.CreateCalendar
Create a calendar
CreateCalendar(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Makes a new calendar of yours, such as Work or Family, as New calendar does in the app. Put events in it with calendarId on CreateEvent, or move them there with UpdateEvent. With kind set to constants.CalendarKindsTodos it is a to-do list instead, for CreateTodo.
Parameters
namestringRequiredThe name the apps show, 1 to 100 characters.
kindstringeventsfor a calendar of events, ortodosfor a to-do list, one ofconstants.CalendarKindsValues.eventsunless you say.colorstringThe colour its events are drawn in, from
CALENDAR_COLORS. Blue unless you say.descriptionstring | nilWhat the calendar is for, up to 1,000 characters.
nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object for the new calendar, which is never your default one.
Example
calendar, err := client.Calendar.CreateCalendar(ctx, nextmail.Body{"name": "Family", "color": "green"})if err != nil { return err} event, err := client.Calendar.CreateEvent(ctx, nextmail.Body{ "summary": "School play", "start": "2026-12-04T17:00:00Z", "end": "2026-12-04T19:00:00Z", "calendarId": calendar.ID(),})if err != nil { return err} fmt.Println(calendar.ID(), event.ID())Notes
One person may keep 50 calendars and 50 to-do lists. One more is refused with 409
calendar_limit.The SDK does not retry it, because a second call makes a second calendar.
Also available in
Calendar.UpdateCalendar
Change a calendar
UpdateCalendar(ctx context.Context, id string, patch nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Renames 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, asListCalendarsgives it.namestringThe new name, 1 to 100 characters.
colorstringThe new colour, from
CALENDAR_COLORS.descriptionstring | nilWhat the calendar is for. Null clears it.
positionintIts place in your list, from 0 at the top. The calendars you keep and the ones you are a member of are ordered apart.
isDefaultbooltruemakes it your default calendar, where new events and invitations go.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object as it stands now.
Example
calendar, err := client.Calendar.UpdateCalendar( ctx, "cln_3f9a1c7e5b2d48a06c1e9f4b", nextmail.Body{"name": "Work", "color": "purple", "isDefault": true},)if err != nil { return err} fmt.Println(calendar.String("name"), calendar.Bool("isDefault"))Notes
Renaming or describing a calendar you are a member of is a 403
calendar_not_owned.isDefaultset tofalseon your default calendar is a 409calendar_is_default: make another calendar the default instead.
Also available in
Calendar.DeleteCalendar
Delete a calendar
DeleteCalendar(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Deletes 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 CancelEvent does, unless you pass nextmail.WithNotifyGuests(false). A meeting that came in through a calendar import is cancelled quietly unless you pass nextmail.WithNotifyGuests(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, asListCalendarsgives it.nextmail.WithNotifyGuestsboolfalsedeletes it without telling anyone. Left out ortrue, the guests of its upcoming meetings are sent a cancellation, andtruetells the guests of imported meetings too.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with deleted: true and cancelledMeetings, how many meetings had their guests told.
Example
gone, err := client.Calendar.DeleteCalendar(ctx, "cln_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(gone.Int("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 passesnextmail.WithNotifyGuests(false).
Also available in
Calendar.SetCalendarMember
Give a member access to a calendar
SetCalendarMember(ctx context.Context, id string, memberID string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Gives 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, asListCalendarsgives it.memberIDstringRequiredThe member id of the person, as
Members.Listgives it.accessstringRequiredreadorwrite, one ofconstants.CollectionAccessLevelsValues.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with the access the member now has.
Example
member, err := client.Calendar.SetCalendarMember( ctx, "cln_3f9a1c7e5b2d48a06c1e9f4b", "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E", nextmail.Body{"access": constants.CollectionAccessLevelsWrite},)if err != nil { return err} fmt.Println(member.String("email"), member.String("access"))Notes
Setting it again only changes the access, so 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.RemoveCalendarMember
Take away a member's access to a calendar
RemoveCalendarMember(ctx context.Context, id string, memberID string, opts ...nextmail.RequestOption) (nextmail.Object, error)Takes 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, asListCalendarsgives it.memberIDstringRequiredThe member id of the person, as
Members.Listgives it.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with deleted: true.
Example
removed, err := client.Calendar.RemoveCalendarMember(ctx, "cln_3f9a1c7e5b2d48a06c1e9f4b", "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E")if err != nil { return err} fmt.Println(removed.String("memberId"), removed.Bool("deleted"))Notes
Removing someone who is not a member is a 422
member_not_found.
Also available in
Calendar.ListCalendarLogins
List calendar sign-ins
ListCalendarLogins(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)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
nextmail.WithMemberstringThe 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. Another member's takesmembers:writeinstead ofaccount:read.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
A []nextmail.Object, newest first, each with id, name, username, last4, member, createdBy, createdAt, lastUsedAt, lastUsedProtocol and lastUsedClient. member, the person it signs in as, and createdBy are maps with id, name and email, and createdBy is null when who made it is not known. lastUsedProtocol is caldav or carddav, from constants.MailAppProtocolsValues, and null like lastUsedAt until an app signs in with it. Revoked sign-ins are left out.
Example
logins, err := client.Calendar.ListCalendarLogins(ctx)if err != nil { return err} for _, login := range logins { lastUsed := "never used" if login.Has("lastUsedAt") { lastUsed = login.String("lastUsedAt") } fmt.Println(login.String("name"), login.String("username"), lastUsed)}Notes
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.CreateCalendarLogin
Create a calendar sign-in
CreateCalendarLogin(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Makes 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.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object: the calendar sign-in as ListCalendarLogins returns it, plus password, shown this once, servers, a map with the username to enter and the caldav and carddav servers, each with url, principalUrl, host, port and security, or null 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, err := client.Calendar.CreateCalendarLogin(ctx, nextmail.Body{"name": "Kitchen iPad"})if err != nil { return err} fmt.Println("Server", created.Object("servers").Object("caldav").String("url"))fmt.Println("Sign in as", created.String("username"), "with", created.String("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 withRevokeCalendarLoginfirst. 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. The error matchesnextmail.ErrStepUpRequired. 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.RevokeCalendarLogin
Revoke a calendar sign-in
RevokeCalendarLogin(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Revokes 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, asListCalendarLoginsgives it.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with object set to calendar_login, id and deleted set to true.
Example
revoked, err := client.Calendar.RevokeCalendarLogin(ctx, "cdl_6b1e0f9a3c7d48e25a0b9c14")if err != nil { return err} fmt.Println(revoked.ID(), revoked.Bool("deleted"))Notes
A sign-in you may not manage, or one already revoked, is a 404
calendar_login_not_found.Not retried by the SDK. Repeating a revoke that succeeded is a 404.
Also available in
Calendar.CreateCalendarLoginProfileLink
Make a link that sets up calendars and contacts on an Apple device
CreateCalendarLoginProfileLink(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Makes 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 CreateCalendarLogin 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.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with object set to calendar_login_profile_link, the url to open on the device, expiresAt, when it stops working, and member, the person the sign-in it makes will belong to, a map with id, name and email.
Example
link, err := client.Calendar.CreateCalendarLoginProfileLink(ctx, nextmail.Body{ "name": "iPhone", "displayName": "Work calendar", "description": "Your calendars and contacts",})if err != nil { return err} fmt.Println("Open", link.String("url"), "on the iPhone before", link.String("expiresAt"))Notes
A person can make 10 of these links, and of the links that set up an address on an Apple device, in an hour. One more is a 429
profile_link_rate_limited.An OAuth access token needs a verification code for this call, as
CreateCalendarLogindoes, and the error matchesnextmail.ErrStepUpRequireduntil it has one. An API key is never asked for a code.Not retried automatically by the SDK, since every attempt makes a link that can make a sign-in. The success status is 201.
Also available in
- API
POST /calendar/logins/profile-link- TypeScript
calendar.createCalendarLoginProfileLink()- Python
calendar.create_calendar_login_profile_link()- Ruby
calendar.create_calendar_login_profile_link- PHP
calendar->createCalendarLoginProfileLink- Java
calendar().createCalendarLoginProfileLink- C#
Calendar.CreateCalendarLoginProfileLinkAsync
Calendar.ListTodos
List to-dos
ListTodos(ctx context.Context, opts ...nextmail.RequestOption) (*nextmail.Page, error)Returns 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. nextmail.WithLimit takes 1 to 500 and defaults to 100, and NextCursor goes back as nextmail.WithCursor while HasMore is true. ListAllTodos and IterateTodos do that walk for you.
Parameters
nextmail.WithCalendarIDs...stringOnly the to-dos in these to-do lists, by the ids
ListCalendarsgives withnextmail.WithKind(constants.CalendarKindsTodos), sent comma-separated. Every to-do list you keep or are a member of unless you say.nextmail.WithStatestringopenfor to-dos still to do,donefor completed and cancelled ones, orall, one ofconstants.TodoStatesValues.openunless you say.nextmail.WithDueBeforetime.TimeOnly to-dos due before this moment.
nextmail.WithDueAftertime.TimeOnly to-dos due at or after this moment.
nextmail.WithLimitintTo-dos per page, a whole number from 1 to 500. The server defaults to 100.
nextmail.WithCursorstringThe
NextCursorfrom the previous page. Never build one yourself.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The *nextmail.Page with Items, HasMore and NextCursor. Each item has id, calendarId, uid, title, notes, status, start, due, allDay, timezone, completedAt, priority, percentComplete, categories, parentId, recurrence, createdAt and updatedAt, where status is one of constants.TodoStatusesValues.
Example
page, err := client.Calendar.ListTodos(ctx, nextmail.WithDueBefore(time.Now().Add(7*24*time.Hour)))if err != nil { return err} for _, todo := range page.Items { due := todo.String("due") if due == "" { due = "someday" } fmt.Println(due, todo.String("title"))} fmt.Println(page.HasMore, page.NextCursor)Notes
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.ListAllTodos
Collect every to-do into one slice
ListAllTodos(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)Follows NextCursor from page to page and returns with every to-do that matches, in the order ListTodos gives them.
Everything is held in memory before the call returns. Prefer IterateTodos when you can stop early. nextmail.WithLimit sets the page size of each request, not the total.
Parameters
nextmail.WithCalendarIDs...stringOnly the to-dos in these to-do lists, by the ids
ListCalendarsgives withnextmail.WithKind(constants.CalendarKindsTodos), sent comma-separated. Every to-do list you keep or are a member of unless you say.nextmail.WithStatestringopenfor to-dos still to do,donefor completed and cancelled ones, orall, one ofconstants.TodoStatesValues.openunless you say.nextmail.WithDueBeforetime.TimeOnly to-dos due before this moment.
nextmail.WithDueAftertime.TimeOnly to-dos due at or after this moment.
nextmail.WithLimitintPage size per request, from 1 to 500, defaulting to 100 on the server.
nextmail.WithCursorstringA cursor from an earlier page to start after.
nextmail.WithAPIKeystringOverrides the client API key for every page of this walk.
Returns
A []nextmail.Object holding every matching to-do across all pages.
Example
done, err := client.Calendar.ListAllTodos(ctx, nextmail.WithState(constants.TodoStatesDone))if err != nil { return err} fmt.Println(len(done), "to-dos done")Notes
A failure on any page fails the whole call, and the to-dos already fetched are discarded.
Also available in
Calendar.IterateTodos
Stream to-dos one at a time
IterateTodos(ctx context.Context, opts ...nextmail.RequestOption) *nextmail.IteratorReturns an iterator that yields to-dos one by one, in the order ListTodos gives them, 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
nextmail.WithCalendarIDs...stringOnly the to-dos in these to-do lists, by the ids
ListCalendarsgives withnextmail.WithKind(constants.CalendarKindsTodos), sent comma-separated. Every to-do list you keep or are a member of unless you say.nextmail.WithStatestringopenfor to-dos still to do,donefor completed and cancelled ones, orall, one ofconstants.TodoStatesValues.openunless you say.nextmail.WithDueBeforetime.TimeOnly to-dos due before this moment.
nextmail.WithDueAftertime.TimeOnly to-dos due at or after this moment.
nextmail.WithLimitintPage size per request, from 1 to 500, defaulting to 100 on the server.
nextmail.WithCursorstringA cursor from an earlier page to start after.
nextmail.WithAPIKeystringOverrides the client API key for every page of this walk.
Returns
The *nextmail.Iterator yielding one to-do per step.
Example
for todo, err := range client.Calendar.IterateTodos(ctx).All() { if err != nil { return err } if priority := todo.Int("priority"); priority == 0 || priority > 4 { continue } fmt.Println("urgent", todo.String("title"))}Notes
The iterator is lazy, so an abandoned loop costs only the pages you consumed.
Also available in
Calendar.GetTodo
Get a to-do
GetTodo(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)One 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, asListTodosgives it.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with id, calendarId, uid, title, notes, status, start, due, allDay, timezone, completedAt, priority, percentComplete, categories, parentId, recurrence, createdAt and updatedAt, where status is one of constants.TodoStatusesValues.
Example
todo, err := client.Calendar.GetTodo(ctx, "tdo_8c1e0f3a9b7d42e65a1c0d9e")if err != nil { return err} fmt.Println(todo.String("title"), todo.String("status"), todo.String("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.CreateTodo
Create a to-do
CreateTodo(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Adds 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.
notesstring | nilNotes on the to-do, up to 8,000 characters.
statusstringNEEDS-ACTION,IN-PROCESS,COMPLETEDorCANCELLED, one ofconstants.TodoStatusesValues.starttime.Time | string | nilWhen work on it can start, in the same form as
due.duetime.Time | string | nilWhen it is due: a day as
YYYY-MM-DD, or a moment as atime.Timeor an ISO 8601 date-time.timezonestring | nilThe IANA time zone a moment is written in for calendar apps, such as
Europe/Berlin. UTC unless you say.priorityintFrom 1, the most urgent, to 9, the least. 0 means none.
percentCompleteint | nilHow far along it is, from 0 to 100.
categories[]stringUp to 20 labels of up to 64 characters each.
parentIdstring | nilMakes it a step of another to-do in the same list.
recurrencestring | nilAn RRULE, such as
FREQ=WEEKLY;BYDAY=MO, that makes it repeat from its start or due date.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object for the new to-do.
Example
lists, err := client.Calendar.ListCalendars(ctx, nextmail.WithKind(constants.CalendarKindsTodos))if err != nil { return err} body := nextmail.Body{"title": "Renew the passport", "due": "2026-11-20", "priority": 1} for _, list := range lists { if list.Bool("isDefault") { body["calendarId"] = list.ID() }} todo, err := client.Calendar.CreateTodo(ctx, body)if err != nil { return err} fmt.Println(todo.ID(), todo.String("status"))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.The SDK does not retry it, because a second call makes a second to-do.
Also available in
Calendar.UpdateTodo
Change a to-do
UpdateTodo(ctx context.Context, id string, patch nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Changes 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.
notesstring | nilNotes on the to-do, up to 8,000 characters.
statusstringNEEDS-ACTION,IN-PROCESS,COMPLETEDorCANCELLED, one ofconstants.TodoStatusesValues.starttime.Time | string | nilWhen work on it can start, in the same form as
due.duetime.Time | string | nilWhen it is due: a day as
YYYY-MM-DD, or a moment as atime.Timeor an ISO 8601 date-time.timezonestring | nilThe IANA time zone a moment is written in for calendar apps, such as
Europe/Berlin. UTC unless you say.priorityintFrom 1, the most urgent, to 9, the least. 0 means none.
percentCompleteint | nilHow far along it is, from 0 to 100.
categories[]stringUp to 20 labels of up to 64 characters each.
parentIdstring | nilMakes it a step of another to-do in the same list.
recurrencestring | nilAn RRULE, such as
FREQ=WEEKLY;BYDAY=MO, that makes it repeat from its start or due date.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object as it stands now.
Example
todo, err := client.Calendar.UpdateTodo(ctx, "tdo_8c1e0f3a9b7d42e65a1c0d9e", nextmail.Body{"status": constants.TodoStatusesCompleted})if err != nil { return err} fmt.Println(todo.String("status"), todo.String("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.DeleteTodo
Delete a to-do
DeleteTodo(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Deletes 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.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with id, deleted: true and removed, which counts the steps that went with it.
Example
gone, err := client.Calendar.DeleteTodo(ctx, "tdo_8c1e0f3a9b7d42e65a1c0d9e")if err != nil { return err} fmt.Println(gone.Int("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.ListFeeds
List calendar links
ListFeeds(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)Returns the secret links that publish your calendar to other calendar apps, as Share in the calendar settings of the app lists them. Anyone with a link can read what it shows, so treat url and webcalUrl like passwords.
Parameters
nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
A []nextmail.Object, each with id, name, mode, url, webcalUrl and when calendar apps last read it.
Example
feeds, err := client.Calendar.ListFeeds(ctx)if err != nil { return err} for _, feed := range feeds { fmt.Println(feed.String("name"), feed.String("mode"), feed.String("url"))}Notes
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.CreateFeed
Create a calendar link
CreateFeed(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Makes 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.
nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with the new url and webcalUrl.
Example
feed, err := client.Calendar.CreateFeed(ctx, nextmail.Body{"name": "Work (busy)", "mode": "busy"})if err != nil { return err} fmt.Println(feed.String("url"))Notes
One person may keep 10 links. One more is refused with 409
calendar_feed_limit.
Also available in
Calendar.ResetFeed
Reset a calendar link
ResetFeed(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Replaces 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.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with its new url and webcalUrl.
Example
feed, err := client.Calendar.ResetFeed(ctx, "cfd_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(feed.String("url"))Notes
A link that is not yours is a 404
calendar_feed_not_found.
Also available in
Calendar.DeleteFeed
Delete a calendar link
DeleteFeed(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Turns 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.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with deleted: true.
Example
feed, err := client.Calendar.DeleteFeed(ctx, "cfd_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(feed.String("id"), feed.String("object"))Notes
A link that is not yours is a 404
calendar_feed_not_found.
Also available in
Calendar.ListSubscriptions
List calendar subscriptions
ListSubscriptions(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)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
nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
A []nextmail.Object, each with name, url, color, status, lastError and how many events it holds.
Example
subscriptions, err := client.Calendar.ListSubscriptions(ctx)if err != nil { return err} for _, subscription := range subscriptions { fmt.Println(subscription.String("name"), subscription.String("status"), subscription.Int("eventCount"))}Notes
statusisfailingwhile reads fail and are retried, andstoppedafter ten failures in a row until you refresh it.
Also available in
Calendar.CreateSubscription
Subscribe to a calendar
CreateSubscription(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Adds 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
CALENDAR_COLORS.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with its first events read.
Example
holidays, err := client.Calendar.CreateSubscription(ctx, nextmail.Body{"url": "webcal://example.com/holidays.ics", "color": "green"})if err != nil { return err} fmt.Println(holidays.String("name"), holidays.Int("eventCount"))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.UpdateSubscription
Change a calendar subscription
UpdateSubscription(ctx context.Context, id string, patch nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)Renames 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
CALENDAR_COLORS.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object as it stands now.
Example
subscription, err := client.Calendar.UpdateSubscription(ctx, "csb_3f9a1c7e5b2d48a06c1e9f4b", nextmail.Body{"name": "Team rota", "color": "purple"})if err != nil { return err} fmt.Println(subscription.String("id"), subscription.String("status"))Notes
A subscription that is not yours is a 404
calendar_subscription_not_found.
Also available in
Calendar.RefreshSubscription
Refresh a calendar subscription
RefreshSubscription(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Reads 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.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object after the read, with status and lastError.
Example
subscription, err := client.Calendar.RefreshSubscription(ctx, "csb_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(subscription.String("lastError"))Notes
A calendar read less than a minute ago is refused with 429
calendar_subscription_refresh_too_soon.
Also available in
Calendar.DeleteSubscription
Unsubscribe from a calendar
DeleteSubscription(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Removes a subscription and every event it brought onto your calendar.
Parameters
idstringRequiredSubscription id,
csb_followed by 24 hex characters.nextmail.WithAPIKeystringOverrides the client's API key for this call only.
Returns
The nextmail.Object with deleted: true.
Example
subscription, err := client.Calendar.DeleteSubscription(ctx, "csb_3f9a1c7e5b2d48a06c1e9f4b")if err != nil { return err} fmt.Println(subscription.String("id"), subscription.String("object"))Notes
A subscription that is not yours is a 404
calendar_subscription_not_found.
Also available in
Calendar.ImportIcs
Import a calendar file
ImportIcs(ctx context.Context, data io.Reader, opts ...nextmail.RequestOption) (nextmail.Object, error)Sends 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 GetImport 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 an io.Reader, and it goes out as text/calendar.
Parameters
dataio.ReaderRequiredThe .ics file: an
io.Reader.nextmail.WithFilenamestringThe name to show for the file in the list of imports, at most 255 characters.
nextmail.WithCalendarIDstringThe calendar the events go into: one you keep, or one you are a member of with write access. Your default calendar unless you say.
nextmail.WithAPIKeystringOverrides the client API key for this call only.
Returns
The nextmail.Object with status: queued.
Example
source, err := os.Open("work.ics")if err != nil { return err} defer source.Close() queued, err := client.Calendar.ImportIcs(ctx, source, nextmail.WithFilename("work.ics"))if err != nil { return err} fmt.Println(queued.ID(), queued.String("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.To send text you already hold, such as what
GetEventIcsreturns, wrap it instrings.NewReader(text).An upload that outlasts the client timeout fails 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.ListImports
List calendar imports
ListImports(ctx context.Context, opts ...nextmail.RequestOption) (*nextmail.Page, error)Returns 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 ImportIcs it lists the calendars that came with a mailbox import, and those carry the id of that import in parentImportId.
Paging is keyset. nextmail.WithLimit takes 1 to 100 and defaults to 25, and NextCursor goes back as nextmail.WithCursor while HasMore is true. ListAllImports and IterateImports do that walk for you.
Parameters
nextmail.WithLimitintImports per page, a whole number from 1 to 100. The server defaults to 25.
nextmail.WithCursorstringThe
NextCursorfrom the previous page. Never build one yourself.nextmail.WithAPIKeystringOverrides the client API key for this call only.
Returns
The *nextmail.Page with Items, HasMore and NextCursor.
Example
page, err := client.Calendar.ListImports(ctx, nextmail.WithLimit(50))if err != nil { return err} for _, job := range page.Items { fmt.Println(job.String("fileName"), job.String("status"), job.Object("counts").Int("imported"), job.Object("counts").Int("skipped"))} fmt.Println(page.HasMore, page.NextCursor)Notes
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
nextmail.WithMaxRetries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
Calendar.ListAllImports
Collect every calendar import into one slice
ListAllImports(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)Follows NextCursor from page to page and returns with every calendar import, newest first.
Everything is held in memory before the call returns. Prefer IterateImports when you can stop early. limit sets the page size of each request, not the total.
Parameters
nextmail.WithLimitintPage size per request, from 1 to 100, defaulting to 25 on the server.
nextmail.WithCursorstringA cursor from an earlier page to start after.
nextmail.WithAPIKeystringOverrides the client API key for every page of this walk.
Returns
A []nextmail.Object holding every import across all pages.
Example
imports, err := client.Calendar.ListAllImports(ctx)if err != nil { return err} added := 0 for _, job := range imports { added += job.Object("counts").Int("imported")} fmt.Println(added, "events came from", len(imports), "imports")Notes
A failure on any page fails the whole call, and the imports already fetched are discarded.
Also available in
Calendar.IterateImports
Stream calendar imports one at a time
IterateImports(ctx context.Context, opts ...nextmail.RequestOption) *nextmail.IteratorReturns an iterator that yields calendar imports one by one, newest first, 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
nextmail.WithLimitintPage size per request, from 1 to 100, defaulting to 25 on the server.
nextmail.WithCursorstringA cursor from an earlier page to start after.
nextmail.WithAPIKeystringOverrides the client API key for every page of this walk.
Returns
The *nextmail.Iterator yielding one import per step.
Example
for job, err := range client.Calendar.IterateImports(ctx).All() { if err != nil { return err } if job.String("status") != "running" { continue } fmt.Println("still running", job.ID(), job.Object("counts").Int("total")) break}Notes
The iterator is lazy, so an abandoned loop costs only the pages you consumed.
Also available in
Calendar.GetImport
Get a calendar import
GetImport(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Returns 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 ImportIcs 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.nextmail.WithAPIKeystringOverrides the client API key for this call only.
Returns
The nextmail.Object with status, counts, report, undoable and when it started, finished and was undone.
Example
item, err := client.Calendar.GetImport(ctx, "iimp_3f9c2a7b1e4d8f60a5c7b92d")if err != nil { return err} counts := item.Object("counts") fmt.Println(item.String("status"), counts.Int("imported"), counts.Int("skipped")) for _, sample := range item.Object("report").Objects("samples") { fmt.Println(sample.String("name"), sample.String("reason"))}Notes
An id that names no calendar import is a 404
item_import_not_found.A GET is retried automatically on network failure and on 408, 500, 502, 503 and 504 responses, up to the client's
nextmail.WithMaxRetries, and on a 429 only when it carries aRetry-Afterof a minute or less.
Also available in
Calendar.UndoImport
Remove what a calendar import added
UndoImport(ctx context.Context, id string, opts ...nextmail.RequestOption) (nextmail.Object, error)Deletes 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.nextmail.WithAPIKeystringOverrides the client API key for this call only.
Returns
The nextmail.Object with status: undone and undoneAt set.
Example
undone, err := client.Calendar.UndoImport(ctx, "iimp_3f9c2a7b1e4d8f60a5c7b92d")if err != nil { return err} fmt.Println(undone.String("status"), undone.String("undoneAt"), undone.Object("counts").Int("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.