
## Create a post

`POST /v1/posts`

Publishes a post to the Bitrix24 Feed and returns its identifier. The text supports BB-code for formatting.

## Request body fields

| Field | Type | Required | Default | Description |
|------|-----|:-----:|-----------|---------|
| `text` | string | yes | — | Post text. Supports BB-code: `[b]`, `[i]`, `[url]` and other formatting tags |
| `title` | string | no | — | Post title |
| `recipients` | string[] | no | `["UA"]` | Who sees the post. Prefixes (can be combined in an array):<br>`UA` — all employees in the Bitrix24 account,<br>`U<id>` — employee (`GET /v1/users`),<br>`D<id>` — department without sub-departments,<br>`DR<id>` — department with sub-departments (`GET /v1/departments`),<br>`SG<id>` — workgroup or project (`GET /v1/workgroups`).<br>Empty array or omission — `["UA"]` |
| `files` | array | no | — | Files to attach to the post. Each element is a `["file_name", "<base64 content>"]` pair. The file is uploaded to the author's Drive and attached to the post.<br>Example: `[["estimate.pdf", "JVBERi0xLjQ…"]]` |

## Examples

### curl — personal key

```bash
curl -X POST https://vibecode.bitrix24.com/v1/posts \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "New version release",
    "text": "An update shipped today. [b]Details[/b] are in the comments.",
    "recipients": ["U1"]
  }'
```

### curl — OAuth application

```bash
curl -X POST https://vibecode.bitrix24.com/v1/posts \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "New version release",
    "text": "An update shipped today. [b]Details[/b] are in the comments.",
    "recipients": ["U1"]
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/posts', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'New version release',
    text: 'An update shipped today. [b]Details[/b] are in the comments.',
    recipients: ['U1'],
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/posts', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    title: 'New version release',
    text: 'An update shipped today. [b]Details[/b] are in the comments.',
    recipients: ['U1'],
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `data.id` | number | Identifier of the created post. Post address in your Bitrix24 account: `https://<portal>.bitrix24.com/company/personal/user/<authorId>/blog/<id>/`, where `authorId` is the `authorId` field from the [GET /v1/posts](/docs/feed/posts/list) response |
| `data.recipients` | string[] | Recipients the post is shared with. If `recipients` is omitted or empty — `["UA"]` is returned |

## Response example

```json
{
  "success": true,
  "data": {
    "id": 303,
    "recipients": ["U1"]
  }
}
```

## Error response example

400 — `text` not provided:

```json
{
  "success": false,
  "error": {
    "code": "MISSING_PARAMS",
    "message": "Required: text (string — post content)"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `MISSING_PARAMS` | Required parameter `text` not provided |
| 403 | `SCOPE_DENIED` | The API key lacks the `log` scope |
| 401 | `TOKEN_MISSING` | The API key has no access tokens configured |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected post creation (error text in `message`) |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable |

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

## See also

- [Update a post](/docs/feed/posts/update)
- [Delete a post](/docs/feed/posts/delete)
- [Posts](/docs/feed/posts)
- [Feed](/docs/feed)
- [Errors](/docs/errors)
