
## Create calendar resource

`POST /v1/calendar-resources`

Creates a calendar resource with the specified name.

The request body is flat — no `fields` wrapper.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `name` | string | yes | Resource name |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/calendar-resources" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Meeting room 2"}'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/calendar-resources" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "Meeting room 2"}'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/calendar-resources', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Meeting room 2' }),
})

const { success, data } = await res.json()
console.log('Resource ID:', data.id)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/calendar-resources', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Meeting room 2' }),
})

const { success, data } = await res.json()
```

## Response fields

A successful creation returns HTTP status `201 Created`.

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | ID of the created resource. The resource name and creator are returned by [`GET /v1/calendar-resources`](./list.md) |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 285
  }
}
```

## Error response example

400 — empty request body:

```json
{
  "success": false,
  "error": {
    "code": "EMPTY_CREATE_BODY",
    "message": "Request body is empty — provide at least one field to create calendarResource."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `EMPTY_CREATE_BODY` | The request body is empty — pass `name` |
| 400 | `READONLY_FIELD` | The body contains a read-only field — `id` or `createdBy` |
| 422 | `BITRIX_ERROR` | `name` is an empty string. Message: the required parameter `name` is not set |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The API key is in read-only mode — writes are forbidden |
| 403 | `SCOPE_DENIED` | The API key does not have the `calendar` scope |
| 403 | `BITRIX_ACCESS_DENIED` | Bitrix24 denied the key owner permission to create the resource |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header was not passed |
| 429 | `RATE_LIMITED` | Rate limit exceeded |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a malformed response |
| 503 | `BITRIX_TIMEOUT` | Bitrix24 did not respond in time |

Full list of common API errors — [Errors](/docs/errors).

## Known specifics

**Several resources in one call.** `POST /v1/calendar-resources/batch` with the `create` action creates resources in a batch: `{"action": "create", "items": [{"name": "Meeting room 2"}]}`. The IDs of the created resources are returned in `data.results[].id`.

## See also

- [List calendar resources](./list.md)
- [Rename calendar resource](./update.md)
- [Delete calendar resource](./delete.md)
- [Resource bookings](./bookings.md)
- [Calendar resources](/docs/entities/calendar-resources)
