# Create a task

`POST /v1/tasks`

Required scope: `tasks:write`

A task, optionally on a contact or company and with a due time. Recorded with source `api`.

## Header parameters

- `Idempotency-Key` (string or null, optional)

## Request body (application/json)

- `description` (string or null, optional)
- `due_at` (string (date-time) or null, optional)
- `owner_id` (string or null, optional)
- `record_id` (string or null, optional)
- `snoozed_until` (string (date-time) or null, optional)
- `status` (string, optional) Allowed values: `"needs_review"`, `"snoozed"`, `"in_progress"`, `"resolved"`. Default: `"needs_review"`.
- `title` (string, required)

## Responses

- `201`: Successful Response
- `400`: The request is not valid.
- `401`: Not signed in, or the credentials are not valid.
- `402`: The balance is too low.
- `403`: Not allowed to do this.
- `404`: Not found.
- `409`: Conflicts with the current state.
- `413`: The request body is too large.
- `415`: The content type is not supported.
- `422`: A value in the request is not valid.
- `429`: Too many requests. Wait for `Retry-After` seconds.
- `500`: Something went wrong on our side.
- `502`: A service Valeron depends on refused the request.
- `503`: A service Valeron depends on is unavailable.

## Examples

### Request

```bash title="cURL"
curl -X POST "https://api.valeron.io/v1/tasks" \
  -H "Authorization: Bearer $VALERON_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "description": "A short description.",
  "due_at": "2026-12-03T14:30:00Z",
  "owner_id": "usr_01J0ZTM2YK",
  "record_id": "tsk_01JRGDZNT1",
  "snoozed_until": "2026-12-03T14:30:00Z",
  "status": "needs_review",
  "title": "Discovery call"
}'
```

```js title="JavaScript"
const response = await fetch("https://api.valeron.io/v1/tasks", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.VALERON_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "description": "A short description.",
    "due_at": "2026-12-03T14:30:00Z",
    "owner_id": "usr_01J0ZTM2YK",
    "record_id": "tsk_01JRGDZNT1",
    "snoozed_until": "2026-12-03T14:30:00Z",
    "status": "needs_review",
    "title": "Discovery call"
  }),
});
if (!response.ok) throw new Error(`Valeron returned ${response.status}`);
const data = await response.json();
```

```python title="Python"
import os
import requests

response = requests.post(
    "https://api.valeron.io/v1/tasks",
    headers={"Authorization": f"Bearer {os.environ['VALERON_API_KEY']}"},
    json={
        "description": "A short description.",
        "due_at": "2026-12-03T14:30:00Z",
        "owner_id": "usr_01J0ZTM2YK",
        "record_id": "tsk_01JRGDZNT1",
        "snoozed_until": "2026-12-03T14:30:00Z",
        "status": "needs_review",
        "title": "Discovery call",
    },
)
response.raise_for_status()
data = response.json()
```

### Response 201

```json
{
  "created_at": "2026-12-03T14:30:00Z",
  "created_by": {
    "id": "tsk_01JMR8F4VE",
    "name": "Jordan Rivera"
  },
  "description": "A short description.",
  "due_at": "2026-12-03T14:30:00Z",
  "id": "tsk_01JMR8F4VE",
  "origin": {
    "at_seconds": 12,
    "automation_id": "aut_01J2VCPWXA",
    "kind": "meeting_booked",
    "kind_label": "example",
    "owner": "member",
    "quote": "We need this live before the end of the quarter.",
    "recording_id": "rec_01JR70S5VT",
    "run_id": "run_01JKBHGW4W",
    "step": 1
  },
  "owner": {
    "id": "tsk_01JMR8F4VE",
    "name": "Jordan Rivera"
  },
  "record": {
    "id": "tsk_01JMR8F4VE",
    "name": "Jordan Rivera",
    "object": "contacts"
  },
  "resolved_at": "2026-12-03T14:30:00Z",
  "snoozed_until": "2026-12-03T14:30:00Z",
  "source": {
    "label": "Example",
    "value": "example"
  },
  "status": {
    "label": "Example",
    "value": "example"
  },
  "title": "Discovery call",
  "updated_at": "2026-12-03T14:30:00Z"
}
```

### Response 401

```json
{
  "error": null
}
```

### Response 402

```json
{
  "error": null
}
```

### Response 403

```json
{
  "error": null
}
```

### Response 404

```json
{
  "error": null
}
```
