# Create or replace an entry by your own id (/docs/api-reference/scheduling-out-of-office/put-scheduling-out-of-office)

For syncing from a system of record such as an HR tool: send what it says, as often as you like, and there's one entry for it. Give every field you want to keep.

`PUT https://api.coss.com/v1/scheduling/out_of_office/by_external_id/{external_id}`

Authenticate with your API key as a bearer token (`Authorization: Bearer coss_test_…`). Responses are JSON with snake_case fields; errors are `{ error: { type, code, message, param?, issues?, request_id } }` (https://coss.com/docs/api-reference/errors.md).

## Path parameters

- `external_id` (string, required): Your own id for the entry.

## Request body

- `host` (string, required): The host, by id or uid.
- `start` (string): An ISO 8601 instant with an offset.
- `end` (string): An ISO 8601 instant with an offset.
- `start_date` (string): The first whole day away. Use instead of `start` and `end`.
- `end_date` (string): The last whole day away, which is included.
- `time_zone` (string, 1-64 characters): What the dates mean in. Default: the host's zone when this is made.
- `delegates` (string[], at most 10 items): Who can be booked in this host's place during it, by id or uid, in the order to try them. They still have to fit how a booking's routed.
- `reason` (string): One of `unspecified`, `vacation`, `travel`, `sick`, `public_holiday`, `parental_leave`, `training` and `other`, or a key from the settings' `out_of_office_reasons`. Only people who manage this host see it: never bookers, webhooks or calendars.
- `notes` (string, at most 2000 characters): For people who manage this host. Encrypted, and never shown to a booker.
- `public_message` (string, at most 300 characters): Shown to bookers while this host is away. Can't contain a link.
- `show_on_calendar` (boolean): Put a private "Out of office" event on the host's calendar. Default: true.
- `existing_bookings` ("leave" | "reassign"): What happens to bookings already in the way. `leave` (the default) only reports them. `reassign` moves them, and any nobody can take stay where they are.
- `reassign` (object): With `existing_bookings: reassign`: who they go to. Default: the fairest who's free.
  - `to_host` (string): Give them all to this host.
  - `preferred_hosts` (string[], at most 20 items): Try these first, in order.
  - `otherwise` ("auto" | "leave"): After `preferred_hosts`: `auto` picks the fairest who's free (the default), `leave` keeps it where it is.

## Example request

TypeScript (the `coss` package):

```ts
import { Coss } from "coss";

const coss = new Coss({
  apiKey: process.env.COSS_API_KEY,
  baseUrl: "https://api.coss.com",
});

const { data, error } = await coss.scheduling.outOfOffice.put({
  value: "hr_leave_4471",
}, {
  host: "doctor_482",
  start_date: "2027-08-02",
  end_date: "2027-08-13",
  reason: "vacation",
});
```

HTTP:

```sh
curl -X PUT "https://api.coss.com/v1/scheduling/out_of_office/by_external_id/hr_leave_4471" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "host": "doctor_482",
  "start_date": "2027-08-02",
  "end_date": "2027-08-13",
  "reason": "vacation"
}'
```

## Response 200

The entry, replaced.

- `object` ("scheduling.out_of_office", required)
- `id` (string, required)
- `host` (string, required)
- `start` (string, required)
- `end` (string, required)
- `all_day` (object | null, required): How it was given, when it was as whole dates.
  - `start_date` (string, required)
  - `end_date` (string, required)
  - `time_zone` (string, required)
- `reason` (string, required)
- `notes` (string | null, required)
- `public_message` (string | null, required)
- `show_on_calendar` (boolean, required)
- `delegates` (string[], required): Who can be booked in their place.
- `existing_bookings` ("leave" | "reassign", required)
- `external_id` (string | null, required)
- `group` (string | null, required): Shared by the entries one request made for several hosts.
- `source` ("api" | "host" | "manager" | "dashboard" | "holiday", required)
- `created_at` (string, required)
- `updated_at` (string, required)

Example:

```json
{
  "object": "scheduling.out_of_office",
  "id": "ooo_01kd2m9a0b1c2d3e4f5g6h7j8m",
  "host": "host_01kd2m9a0b1c2d3e4f5g6h7j8m",
  "start": "2027-08-02T04:00:00.000Z",
  "end": "2027-08-14T04:00:00.000Z",
  "all_day": {
    "start_date": "2027-08-02",
    "end_date": "2027-08-13",
    "time_zone": "America/New_York"
  },
  "reason": "vacation",
  "notes": null,
  "public_message": "Back on the 16th.",
  "show_on_calendar": true,
  "delegates": [
    "host_01kd2m9a0b1c2d3e4f5g6h7j8n"
  ],
  "existing_bookings": "leave",
  "external_id": null,
  "group": null,
  "source": "api",
  "created_at": "2027-01-01T10:00:00.000Z",
  "updated_at": "2027-01-01T10:00:00.000Z"
}
```

## Response 201

The entry, new.

- `object` ("scheduling.out_of_office", required)
- `id` (string, required)
- `host` (string, required)
- `start` (string, required)
- `end` (string, required)
- `all_day` (object | null, required): How it was given, when it was as whole dates.
  - `start_date` (string, required)
  - `end_date` (string, required)
  - `time_zone` (string, required)
- `reason` (string, required)
- `notes` (string | null, required)
- `public_message` (string | null, required)
- `show_on_calendar` (boolean, required)
- `delegates` (string[], required): Who can be booked in their place.
- `existing_bookings` ("leave" | "reassign", required)
- `external_id` (string | null, required)
- `group` (string | null, required): Shared by the entries one request made for several hosts.
- `source` ("api" | "host" | "manager" | "dashboard" | "holiday", required)
- `created_at` (string, required)
- `updated_at` (string, required)

Example:

```json
{
  "object": "scheduling.out_of_office",
  "id": "ooo_01kd2m9a0b1c2d3e4f5g6h7j8m",
  "host": "host_01kd2m9a0b1c2d3e4f5g6h7j8m",
  "start": "2027-08-02T04:00:00.000Z",
  "end": "2027-08-14T04:00:00.000Z",
  "all_day": {
    "start_date": "2027-08-02",
    "end_date": "2027-08-13",
    "time_zone": "America/New_York"
  },
  "reason": "vacation",
  "notes": null,
  "public_message": "Back on the 16th.",
  "show_on_calendar": true,
  "delegates": [
    "host_01kd2m9a0b1c2d3e4f5g6h7j8n"
  ],
  "existing_bookings": "leave",
  "external_id": null,
  "group": null,
  "source": "api",
  "created_at": "2027-01-01T10:00:00.000Z",
  "updated_at": "2027-01-01T10:00:00.000Z"
}
```

## Errors

- `400`: The body is not valid JSON (`invalid_json`). Also when the `Coss-Version` header names an unknown API version (`invalid_api_version`).
- `401`: The API key is missing, invalid, revoked or expired (`authentication_error`).
- `403`: The API key lacks the permission this endpoint needs (`permission_error`), or its organization is suspended (`organization_suspended`).
- `404`: Nothing with this id or uid exists in the environment (`not_found`).
- `415`: The body is not sent as `application/json` (`unsupported_media_type`).
- `422`: The request failed validation (`validation_error`, see `issues`), or can't be done: see `code`.
- `429`: Too many requests with this API key (`rate_limited`), or too many requests with invalid keys from this address (`too_many_failed_authentications`). Retry after `Retry-After` seconds. Successful responses carry `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` (seconds until the limit is fully restored).
- `500`: Unexpected server error (`api_error` / `internal_error`).
- `503`: The API key could not be verified right now; retry (`service_unavailable`).