# Create out of office entries (/docs/api-reference/scheduling-out-of-office/create-scheduling-out-of-office)

Marks one host, a list of hosts or everyone matching some attributes as away, for part of a day or for whole dates. They aren't offered during it. Existing bookings stay as they are: list them with the entry's conflicts.

`POST https://api.coss.com/v1/scheduling/out_of_office`

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).

## Request body

- `host` (string): One host, by id or uid.
- `hosts` (string[], at most 500 items): Several hosts, by id or uid. Each gets an entry of their own.
- `host_filter` (map of string | string[]): Every active host matching these attributes right now. A host added later isn't covered.
- `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.
- `external_id` (string, 1-255 characters): Your own id for this entry, unique in the environment. Needs one host.

## 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.create({
  host: "doctor_482",
  start_date: "2027-08-02",
  end_date: "2027-08-13",
  reason: "vacation",
  public_message: "Back on the 16th.",
});
```

HTTP:

```sh
curl -X POST "https://api.coss.com/v1/scheduling/out_of_office" \
  -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",
  "public_message": "Back on the 16th."
}'
```

## Response 201

An entry per host.

- `object` ("list", required)
- `data` (object[], required)
  - `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)
- `has_more` (boolean, required)

Example:

```json
{
  "object": "list",
  "data": [
    {
      "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"
    }
  ],
  "has_more": false
}
```

## 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`).