# Send message

Sends a message.

```http
POST https://api.pozy.ai/v1/inbox/conversations/{conversationId}/messages
```

- Area: Inbox / Messages
- Auth: Authorization: Bearer pz_live_...

## Path parameters

- `conversationId` (string, required)

## Header parameters

- `Idempotency-Key` (string)

## Request body

Content type: `application/json`

- `accountId`, string, required
- `message`, string
- `attachmentUrl`, string
- `category`, string: One of `utility`
- `linkPreview`, boolean: Default `true`
- `attachmentType`, string: One of `image`, `video`, `audio`, `file`
- `attachmentName`, string
- `voiceNote`, boolean
- `subject`, string: Up to 1000 characters
- `cc`, array of string (email): Up to 50 items
- `effect`, string: One of `slam`, `loud`, `gentle`, `invisibleInk`, `echo`, `spotlight`, `balloons`, `confetti`, `love`, `lasers`, `fireworks`, `shootingStar`, `celebration`
- `contactCard`, boolean
- `channel`, string: One of `imessage`, `sms`, `rcs`, `whatsapp`
- `sharedMediaId`, string: Matches `^\d+$`
- `sticker`, string: One of `like_heart`
- `quickReplies`, array of object: Up to 13 items
  - `title`, string, required: Up to 20 characters
  - `payload`, string, required
  - `imageUrl`, string
- `buttons`, array of object: Up to 3 items
  - `type`, string, required: One of `url`, `postback`, `phone`
  - `title`, string, required: Up to 20 characters
  - `url`, string
  - `payload`, string
  - `phone`, string
- `template`, object
  - `type`, string: One of `generic`
  - `imageAspectRatio`, string: One of `horizontal`, `square`
  - `elements`, array of object: Up to 10 items
    - `title`, string: Up to 80 characters
    - `subtitle`, string
    - `imageUrl`, string
    - `buttons`, array of object: Up to 3 items
      - `type`, string: One of `url`, `postback`
      - `title`, string: Up to 20 characters
      - `url`, string
      - `payload`, string
    - `name`, string
    - `language`, string
    - `components`, array of object
- `interactive`, object
  - `type`, string, required: One of `list`, `cta_url`, `flow`, `location_request_message`, `request_contact_info`, `voice_call`, `product`, `product_list`, `catalog_message`, `carousel`, `address_message`
  - `header`, object
    - `type`, string: One of `text`, `image`, `video`, `document`
    - `text`, string
    - `image`, object
      - `link`, string
    - `video`, object
      - `link`, string
    - `document`, object
      - `link`, string
  - `body`, object
    - `text`, string, required
  - `footer`, object
    - `text`, string
  - `action`, object
    - one of: Option 1
      - `button`, string, required
      - `sections`, array of object, required: At least 1 item. Up to 10 items
        - `title`, string
        - `rows`, array of object, required: At least 1 item. Up to 10 items
          - `id`, string, required
          - `title`, string, required
          - `description`, string
    - one of: Option 2
      - `name`, string, required: One of `cta_url`
      - `parameters`, object, required
        - `display_text`, string, required
        - `url`, string (URL), required
    - one of: Option 3
      - `name`, string, required: One of `voice_call`
      - `parameters`, object
        - `display_text`, string: Up to 20 characters
        - `ttl_minutes`, integer: 1 to 43200
        - `payload`, string: Up to 512 characters
    - one of: Option 4
      - `name`, string, required: One of `flow`
      - `parameters`, object, required
        - `flow_message_version`, string: One of `3`
        - `flow_token`, string, required
        - `flow_id`, string, required
        - `flow_cta`, string, required
        - `flow_action`, string, required: One of `navigate`, `data_exchange`
        - `flow_action_payload`, object
          - `screen`, string
          - `data`, object
        - `mode`, string: One of `draft`
    - one of: Option 5
      - `name`, string, required: One of `send_location`
    - one of: Option 6
      - `name`, string, required: One of `request_contact_info`
    - one of: Option 7
      - `catalog_id`, string, required
      - `product_retailer_id`, string, required
    - one of: Option 8
      - `catalog_id`, string, required
      - `sections`, array of object, required: At least 1 item. Up to 10 items
        - `title`, string
        - `product_items`, array of object, required: At least 1 item
          - `product_retailer_id`, string, required
    - one of: Option 9
      - `name`, string, required: One of `catalog_message`
      - `parameters`, object
        - `thumbnail_product_retailer_id`, string
    - one of: Option 10
      - `cards`, array of object, required: At least 2 items. Up to 10 items
        - `card_index`, integer: 0 to 9
        - `type`, string
        - `header`, object
        - `body`, object
        - `action`, object
    - one of: Option 11
      - `name`, string, required: One of `address_message`
      - `parameters`, object, required
        - `country`, string, required
        - `values`, object
        - `saved_addresses`, array of object
        - `validation_errors`, map of string
