
## Add a time-tracking entry

`POST /v1/tasks/:taskId/time`

Creates a new time-tracking entry for a task. The required field is `seconds`; the comment and author are optional.

## Parameters

| Parameter | Type | Required | Description |
|----------|-----|:-----:|---------|
| `taskId` (path) | number | yes | Task ID |

## Request fields (body)

| Field | Type | Required | Description |
|------|-----|:-----:|---------|
| `seconds` | number | ★ | Duration in seconds |
| `comment` | string | | Comment for the entry. Stored in `COMMENT_TEXT` |
| `userId` | number | | Author ID. Defaults to the API-key user. Pass only existing employee IDs (`GET /v1/users`) — see "Known specifics". |
| `createdDate` | string | | Date and time of the entry. Three formats are accepted: ISO 8601 with offset `2026-07-13T14:30:00+00:00`, ISO 8601 without offset `2026-07-13T14:30:00`, and a date `2026-07-13`. Without this field the entry is dated at the moment of creation |

## Examples

### curl — personal key

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/tasks/289/time" \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "seconds": 1800,
    "comment": "Draft preparation"
  }'
```

### curl — OAuth application

```bash
curl -X POST "https://vibecode.bitrix24.com/v1/tasks/289/time" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "seconds": 1800,
    "comment": "Draft preparation"
  }'
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/289/time', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    seconds: 1800,
    comment: 'Draft preparation',
  }),
})

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

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/tasks/289/time', {
  method: 'POST',
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    seconds: 1800,
    comment: 'Draft preparation',
  }),
})

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

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data.id` | number | ID of the created entry. Use it for `GET` / `PATCH` / `DELETE` |

## Response example

HTTP 201 Created:

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

## Error response example

400 — the required `seconds` was not provided:

```json
{
  "success": false,
  "error": {
    "code": "MISSING_PARAMS",
    "message": "Required: seconds (number)"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `MISSING_PARAMS` | The `seconds` field was not provided |
| 422 | `BITRIX_ERROR` | Bitrix24 returned an error (e.g. the parent task is inaccessible) |
| 403 | `SCOPE_DENIED` | The API key lacks the `task` scope |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |

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

## Known specifics

**Bitrix24 does not validate `userId`.** The `task.elapseditem.add` method saves the entry with any `userId` — even a non-existent one — and returns `201`. But such a "ghost" entry can then no longer be read, updated, or deleted via the card methods: `GET` / `PATCH` / `DELETE /v1/tasks/:taskId/time/:itemId` return `422` (`512/TE/ITEM_NOT_FOUND_OR_NOT_ACCESSIBLE`). It stays visible only in the lists (`GET /v1/tasks/:taskId/time`, `GET /v1/task-time`) and clutters reports with no way to clean it up via the API. Pass only real employee IDs from [`GET /v1/users`](/docs/entities/users).

**The response contains only `id`, without the other fields.** Unlike creating a task or comment, this method returns only the identifier. To get the full entry with the auto-generated `MINUTES`, `SOURCE`, `CREATED_DATE`, `DATE_START`, `DATE_STOP`, call [`GET /v1/tasks/:taskId/time/:itemId`](./get.md).

## See also

- [Get an entry](./get.md) — read the entry you just created with all fields
- [List entries](./list.md) — all entries of a task
- [Update an entry](./update.md) — change the duration or comment
- [Delete an entry](./delete.md) — remove an entry
- [Tasks](/docs/entities/tasks) — parent entity
