# Messages

Emails and text messages, scheduled or sent to guests

Endpoint: `https://api.bookingmood.com/v1/messages`, supporting `GET`. Authenticate with the header `Authorization: Bearer YOUR_API_KEY` (see [authentication](https://www.bookingmood.com/ja-JP/api-reference/authentication.md)).

## The message object

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `uuid` | Unique identifier. |
| `booking_id` | `uuid` | Identifier of the related booking. References [`bookings.id`](https://www.bookingmood.com/ja-JP/api-reference/bookings.md). |
| `message_template_id` | `uuid \| null` | Identifier of the message template the message is based on. References [`message_templates.id`](https://www.bookingmood.com/ja-JP/api-reference/message_templates.md). |
| `created_at` | `timestamp with time zone` | Creation timestamp. Read-only: set by the database. |
| `attachments` | `Array<MessageAttachment> \| null` | Attachments included in the email. |
| `body` | `text` | Body of the message. |
| `html` | `text \| null` | HTML of the email. |
| `include_booking_details` | `boolean` | Whether the message includes booking details. |
| `include_booking_link` | `boolean` | Whether the message includes a link to the guest page. |
| `include_ical_data` | `boolean` | Whether the email includes an iCal attachment. |
| `include_product_image` | `boolean` | Whether the email includes an image of the unit. |
| `include_transactions` | `boolean` | Whether the message includes the booking's transactions. |
| `send_at` | `timestamp with time zone` | Timestamp at which the message is or was sent. |
| `status` | `MessageStatus` | Status of the message. |
| `subject` | `text` | Subject of the email. |
| `type` | `MessageType` | Type of the message: `email` or `sms`. |

```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "booking_id": "00000000-0000-0000-0000-000000000000",
  "message_template_id": "00000000-0000-0000-0000-000000000000",
  "created_at": "2026-10-30T23:18:45.588Z",
  "attachments": [
    {
      "filename": "file",
      "url": "https://example.com",
      "type": "application/pdf"
    }
  ],
  "body": "A short description.",
  "html": "",
  "include_booking_details": false,
  "include_booking_link": false,
  "include_ical_data": false,
  "include_product_image": false,
  "include_transactions": false,
  "send_at": "2026-10-30T23:18:45.588Z",
  "status": "sent",
  "subject": "Summer cottage",
  "type": "email"
}
```

### Types

```typescript
type MessageAttachment = {
  filename: string;
  type: string;
  url: string;
};

type MessageStatus = 
  | "manually-scheduled"
  | "scheduled-around-arrival"
  | "scheduled-around-departure"
  | "sent";

type MessageType = "email" | "sms";
```

### Related resources

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

| Embed | Type | Description |
| --- | --- | --- |
| `bookings(*)` | `object \| null` | The [booking](https://www.bookingmood.com/ja-JP/api-reference/bookings.md) referenced by `booking_id`. |
| `message_templates(*)` | `object \| null` | The [message template](https://www.bookingmood.com/ja-JP/api-reference/message_templates.md) referenced by `message_template_id`. |
| `message_events(*)` | `array` | The [message events](https://www.bookingmood.com/ja-JP/api-reference/message_events.md) referencing this message through `message_events.message_id`. |

## List messages

`GET /v1/messages`

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

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

Responses:

- `200`: A list of messages 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.

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