# Tasks

Tasks per calendar event

Endpoint: `https://api.bookingmood.com/v1/tasks`, supporting `GET`, `POST`, `DELETE`, `PATCH`. Authenticate with the header `Authorization: Bearer YOUR_API_KEY` (see [authentication](https://www.bookingmood.com/tr-TR/api-reference/authentication.md)).

## The task object

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `uuid` | Unique identifier. |
| `calendar_event_id` | `uuid` | Identifier of the related calendar event. References [`calendar_events.id`](https://www.bookingmood.com/tr-TR/api-reference/calendar_events.md). |
| `task_template_id` | `uuid \| null` | Identifier of the related task template. References [`task_templates.id`](https://www.bookingmood.com/tr-TR/api-reference/task_templates.md). |
| `created_at` | `timestamp with time zone` | Creation timestamp. Read-only: set by the database. |
| `updated_at` | `timestamp with time zone` | Last modification timestamp. Read-only: set by the database. |
| `completed_at` | `timestamp with time zone \| null` | Timestamp at which the task was completed. |
| `due_at` | `timestamp with time zone` | Timestamp at which the task is due. |
| `fts` | `tsvector` | Read-only: set by the database. |
| `label` | `text` | Label of the task. |
| `notification_sent_at` | `timestamp with time zone \| null` | Timestamp at which the last notification was sent. |
| `schedule` | `TaskSchedule` | Schedule of the task relative to the event. |

```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "calendar_event_id": "00000000-0000-0000-0000-000000000000",
  "task_template_id": "00000000-0000-0000-0000-000000000000",
  "created_at": "2026-10-30T23:18:45.588Z",
  "updated_at": "2026-10-30T23:18:45.588Z",
  "completed_at": "2026-10-30T23:18:45.588Z",
  "due_at": "2026-10-30T23:18:45.588Z",
  "label": "Summer cottage",
  "notification_sent_at": "2026-10-30T23:18:45.588Z",
  "schedule": "arrival"
}
```

### Types

```typescript
type TaskSchedule = "manual" | "arrival" | "departure";
```

### Related resources

Embed related resources with the [`select` parameter](https://www.bookingmood.com/tr-TR/api-reference/selecting.md), e.g. `select=*,calendar_events(*)`. Resources related through more than one column need the column as a hint, like `table!column(*)`.

| Embed | Type | Description |
| --- | --- | --- |
| `calendar_events(*)` | `object \| null` | The [calendar event](https://www.bookingmood.com/tr-TR/api-reference/calendar_events.md) referenced by `calendar_event_id`. |
| `task_templates(*)` | `object \| null` | The [task template](https://www.bookingmood.com/tr-TR/api-reference/task_templates.md) referenced by `task_template_id`. |
| `task_assignees(*)` | `array` | The [task assignees](https://www.bookingmood.com/tr-TR/api-reference/task_assignees.md) referencing this task through `task_assignees.task_id`. |

## List tasks

`GET /v1/tasks`

Filter on any attribute with `column=operator.value` (see [filtering](https://www.bookingmood.com/tr-TR/api-reference/filtering.md)). Choose columns and embed related resources with `select` (see [selecting](https://www.bookingmood.com/tr-TR/api-reference/selecting.md)), and sort and paginate with `order`, `limit` and `offset` (see [sorting and pagination](https://www.bookingmood.com/tr-TR/api-reference/sorting-pagination.md)).

```bash
curl -X GET "https://api.bookingmood.com/v1/tasks?select=*&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Responses:

- `200`: A list of tasks with the selected columns. `206` when the list is a partial range.
- `400`: The request is malformed, for example an unknown column or an invalid filter.
- `401`: The API key is missing or invalid.

## Create tasks

`POST /v1/tasks`

Insert one task or an array of tasks. The body is a `Partial` task object, so columns with a default can be left out. Read-only attributes can't be written.

```bash
curl -X POST "https://api.bookingmood.com/v1/tasks" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "calendar_event_id": "00000000-0000-0000-0000-000000000000",
    "due_at": "2026-10-30T23:18:45.588Z",
    "label": "Summer cottage",
    "schedule": "arrival"
  }'
```

Responses:

- `201`: The newly created tasks with the selected columns.
- `400`: The request is malformed, for example an unknown column, an invalid filter or an invalid body.
- `401`: The API key is missing or invalid.
- `403`: The API key has no permission for this change, for example when writing rows of another organization.
- `409`: The change conflicts with existing data, for example a duplicate key or a reference to a row that does not exist.

## Delete tasks

`DELETE /v1/tasks`

Filter on any attribute with `column=operator.value` (see [filtering](https://www.bookingmood.com/tr-TR/api-reference/filtering.md)). Without filters, this request deletes all tasks you have access to. Always filter on at least one column, e.g. `id=eq.{id}`.

```bash
curl -X DELETE "https://api.bookingmood.com/v1/tasks?id=eq.00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Responses:

- `200`: The deleted tasks with the selected columns. `204` without a body when sending the header `Prefer: return=minimal`.
- `400`: The request is malformed, for example an unknown column or an invalid filter.
- `401`: The API key is missing or invalid.
- `403`: The API key has no permission for this change, for example when writing rows of another organization.

## Update tasks

`PATCH /v1/tasks`

Filter on any attribute with `column=operator.value` (see [filtering](https://www.bookingmood.com/tr-TR/api-reference/filtering.md)). Without filters, this request updates all tasks you have access to. Always filter on at least one column, e.g. `id=eq.{id}`. The body holds the attributes to change.

```bash
curl -X PATCH "https://api.bookingmood.com/v1/tasks?id=eq.00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "due_at": "2026-10-30T23:18:45.588Z"
  }'
```

Responses:

- `200`: The updated tasks with the selected columns. `204` without a body when sending the header `Prefer: return=minimal`.
- `400`: The request is malformed, for example an unknown column, an invalid filter or an invalid body.
- `401`: The API key is missing or invalid.
- `403`: The API key has no permission for this change, for example when writing rows of another organization.
- `409`: The change conflicts with existing data, for example a duplicate key or a reference to a row that does not exist.

Errors have a JSON body with a `code`, `message`, `details` and `hint`. See the [introduction](https://www.bookingmood.com/tr-TR/api-reference.md) for more on errors. The full API is described by the OpenAPI spec at https://api.bookingmood.com/v1/openapi.json.
