> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Post a message to a thread

> Same streaming contract as /api/chat when stream is true.

Same streaming contract as `/api/chat` when `stream` is true.

### Path parameters

**id** `string` *required*

Thread id

### Request body

`ThreadMessage`

**message** `string` *required*

**stream** `boolean`

**provider** `string`

### Response

`ChatResponse`

**ok** `boolean` *required*

**reply** `string` *required*

The assistant reply, rendered as markdown

**threadId** `string`

**suggestions** `string[]`

**provider** `string`

**model** `string`

**toolCalls** `object[]`

**sources** `object[]`

**sources**

**title** `string`

**url** `string`

**outcomes** `Outcome[]`

**Outcome**

**name** `string`

e.g. `order.cancelled`, `cart.added`, `checkout.started`, `purchase.completed`

**resourceType** `string`

**resourceId** `string`

**quantity** `number`

**amount** `number`

Minor units

**revenue** `number`

Minor units

**currency** `string`

**type** `string`

Rich message type: `product_cards` or `order_cards`

**content** `object`

Payload for the rich message type

**content**

**headline** `string`

**products** `object[]`

**products**

**id** `string`

**title** `string`

**price** `string`

**orders** `object[]`

### Status codes

| Code | Meaning |
| - | - |
| `200` | OK |
| `400` | Error |
| `401` | Error |

```bash cURL theme={null}
curl --request POST \
  --url 'https://api.example.com/api/threads/{id}/messages' \
  --header 'x-widget-token: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "message": "Two-person tent, green — replacement for damaged pole set.",
  "stream": true,
  "provider": "string"
}'
```

```json 200 theme={null}
{
  "ok": true,
  "reply": "string",
  "threadId": "string",
  "suggestions": [
    "string"
  ],
  "provider": "string",
  "model": "string",
  "toolCalls": [
    {}
  ],
  "sources": [
    {
      "title": "Replacement tent pole set",
      "url": "https://example.com/webhooks/stateset"
    }
  ],
  "outcomes": [
    {
      "name": "Two-Person Tent",
      "resourceType": "string",
      "resourceId": "string",
      "quantity": 2,
      "amount": 49,
      "revenue": 49,
      "currency": "USD"
    }
  ],
  "type": "standard",
  "content": {
    "headline": "Replacement tent pole set",
    "products": [
      {
        "id": null,
        "title": null,
        "price": null
      }
    ],
    "orders": [
      {}
    ]
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.