# Start a conversation (https://notert.io/docs/api/reference/start-a-conversation)

`POST /api/v1/conversations`

Writes first to a customer as the token's holder, by email: to a contact or to an address. It starts a conversation and emails the message at once, under a subject written from it, and what the customer writes back lands in it. An email can't be taken back, so send the same id when you send again after getting no answer: the conversation is started once.

Access: A token with conversations:write.

## Headers

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | string | No | A key of your own for this call, such as a UUID, sent again with a call made again after its answer was lost, so it stores and sends once and answers what the first stored. The same key with other words names another record. Send it or an id in the body, not both. At least 1 character. At most 255 characters. |

## Body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | uuid | No | An id of your own, a UUID, so a call sent again after its answer was lost answers the conversation already started rather than starting and emailing a second. Or send an Idempotency-Key header instead, not both. |
| `customerId` | string | No | The customer to write to, by their c_ id from the people endpoints. Leave it out to write to an email. |
| `email` | string | No | The address to write to, in place of a customerId: the contact who has it, or a new one. At most 254 characters. |
| `body` | string | Yes | The first message, as plain text, which the customer reads by email and in the conversation. At least 1 character. At most 5000 characters. |
| `pictureUrls` | uri[] | No | Public https addresses of pictures to send with the first message (JPEG, PNG, GIF or WebP, of no more pixels than 3840 x 2160, up to 10 MB each), at most 10 and the plan's count, which the server fetches from the open web. One that can't be fetched, isn't a picture or is too large is PICTURE_REFUSED, and nothing is sent. Default []. |

## Response 201

| Field | Type | Description |
| --- | --- | --- |
| `id` | string | The new conversation's id. |
| `customerId` | string or null | The customer it was written to, as the people endpoints name them: the contact named, or the one who has the email, added if there was none. Null only for a contact deleted since, on a call sent again. |

## Errors

| Status | Code | Message |
| --- | --- | --- |
| 400 | `BAD_REQUEST` | Input validation failed. |
| 400 | `IDEMPOTENCY_KEY_REFUSED` | Send an Idempotency-Key of 1 to 255 visible characters, or an id of your own in the body, not both. |
| 401 | `UNAUTHORIZED` | Send a valid API token as a Bearer token. |
| 403 | `BANNED` | The workspace banned that person, so nothing is written for them. |
| 403 | `HOLDER_NOT_ALLOWED` | The teammate who holds this API token's secret can't do this in the workspace now. A teammate who can should roll it in the workspace's settings. |
| 403 | `INSUFFICIENT_SCOPE` | This API token can't reply to or organize conversations. Create one that may in the workspace's settings. |
| 403 | `NETWORK_NOT_ALLOWED` | This API token works only from the networks it was made for. Call from one of them, or create a token for this one in the workspace's settings. |
| 403 | `NO_EMAIL` | That contact has no email address to write to. Name an address in email instead. |
| 403 | `NO_SEAT` | This workspace's plan has no seat for you. |
| 403 | `UNSUBSCRIBED` | That person asked not to be emailed, so they can't be written to. |
| 403 | `WORKSPACE_SUSPENDED` | This workspace is suspended. |
| 404 | `NOT_FOUND` | Not Found. |
| 409 | `BLOCKED` | The team blocked that sender, so they can't be written to. |
| 409 | `BOUNCED` | Emails to that address bounce, so it can't be written to. |
| 409 | `CHANGED_MEANWHILE` | Something changed meanwhile. Try again. |
| 409 | `OWN_ADDRESS` | That is the workspace's own address, so it can't be written to. |
| 409 | `TOO_MANY_FILES` | That is more files than the workspace's plan takes. Its data holds `limit`. |
| 409 | `UNAVAILABLE` | This workspace can't start conversations by email yet. |
| 422 | `PICTURE_REFUSED` | A picture in pictureUrls couldn't be attached, so nothing was written. data.url names it and data.reason says why. Its data holds `url`, `reason`. |
| 429 | `TOO_MANY_REQUESTS` | Too Many Requests. Its data holds `retryAfter`. |

## Example request

```sh
curl -X POST https://app.notert.io/api/v1/conversations \
  -H "Authorization: Bearer $NOTERT_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "id": "3b7e2a90-5c1d-4f8e-9a6b-1d2c3e4f5a60",
  "customerId": "c_e1a5c9d3-7b2f-4e8a-b6c4-0d2f4a6c8e13",
  "email": "ingrid@example.com",
  "body": "The CSV export you asked for shipped today.",
  "pictureUrls": [
    "https://example.com/shots/export.png"
  ]
}'
```

## Example response 201

```json
{
  "id": "3b7e2a90-5c1d-4f8e-9a6b-1d2c3e4f5a60",
  "customerId": "c_e1a5c9d3-7b2f-4e8a-b6c4-0d2f4a6c8e13"
}
```
