Skip to Content

Move or rename calendar object.

Moves a calendar object to another collection, renames its href slug, or both. Optional overwrite validates the destination and replaces an unscheduled occupant atomically; the replaced object remains recoverable in trash.

openemail.calendarObjects.move(
  identityId: string,
  calendarId: string,
  href: string,
  body?: CalendarObjectsMoveBody,
  options?: CalendarObjectsMoveOptions,
): ApiPromise<CalendarObjectsMoveResult>

It calls POST /identities/{identityId}/calendars/{calendarId}/objects/{href}/move: Move or rename calendar object in the API reference.

Example

const result = await openemail.calendarObjects.move(identityId, calendarId, href, {})

Arguments

ArgumentTypeDescription
identityIdstringMailbox identity ULID. The path's {identityId}.
calendarIdstringCollection ULID or its name slug. The path's {calendarId}.
hrefstringThe object's href: its filename segment within the collection (e.g. 1a2b3c.ics). The path's {href}.
bodyCalendarObjectsMoveBodyOptional. The request's body.

Options

The last argument, options, a CalendarObjectsMoveOptions, takes:

OptionTypeSent asDescription
ifMatchstringheader if-matchTarget ETag validator
ifScheduleTagMatchstringheader if-schedule-tag-matchRFC 6638 schedule-tag validator; 412 on a mismatch

Every call also takes signal, timeout, retry and headers, which say how that one call is sent (call options).

Answer

Awaited, it is the API's JSON, CalendarObjectsMoveResult. It is an ApiPromise: .withResponse() gives the same with the Response it came in, for its headers.

Errors

StatusWhat it means
400invalid_href, or neither to nor destination was supplied
401unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a WWW-Authenticate: Bearer challenge
403forbidden — read-only grant on source or destination
404No such object, source collection, destination collection, or mailbox
409href_taken, uid_conflict, wrong_kind, unsupported_component, or scheduled_overwrite: a scheduled calendar destination cannot be replaced
412precondition_failed: If-Match not satisfied
413too_large: JSON request body exceeds 1 MiB or 500,000 values (object keys included), checked before parsing
503temporary_failure: the platform's storage could not answer just now; retry after the Retry-After window. Any operation can answer this. A write that got it may have been applied, so retry it with the same idempotency key where it takes one, or read the state back first (see Transient failures in the API description)

A failed call rejects with a RequestError: its status, and its code, the API's error. Decide on the code: one status covers several.

Types

CalendarObjectsMoveBody

/** The body of `calendarObjects.move`. */
type CalendarObjectsMoveBody = {
  /** Replace an existing destination atomically (default false); scheduled calendar occupants cannot be replaced */
  overwrite?: boolean
  /** New resource href slug */
  to?: string
  /** Destination collection ULID or name slug */
  toCalendarId?: string
}

CalendarObjectsMoveResult

/** What `calendarObjects.move` answers. */
type CalendarObjectsMoveResult = {
  /** Where the object now lives */
  collectionId: string
  etag: string
  id: string
  /** Whether an existing destination object was replaced */
  overwritten: boolean
  /** RFC 6638 schedule-tag of the object at its new href */
  scheduleTag: string
  syncToken: string
}