# Messages

> Conversations with creators.

Source: https://www.onlucra.com/docs/api-messages

Conversations between an account and the creators it works with. Everything an inbox needs is in the API, so you can build your own.

## Start a conversation

`POST /v1/threads` opens a direct conversation with a creator you work with, or returns the existing one. Include a first message if you like:

```ts
const { data: thread } = await lucra.threads.create({
  body: { kind: "direct", with: "crtr_06ZqNevhUeDnqxzC6VkeuQr", message: { body: "Welcome aboard!" } },
})
```

`kind: "program"` opens a program's group chat instead, with `program` set to its ID.

## Read and reply

`GET /v1/threads` lists conversations, most recently active first. `GET /v1/messages?thread=thr_…` reads one. Reply with `POST /v1/messages`:

```ts
await lucra.messages.create({ body: { thread: thread.id, body: "Loved the first cut!" } })
```

`PATCH /v1/messages/:id` edits or deletes a message you sent (send its `version`), sets a reaction like `{ "reaction": { "emoji": "🎉", "active": true } }`, or reports a message. One change per request.

## Notes

- A partner does all of this as a roster creator with `Lucra-Account: crtr_…`.
- The `message.created` [webhook](https://www.onlucra.com/docs/webhooks) tells you when a message arrives.
- Read state, muting and live updates are yours to keep in your own app: track what each of your users has seen by message ID.

## Endpoints

- `GET /v1/messages` (read, SDK `lucra.messages.list`): List messages
- `POST /v1/messages` (write, SDK `lucra.messages.create`): Send a message
- `PATCH /v1/messages/:id` (write, SDK `lucra.messages.update`): Edit or delete a message the caller sent (at its version), react to a message, or report it; one change per request
- `GET /v1/threads` (read, SDK `lucra.threads.list`): List the conversations the account (or, acting as a creator, the creator) takes part in, most recently active first
- `POST /v1/threads` (write, SDK `lucra.threads.create`): Open a direct conversation with an account or creator you work with (an account can also message any creator it finds in the marketplace), a program's group chat or a Lucra Support thread; an existing one is returned
- `GET /v1/threads/:id` (read, SDK `lucra.threads.retrieve`): Get a conversation; its messages are GET /v1/messages?thread=