- `replyMarkup`, object
  - `type`, string: One of `inline_keyboard`, `reply_keyboard`
  - `keyboard`, array of array of object
  - `oneTime`, boolean: Default `true`
- `messagingType`, string: One of `RESPONSE`, `UPDATE`, `MESSAGE_TAG`
- `messageTag`, string: One of `CONFIRMED_EVENT_UPDATE`, `POST_PURCHASE_UPDATE`, `ACCOUNT_UPDATE`, `HUMAN_AGENT`
- `replyTo`, string
- `location`, object
  - `latitude`, number, required
  - `longitude`, number, required
  - `name`, string
  - `address`, string
- `contacts`, array of object
  - `name`, object, required
    - `formatted_name`, string, required
    - `first_name`, string
    - `last_name`, string
  - `phones`, array of object
    - `phone`, string
    - `type`, string
  - `emails`, array of object
    - `email`, string
    - `type`, string

## Example request

```bash
curl -X POST "https://api.pozy.ai/v1/inbox/conversations/6e525f3820fc636aa96d2ee9/messages" \
  -H "Authorization: Bearer $POZY_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "accountId": "696e0b682d0a31188e7a2ba9"
}'
```

```ts
import { randomUUID } from "node:crypto";

const res = await fetch("https://api.pozy.ai/v1/inbox/conversations/6e525f3820fc636aa96d2ee9/messages", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POZY_API_KEY}`,
    "Idempotency-Key": randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    accountId: "696e0b682d0a31188e7a2ba9"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.post(
    "https://api.pozy.ai/v1/inbox/conversations/6e525f3820fc636aa96d2ee9/messages",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    json={
        "accountId": "696e0b682d0a31188e7a2ba9",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `success`, boolean
- `warnings`, array of object
  - `code`, string, required: One of `ignored_field`
  - `param`, string, required: One of `replyTo`
  - `message`, string, required
- `data`, object
  - `messageId`, string
  - `conversationId`, string
  - `attachments`, array of object
    - `type`, string
    - `url`, string
  - `messageIds`, array of string
  - `partialFailure`, object
    - `part`, string: One of `text`
    - `error`, string
    - `platformError`, object
      - `code`, integer
      - `subcode`, integer
      - `fbtraceId`, string
      - `type`, string

```json
{
  "success": true,
  "warnings": [
    {
      "code": "ignored_field",
      "param": "replyTo",
      "message": "Hello from Pozy"
    }
  ],
  "data": {
    "messageId": "62d191e7089bc48b8ea56b35",
    "conversationId": "6e525f3820fc636aa96d2ee9",
    "attachments": [
      {
        "type": "string",
        "url": "https://pozy.ai/media/example-1.jpg"
      }
    ],
    "messageIds": [
      "Hello from Pozy"
    ],
    "partialFailure": {
      "part": "text",
      "error": "string",
      "platformError": {
        "code": 1,
        "subcode": 1,
        "fbtraceId": "683a6bd99e02a3ca186c487f",
        "type": "string"
      }
    }
  }
}
```
