# Task templates

Tasks required for all bookings for a unit

Endpoint: `https://api.bookingmood.com/v1/task_templates`, 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 template object

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `uuid` | Unique identifier. |
| `product_id` | `uuid` | Identifier of the related unit. References [`products.id`](https://www.bookingmood.com/tr-TR/api-reference/products.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. |
| `label` | `text` | Label of the task. |
| `moment` | `MomentExpression` | Moment at which the task is due. |
| `status` | `CalendarEventStatus` | Whether the task only applies to confirmed events, or also to pending events. |
| `time` | `time without time zone \| null` | Time of day at which the task is scheduled. |

```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "product_id": "00000000-0000-0000-0000-000000000000",
  "created_at": "2026-10-30T23:37:06.265Z",
  "updated_at": "2026-10-30T23:37:06.265Z",
  "label": "Summer cottage",
  "moment": {},
  "status": "CONFIRMED",
  "time": null
}
```

### Types

```typescript
type CalendarEventStatus = "CONFIRMED" | "TENTATIVE" | "CANCELLED";

type MomentExpression = {
  offset: number;
  type: "check-in" | "checkout" | "confirmation" | "on-site" | "request";
};
```

### Related resources

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

| Embed | Type | Description |
| --- | --- | --- |
| `products!product_id(*)` | `object \| null` | The [product](https://www.bookingmood.com/tr-TR/api-reference/products.md) referenced by `product_id`. |
| `task_template_assignees(*)` | `array` | The [task template assignees](https://www.bookingmood.com/tr-TR/api-reference/task_template_assignees.md) referencing this task template through `task_template_assignees.task_template_id`. |
| `tasks(*)` | `array` | The [tasks](https://www.bookingmood.com/tr-TR/api-reference/tasks.md) referencing this task template through `tasks.task_template_id`. |

## List task templates

`GET /v1/task_templates`

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/task_templates?select=*&limit=10" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Responses:

- `200`: A list of task templates 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 task templates

`POST /v1/task_templates`

Insert one task template or an array of task templates. The body is a `Partial` task template 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/task_templates" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": "00000000-0000-0000-0000-000000000000",
    "label": "Summer cottage",
    "moment": {},
    "status": "CONFIRMED"
  }'
```

Responses:

- `201`: The newly created task templates 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 task templates

`DELETE /v1/task_templates`

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 task templates 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/task_templates?id=eq.00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

Responses:

- `200`: The deleted task templates 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 task templates

`PATCH /v1/task_templates`

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 task templates 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/task_templates?id=eq.00000000-0000-0000-0000-000000000000" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "label": "Summer cottage"
  }'
```

Responses:

- `200`: The updated task templates 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.
