## Get the ID of the first task result

`GET /v1/tasks/:taskId/results/first`

Returns the ID of the task's first result — the smallest ID among its results, without the text or author.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|----------|
| `taskId` (path) | number | yes | Task ID, a positive integer. List: [`GET /v1/tasks`](/docs/entities/tasks/list) |

## Examples

### curl — personal key

```bash
curl -X GET "https://vibecode.bitrix24.com/v1/tasks/4207/results/first" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

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

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/4207/results/first', {
  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` if the request succeeded |
| `data` | object | Wrapper with the result ID |
| `data.result` | number | ID of the task's first result, or `0` for a task without results. The result itself is in the list returned by [`GET /v1/tasks/:taskId/results`](/docs/entities/tasks/results) |

## Response example

The task has results:

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

The task has no results:

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

## Error response example

400 — `taskId` is not a positive integer:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "taskId must be a positive integer"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|----------|
| 400 | `INVALID_PARAMS` | `taskId` is not a positive integer. Message: `taskId must be a positive integer` |
| 401 | `MISSING_API_KEY` | The `X-Api-Key` header is missing |
| 401 | `TOKEN_MISSING` | The key has no Bitrix24 tokens |
| 403 | `SCOPE_DENIED` | The key has no `task` scope |
| 422 | `BITRIX_ERROR` | The employee on whose behalf the call is made cannot read the task. Message: `Access denied.` |
| 429 | `RATE_LIMITED` | Request rate exceeded. The effective cap is in the `x-ratelimit-limit` header |

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

## Known specifics

**The response does not distinguish a task without results from a task that does not exist.** For a request with a nonexistent `taskId`, a Bitrix24 account administrator's key gets `200` with `"result": 0`. To check that the task exists, use [`GET /v1/tasks/:id`](/docs/entities/tasks/get).

## See also

- [Task results: legacy REST](/docs/entities/tasks/results)
- [Get the ID of the last task result](/docs/entities/tasks/results-last)
- [Create a task result from a comment](/docs/entities/tasks/results-from-comment)
- [Task results: REST 3.0](/docs/entities/tasks/results-v3)
- [Tasks](/docs/entities/tasks)
