## List pending flow tasks

`GET /v1/tasks/flows/:flowId/tasks/pending`

Returns the flow tasks that no one has started yet: the flow queue at the time of the call.

## Parameters

| Parameter | Type | Required | Default | Description |
|----------|-----|:-----:|-----------|----------|
| `flowId` (path) | number | yes | — | Flow ID, a positive integer. List: [`GET /v1/tasks/flows`](/docs/entities/tasks/flows-list) |
| `start` (query) | number | no | `0` | Page offset in steps of 50, a non-negative integer. See the Pagination paragraph below |

**Pagination.** The response is one page of up to 50 tasks; the total number of tasks in the list is in `data.totalCount`. `start` selects the page in steps of 50: values from `0` to `49` return the first page, `50` returns the second. Request the next page with `start` increased by exactly 50. Pages are not loaded automatically.

## Examples

### curl — personal key

```bash
curl -X GET "https://vibecode.bitrix24.com/v1/tasks/flows/15/tasks/pending" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl -X GET "https://vibecode.bitrix24.com/v1/tasks/flows/15/tasks/pending" \
  -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/tasks/flows/15/tasks/pending', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data } = await res.json()
console.log(`Waiting to start: ${data.totalCount}`)
data.tasks.forEach((task) => {
  const taskId = Number(task.url.split('/').at(-2))
  console.log(taskId, task.title, task.timeInStatus.formatted)
})
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/flows/15/tasks/pending', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

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

## Response fields

| Field | Type | Description |
|------|-----|----------|
| `success` | boolean | `true` on success |
| `data` | object | The list page and the total number of tasks |
| `data.tasks` | array | Pending tasks on this page. An empty array if there are no pending tasks |
| `data.tasks[].title` | string | Task title |
| `data.tasks[].url` | string | Relative URL of the task in the Bitrix24 account. There is no separate task ID field: the ID is the last path segment, `4220` and `4222` in the example. The full task: [`GET /v1/tasks/:id`](/docs/entities/tasks/get) |
| `data.tasks[].serial` | number | Sequence number of the task in the response, starting from `1` |
| `data.tasks[].creator` | object | Task creator |
| `data.tasks[].creator.id` | string | Creator ID, as a string. Get: [`GET /v1/users/:id`](/docs/entities/users/get) |
| `data.tasks[].creator.name` | string | Employee display name |
| `data.tasks[].creator.avatar` | string | Employee photo URL |
| `data.tasks[].creator.workPosition` | string \| null | Job title. Can be an empty string or `null` |
| `data.tasks[].creator.pathToProfile` | string | Relative URL of the employee profile in the Bitrix24 account |
| `data.tasks[].responsible` | object | Responsible person for the task. Same fields as `creator`. The ID is a string. Get: [`GET /v1/users/:id`](/docs/entities/users/get) |
| `data.tasks[].timeInStatus` | object | How long the task has been waiting since it was created |
| `data.tasks[].timeInStatus.years`, `months`, `days`, `hours`, `minutes`, `seconds` | number | Duration components: years, months, days, hours, minutes, seconds |
| `data.tasks[].timeInStatus.formatted` | string | Human-readable duration in the Bitrix24 account language, for example `1 minute`. A duration under a minute is also labeled `1 minute` |
| `data.tasks[].canRead` | number | `1` — the employee on whose behalf the call is made can read the task |
| `data.totalCount` | number | Total number of pending tasks in the flow, across all pages |

## Response example

```json
{
  "success": true,
  "data": {
    "tasks": [
      {
        "title": "Prepare a sales proposal",
        "url": "/company/personal/user/15/tasks/task/view/4220/",
        "serial": 1,
        "creator": {
          "id": "15",
          "name": "Anna Smith",
          "avatar": "https://example.bitrix24.com/upload/main/a1b/avatar.jpg",
          "workPosition": null,
          "pathToProfile": "/company/personal/user/15/"
        },
        "responsible": {
          "id": "27",
          "name": "David Taylor",
          "avatar": "https://example.bitrix24.com/upload/main/c2d/avatar.jpg",
          "workPosition": null,
          "pathToProfile": "/company/personal/user/27/"
        },
        "timeInStatus": {
          "years": 0,
          "months": 0,
          "days": 0,
          "hours": 0,
          "minutes": 0,
          "seconds": 9,
          "formatted": "1 minute"
        },
        "canRead": 1
      },
      {
        "title": "Review the client contract",
        "url": "/company/personal/user/15/tasks/task/view/4222/",
        "serial": 2,
        "creator": {
          "id": "15",
          "name": "Anna Smith",
          "avatar": "https://example.bitrix24.com/upload/main/a1b/avatar.jpg",
          "workPosition": null,
          "pathToProfile": "/company/personal/user/15/"
        },
        "responsible": {
          "id": "27",
          "name": "David Taylor",
          "avatar": "https://example.bitrix24.com/upload/main/c2d/avatar.jpg",
          "workPosition": null,
          "pathToProfile": "/company/personal/user/27/"
        },
        "timeInStatus": {
          "years": 0,
          "months": 0,
          "days": 0,
          "hours": 0,
          "minutes": 0,
          "seconds": 8,
          "formatted": "1 minute"
        },
        "canRead": 1
      }
    ],
    "totalCount": 2
  }
}
```

## Error response example

400 — the request contains a parameter the method does not accept, here `days`:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "query contains unsupported fields"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | The request contains a parameter other than `start`, for example `days`. Message `query contains unsupported fields` |
| 400 | `INVALID_PARAMS` | `flowId` is not a positive integer. Message `flowId must be a positive safe integer` |
| 400 | `INVALID_PARAMS` | `start` is not a non-negative integer. Message `start must be a non-negative safe integer` |
| 401 | `MISSING_API_KEY` | `X-Api-Key` is missing |
| 401 | `INVALID_API_KEY` | The key is not found |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key lacks the `task` or `tasks` scope |
| 422 | `BITRIX_ERROR` | Bitrix24 rejected the call. The text is in `error.message`; the Bitrix24 code, if any, is in `error.b24Code` |
| 429 | `RATE_LIMITED` | The request rate to Bitrix24 or to the platform was exceeded. Retry after the delay in the `Retry-After` header |

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

## Known specifics

**A nonexistent flow does not cause an error.** A nonexistent or deleted `flowId` returns `200` with an empty `tasks` and `"totalCount": 0`, just like a flow with no pending tasks. To check that the flow exists, use [`GET /v1/tasks/flows/:flowId`](/docs/entities/tasks/flows-get).

## See also

- [Flows and flow tasks](/docs/entities/tasks/flows)
- [List in-progress flow tasks](/docs/entities/tasks/flows-progress)
- [List completed flow tasks](/docs/entities/tasks/flows-completed)
- [Get a flow](/docs/entities/tasks/flows-get)
- [Start task](/docs/entities/tasks/start)
- [Get task](/docs/entities/tasks/get)
