## Create a task template

`POST /v1/task-templates`

Creates a task template in Bitrix24. Template fields are passed in the `fields` object with their Bitrix24 names, without renaming.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|----------|
| `fields` | object | yes | Template fields. Passed to Bitrix24 unchanged |
| `fields.TITLE` | string | yes | Title of the template and of the future task |
| `fields.CREATED_BY` | number | yes | Creator ID. List: [`GET /v1/users`](/docs/entities/users/list) |
| `fields.RESPONSIBLE_ID` | number | yes | Responsible person ID. List: [`GET /v1/users`](/docs/entities/users/list) |
| `fields.DESCRIPTION` | string | no | Task description |
| `fields.PRIORITY` | number | no | Priority: `0` — low, `1` — normal, `2` — high. Defaults to `1` |
| `params` | object | no | Additional Bitrix24 parameters. Passed unchanged |

The body must not contain keys other than `fields` and `params`.

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/task-templates" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fields": {
      "TITLE": "Weekly status report",
      "CREATED_BY": 1,
      "RESPONSIBLE_ID": 1
    }
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/task-templates" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fields": {
      "TITLE": "Weekly status report",
      "CREATED_BY": 1,
      "RESPONSIBLE_ID": 1
    }
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/task-templates', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: {
      TITLE: 'Weekly status report',
      CREATED_BY: 1,
      RESPONSIBLE_ID: 1,
    },
  }),
})

const { success, data } = await res.json()
if (success && data > 0) {
  console.log('Template ID:', data)
}
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/task-templates', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    fields: {
      TITLE: 'Weekly status report',
      CREATED_BY: 1,
      RESPONSIBLE_ID: 1,
    },
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` if the request was accepted |
| `data` | number | ID of the created template. `0` — the template was not created: `fields` lacks `TITLE`, `CREATED_BY` or `RESPONSIBLE_ID`. The response status is still `200`, so check that `data` is greater than zero |

## Response example

```json
{
  "success": true,
  "data": 75
}
```

## Error response example

400 — the body has no `fields` object:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "Expected fields and only fields, params"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | The body is not a JSON object, has no `fields` object, contains keys other than `fields` and `params`, or `params` is not an object |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key does not have the `task` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is in read-only mode. `error.details.switchUrl` holds the URL of the section where the mode is changed |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the call. The text is in `error.message` |
| 429 | `RATE_LIMITED` | Request rate exceeded. The effective cap is in the `x-ratelimit-limit` header |

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

## See also

- [Task templates](/docs/entities/tasks/templates)
- [List task templates](/docs/entities/tasks/templates-list)
- [Get a task template](/docs/entities/tasks/templates-get)
- [Update a task template](/docs/entities/tasks/templates-update)
- [Employees](/docs/entities/users)
