# calendarObjects.move

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.

```ts
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](/docs/api/pim/post_CalendarObjectMove) in the API reference.

## Example

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

## Arguments

| Argument | Type | Description |
| --- | --- | --- |
| `identityId` | `string` | Mailbox identity ULID. The path's `{identityId}`. |
| `calendarId` | `string` | Collection ULID or its name slug. The path's `{calendarId}`. |
| `href` | `string` | The object's href: its filename segment within the collection (e.g. 1a2b3c.ics). The path's `{href}`. |
| `body` | [`CalendarObjectsMoveBody`](#calendarobjectsmovebody) | Optional. The request's body. |

## Options

The last argument, `options`, a `CalendarObjectsMoveOptions`, takes:

| Option | Type | Sent as | Description |
| --- | --- | --- | --- |
| `ifMatch` | `string` | header `if-match` | Target ETag validator |
| `ifScheduleTagMatch` | `string` | header `if-schedule-tag-match` | RFC 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](/docs/sdks/typescript/calling-methods#call-options)).

## Answer

Awaited, it is the API's JSON, [`CalendarObjectsMoveResult`](#calendarobjectsmoveresult). It is an [`ApiPromise`](/docs/sdks/typescript/responses): `.withResponse()` gives the same with the `Response` it came in, for its headers.

## Errors

| Status | What it means |
| --- | --- |
| `400` | invalid_href, or neither to nor destination was supplied |
| `401` | unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a `WWW-Authenticate: Bearer` challenge |
| `403` | forbidden — read-only grant on source or destination |
| `404` | No such object, source collection, destination collection, or mailbox |
| `409` | href_taken, uid_conflict, wrong_kind, unsupported_component, or scheduled_overwrite: a scheduled calendar destination cannot be replaced |
| `412` | precondition_failed: If-Match not satisfied |
| `413` | too_large: JSON request body exceeds 1 MiB or 500,000 values (object keys included), checked before parsing |
| `503` | temporary_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`](/docs/sdks/typescript/errors): its `status`, and its `code`, the API's `error`. Decide on the code: one status covers several.

## Types

### CalendarObjectsMoveBody

```ts
/** 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

```ts
/** 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
}
```
