
## Create activity

`POST /v1/activity-configurable`

Creates a configurable activity in the timeline of a CRM entity. `fields` defines the activity's field set; `layout` defines its appearance.

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `ownerTypeId` | number | yes | CRM entity type:<br>1 — lead<br>2 — deal<br>3 — contact<br>4 — company<br>7 — quote<br>31 — invoice<br>≥128 — smart process, the type ID is in [`GET /v1/smart-processes`](/docs/entities/smart-processes/list) |
| `ownerId` | number | yes | ID of the entity in whose timeline the activity is created. The source depends on `ownerTypeId`: [`GET /v1/leads`](/docs/entities/leads/list), [`GET /v1/deals`](/docs/entities/deals/list), [`GET /v1/contacts`](/docs/entities/contacts/list), [`GET /v1/companies`](/docs/entities/companies/list), [`GET /v1/quotes`](/docs/entities/quotes/list), [`GET /v1/invoices`](/docs/entities/invoices/list), [`GET /v1/items/:entityTypeId`](/docs/entities/items/list) |
| `fields` | object | yes | Activity fields |
| `fields.typeId` | string | no | Activity type. Defaults to `CONFIGURABLE`. A custom type is registered in Bitrix24 as configurable in the context of the same application |
| `fields.completed` | boolean | no | Activity is closed. Accepts `true`/`false`, `1`/`0`, `Y`/`N` |
| `fields.deadline` | string | no | Due date, ISO 8601. Incompatible with `fields.isIncomingChannel` |
| `fields.pingOffsets` | number[] | no | Offsets in minutes relative to `fields.deadline` at which reminders are generated |
| `fields.isIncomingChannel` | boolean | no | Activity created from an incoming channel. Accepts `true`/`false`, `1`/`0`, `Y`/`N` |
| `fields.responsibleId` | number | no | ID of the responsible employee. List: [`GET /v1/users`](/docs/entities/users/list) |
| `fields.badgeCode` | string | no | Activity badge code on the Kanban board |
| `fields.originatorId` | string | no | ID of the external data source |
| `fields.originId` | string | no | ID of the record in the external source |
| `layout` | object | yes | Activity appearance in the timeline |
| `layout.icon.code` | string | yes | Activity icon code |
| `layout.header.title` | string | yes | Activity title |
| `layout.body.logo.code` | string | yes | Logo code in the body. Without `logo`, the request fails with `422 BITRIX_ERROR` |
| `layout.body.blocks` | object | no | Named body blocks |
| `layout.footer.buttons` | object | no | Buttons in the bottom section of the activity |

A block in `layout.body.blocks` has a `type` and `properties`. Main block types:

- `text` — value
- `link` — link with an action
- `lineOfBlocks` — a row of nested blocks
- `withTitle` — block with a caption

The action of links and buttons is defined by the `type` field:

- `redirect` — navigation to the URL from the `uri` field
- `openRestApp` — opening the application with the parameters from `actionParams`
- `restEvent` — an event to the application by `id`, for menu items

## Examples

Examples are given only for an OAuth application: a personal key does not work here. OAuth application requirements — [Configurable activities](/docs/entities/activities/configurable).

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/activity-configurable \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "ownerTypeId": 1,
    "ownerId": 999,
    "fields": { "typeId": "CONFIGURABLE", "completed": true, "responsibleId": 1, "badgeCode": "CUSTOM" },
    "layout": {
      "icon": { "code": "call-completed" },
      "header": { "title": "Incoming call" },
      "body": {
        "logo": { "code": "call-incoming" },
        "blocks": {
          "phone": { "type": "text", "properties": { "value": "+12025550123" } }
        }
      },
      "footer": {
        "buttons": {
          "startCall": {
            "title": "About the client",
            "type": "primary",
            "action": { "type": "openRestApp", "actionParams": { "clientId": 456 } }
          }
        }
      }
    }
  }'
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/activity-configurable', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    ownerTypeId: 1,
    ownerId: 999,
    fields: { typeId: 'CONFIGURABLE', completed: true, responsibleId: 1, badgeCode: 'CUSTOM' },
    layout: {
      icon: { code: 'call-completed' },
      header: { title: 'Incoming call' },
      body: {
        logo: { code: 'call-incoming' },
        blocks: {
          phone: { type: 'text', properties: { value: '+12025550124' } },
        },
      },
      footer: {
        buttons: {
          startCall: {
            title: 'About the client',
            type: 'primary',
            action: { type: 'openRestApp', actionParams: { clientId: 456 } },
          },
        },
      },
    },
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | object | The result — the activity in the `activity` field |
| `data.activity.id` | number | ID of the created activity |

## Response example

```json
{
  "success": true,
  "data": { "activity": { "id": 8053 } }
}
```

## Error response example

422 — `logo` not filled in the body:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "The logo field in BodyDto must be filled in."
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `VALIDATION_ERROR` | `ownerTypeId`, `ownerId`, `fields`, or `layout` not provided. Message: `ownerTypeId, ownerId, fields, and layout are required` |
| 422 | `BITRIX_ERROR` | Request with a personal key `vibe_api_*`. The `b24Code` field of the response carries `ERROR_WRONG_CONTEXT`: the method works only with an authorization key `vibe_app_*` and a session token |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the request: empty `layout`, `layout.body.logo` not filled, incoming activity with `deadline` |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only — see [access rights](/docs/access-rights) |
| 403 | `SCOPE_DENIED` | The key lacks the `crm` scope |
| 401 | `TOKEN_MISSING` | The authorization key was passed without a session token in the `Authorization: Bearer` header |

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

## See also

- [Get activity](/docs/entities/activities/configurable/get)
- [Update activity](/docs/entities/activities/configurable/update)
- [Configurable activities](/docs/entities/activities/configurable)
- [Activities](/docs/entities/activities)
