# Feed

Publishing posts to the Bitrix24 Feed via the API: posts addressed to departments and employees, granting access to additional recipients, and comments.

**Scope:** `log` | **Base URL:** `https://vibecode.bitrix24.com/v1` | **Authorization:** `X-Api-Key`

[Quick start](#quick-start) | [Full example](#full-example) | [Endpoint reference](#endpoint-reference) | [Error codes](#error-codes)

## Documentation sections

- [Posts](/docs/feed/posts) — create, list, update, delete posts and add recipients
- [Comments](/docs/feed/comments) — add and delete comments on posts

## Quick start

### 1. Publish a post

```bash
curl -X POST https://vibecode.bitrix24.com/v1/posts \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Platform update",
    "text": "[b]A new version is out[/b] — batch request support.",
    "recipients": ["UA"]
  }'
```

The response is the identifier of the created post and the recipients it was opened to:

```json
{
  "success": true,
  "data": {
    "id": 512,
    "recipients": ["UA"]
  }
}
```

### 2. Comment on a post

```bash
curl -X POST https://vibecode.bitrix24.com/v1/posts/512/comments \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "text": "Great news!" }'
```

The response is the comment identifier:

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

### 3. Open the post to additional recipients

```bash
curl -X POST https://vibecode.bitrix24.com/v1/posts/512/share \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "recipients": ["DR3", "U5"] }'
```

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

## Full example

An automated report to the Feed: publishing a post, a comment from the integration, and granting access to management. The scenario uses only the `log` scope.

```javascript
const VIBE_KEY = process.env.VIBE_KEY
const BASE = 'https://vibecode.bitrix24.com/v1'

async function api(method, path, body = null) {
  const opts = { method, headers: { 'X-Api-Key': VIBE_KEY } }
  if (body) {
    opts.headers['Content-Type'] = 'application/json'
    opts.body = JSON.stringify(body)
  }
  const res = await fetch(`${BASE}${path}`, opts)
  return res.status === 204 ? null : res.json()
}

// 1. Publish the daily report, addressing a department with sub-departments
const created = await api('POST', '/posts', {
  title: 'Daily report',
  text: [
    '[b]Day summary[/b]',
    '',
    'Closed tasks: 48',
    'New requests: 12'
  ].join('\n'),
  recipients: ['DR1']
})
const postId = created.data.id
console.log('Post published, ID:', postId)

// 2. Add a comment from the integration
const comment = await api('POST', `/posts/${postId}/comments`, {
  text: 'The report was generated automatically by the Vibecode integration.'
})
console.log('Comment added, ID:', comment.data)

// 3. Open the report to management
await api('POST', `/posts/${postId}/share`, { recipients: ['U1'] })

// 4. Check that the post is in the Feed
const list = await api('GET', '/posts?limit=5')
console.log('Total posts:', list.meta.total)
```

## Endpoint reference

| Method | Path | Bitrix24 method | Description |
|-------|------|---------------|---------|
| POST | [/v1/posts](/docs/feed/posts/create) | log.blogpost.add | Create a post |
| GET | [/v1/posts](/docs/feed/posts/list) | log.blogpost.get | List posts |
| PATCH | [/v1/posts/:id](/docs/feed/posts/update) | log.blogpost.update | Update a post |
| DELETE | [/v1/posts/:id](/docs/feed/posts/delete) | log.blogpost.delete | Delete a post |
| POST | [/v1/posts/:id/share](/docs/feed/posts/share) | log.blogpost.share | Add recipients |
| POST | [/v1/posts/:id/comments](/docs/feed/comments/add) | log.blogcomment.add | Add a comment |
| DELETE | [/v1/posts/:id/comments/:commentId](/docs/feed/comments/delete) | log.blogcomment.delete | Delete a comment |

## Error codes

### Feed errors

| Code | HTTP | Description |
|-----|------|---------|
| `SCOPE_DENIED` | 403 | The API key lacks the `log` scope |
| `TOKEN_MISSING` | 401 | The API key has no access tokens configured |
| `MISSING_PARAMS` | 400 | Required parameters are missing (`text` for a post or comment, `recipients` for adding recipients) |
| `INVALID_LIMIT` | 400 | `limit` is out of the 1..50 range |
| `INVALID_OFFSET` | 400 | `offset` is negative |
| `INVALID_POST_ID` | 400 | The post `id` is not a positive integer |
| `POST_NOT_FOUND` | 404 | The post was not found or is not accessible with this key |
| `POST_NOT_FOUND_OR_INVALID_RECIPIENTS` | 404 | Adding recipients rejected: the post does not exist or one of the recipients is invalid |
| `INVALID_RECIPIENTS` | 400 | Invalid recipients format |
| `BITRIX_ACCESS_DENIED` | 403 | Insufficient permissions on the post |
| `COMMENT_NOT_FOUND` | 404 | The comment was not found |
| `INVALID_COMMENT_ID` | 400 | `commentId` is invalid |
| `COMMENT_ACCESS_DENIED` | 403 | Insufficient permissions on the comment |
| `DUPLICATE_COMMENT` | 409 | A repeated comment with the same content |

### System errors

| Code | HTTP | Description |
|-----|------|---------|
| `MISSING_API_KEY` | 401 | The `X-Api-Key` header is missing |
| `INVALID_API_KEY` | 401 | Invalid API key |
| `RATE_LIMITED` | 429 | Request rate limit exceeded |
| `BITRIX_ERROR` | 422 | Bitrix24 returned an error |
| `BITRIX_UNAVAILABLE` | 502 | The Bitrix24 portal is unavailable |
| `INTERNAL_ERROR` | 500 | Internal server error |

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

## See also

- [Posts](/docs/feed/posts)
- [Comments](/docs/feed/comments)
- [Keys and authorization](/docs/keys-auth)
- [Errors](/docs/errors)
