# Create a holiday calendar (/docs/api-reference/scheduling-holiday-calendars/create-scheduling-holiday-calendar)

Applies a country's public holidays, or your own feed, to some hosts as ordinary out of office entries, kept up to date by coss.com. A host who removes one keeps it removed.

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

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

- `name` (string, required, 1-200 characters)
- `country` (string): A code from the list of holiday calendars, such as `GB`.
- `ics_url` (string, uri, at most 2000 characters): Your own feed, https or webcal, read in live environments. Stored encrypted.
- `hosts` (string[], at most 1000 items): These hosts, by id or uid.
- `host_filter` (map of string | string[]): Everyone matching these attributes, asked again at every sync.
- `regions` (string[], at most 50 items): Which regional holidays apply, matched against how the calendar names them, such as `England`. Without this, all of them do; empty, only nationwide ones.
- `delegates` (string[], at most 10 items): Who can be booked in their place on those days, by id or uid, in order.
- `existing_bookings` ("leave" | "reassign"): What happens to bookings already on a holiday. `leave` (the default) only reports them. `reassign` moves them.

## 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.holidayCalendars.create({
  name: "UK team",
  country: "GB",
  host_filter: {
    team: "london",
  },
});
```

HTTP:

```sh
curl -X POST "https://api.coss.com/v1/scheduling/holiday_calendars" \
  -H "Authorization: Bearer $COSS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "UK team",
  "country": "GB",
  "host_filter": {
    "team": "london"
  }
}'
```

## Response 201

The calendar.

- `object` ("scheduling.holiday_calendar", required)
- `id` (string, required)
- `name` (string, required)
- `source` ("country" | "ics", required)
- `country` (string | null, required)
- `hosts` (string[] | null, required)
- `host_filter` (map of string | string[] | null, required)
- `regions` (string[] | null, required)
- `delegates` (string[], required)
- `existing_bookings` ("leave" | "reassign", required)
- `last_read_at` (string | null, required)
- `last_error` (string | null, required): Why its feed couldn't be read.
- `created_at` (string, required)
- `updated_at` (string, required)

Example:

```json
{
  "object": "scheduling.holiday_calendar",
  "id": "hcal_01kd2m9a0b1c2d3e4f5g6h7j8m",
  "name": "UK team",
  "source": "country",
  "country": "GB",
  "hosts": null,
  "host_filter": {
    "team": "london"
  },
  "regions": [
    "England"
  ],
  "delegates": [],
  "existing_bookings": "leave",
  "last_read_at": "2027-01-01T10:00:00.000Z",
  "last_error": null,
  "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`: That isn't something to read (`invalid_holiday_calendar`).
- `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`).