# Flow form

Data for the form that creates a task flow from a collab: the ID of the collab's workgroup. The flow is not created — the user fills in the form in Bitrix24.

## Get the form data

`GET /v1/chats/:dialogId/flow-form`

The v2 messenger method `im.v2.Chat.Flow.prepare`. Works for collabs only.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `dialogId` (path) | string | yes | Dialog ID of the collab: `chat123` |

The operation accepts no query parameters: any query parameter is rejected with `400 INVALID_PARAMS`.

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/chats/chat42/flow-form" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/chats/chat42/flow-form" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/flow-form', {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' },
})

const { data } = await res.json()
console.log('Collab group:', data.groupId)
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/chats/chat42/flow-form', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { data } = await res.json()
console.log('Collab group:', data.groupId)
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.groupId` | number | ID of the collab's workgroup — the flow will be created in it |

## Response example

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

## Error response example

422 — the chat is not a collab:

```json
{
  "success": false,
  "error": {
    "code": "BITRIX_ERROR",
    "message": "Chat type is not supported",
    "b24Code": "CHAT_TYPE_NOT_SUPPORTED"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | A query parameter was passed — the operation accepts none |
| 401 | `TOKEN_MISSING` | The API key has no Bitrix24 tokens configured |
| 403 | `SCOPE_DENIED` | The API key does not have the `im` scope |
| 403 | `WRITE_BLOCKED_READONLY_KEY` | The key is read-only: the call may make the key owner a chat member |
| 404 | `ENTITY_NOT_FOUND` | Bitrix24 returned "not found"; the portal code is in `error.b24Code` |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error; the portal code is in `error.b24Code`. `CHAT_TYPE_NOT_SUPPORTED` — the chat is not a collab, `GROUP_WAS_NOT_FOUND` — the collab has no workgroup |
| 502 | `ME_ALIAS_RESOLUTION_FAILED` | Failed to resolve the current user for `me` |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable or returned a server error |

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

## Known specifics

- The operation only reads data, but Bitrix24 may add the caller to the collab if the collab allows auto-join, as opening the chat in the interface does. A read-only key therefore gets `403 WRITE_BLOCKED_READONLY_KEY`.

## See also

- [Task form](/docs/chats/service/task-form)
- [Service methods](/docs/chats/service)
