Create Visitor Message

Send a message as a visitor through a widget. Chatway picks the contact and the conversation for you, so no conversation_id is needed.

How the contact is selected

If contact_id matches an existing contact on this widget, it takes priority and the supplied name, email and phone are ignored. If contact_id is missing or not found, Chatway looks up the contact by email, then creates a new contact if no match exists. An unknown contact_id does not itself cause an error.

In detail, Chatway checks these in order and uses the first match:

  1. contact_id: the existing contact with this ID, if it belongs to the widget in widget_id. It always takes priority over email.
  2. email: the most recent contact on the widget with this email. This is also used when contact_id is sent but not found on the widget.
  3. New contact: if nothing matches, or neither contact_id nor email is sent, a new contact is created from name, email and phone. It gets a new ID; an unknown contact_id is never reused as the ID.

When an existing contact is matched, name, email and phone are not used to update it.

Which conversation receives the message

Reusing an initialized contact

If you created the contact with POST /api/v1/contacts/initialize, send the returned contact ID as contact_id with the same widget. The message then goes to that contact instead of creating another one.

Note: this endpoint uses widget_id, while the initialize endpoint uses widgetId. The message text goes in the top-level content field.

Examples

Use data.attributes.contact.id from the response as contact_id to send more messages as the same visitor.

POST https://developers.chatway.app/api/v1/conversations

Example request

curl -X POST "https://developers.chatway.app/api/v1/conversations" \
  -H "X-API-KEY: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "widget_id": "eouqtiupanm6uvglwshy",
    "contact_id": "9b0c5fe6-35ad-459d-b6ba-4288191f84f1",
    "name": "Jane Doe",
    "email": "[email protected]",
    "phone": "+15551234567",
    "content": "Hi, I need help with my order."
}'

Request body

application/json

Responses

200

application/json

422

404

The widget does not exist or does not belong to your team.

application/json

Examples

Request body example

{
    "widget_id": "eouqtiupanm6uvglwshy",
    "contact_id": "9b0c5fe6-35ad-459d-b6ba-4288191f84f1",
    "name": "Jane Doe",
    "email": "[email protected]",
    "phone": "+15551234567",
    "content": "Hi, I need help with my order."
}

Response 200 example

{
    "data": {
        "type": "messages",
        "id": "msg-1",
        "attributes": {
            "conversation_id": "0f46c0a1-8938-40e3-b2b5-bb56f569fcab",
            "chat_contact_id": "9b0c5fe6-35ad-459d-b6ba-4288191f84f1",
            "agent": null,
            "contact": {
                "id": "9b0c5fe6-35ad-459d-b6ba-4288191f84f1",
                "name": "John Doe"
            },
            "origin": "chat",
            "content": "Hello, I need help",
            "type": "message",
            "created_at": "2026-02-04T10:30:00Z"
        }
    }
}