> ## 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.

# Gorgias HTTP integration webhook (agent replies into the chat thread)

> Authenticated by the token query parameter matching GORGIAS_WEBHOOK_SECRET. In production a missing secret answers 503 webhook_not_configured…

Authenticated by the `token` query parameter matching `GORGIAS_WEBHOOK_SECRET`. In
production a missing secret answers `503 webhook_not_configured`; outside production the
gate is skipped. Public agent messages (`from_agent: true`, `public !== false`) are
appended to the earliest thread carrying the ticket id; acknowledgement messages and
messages flagged `source.extra.suppress_in_chat` are skipped.

### Request body

`GorgiasWebhookPayload`

**ticket\_id** `string,integer`

**ticket** `object`

**ticket**

**id** `string,integer`

**messages** `GorgiasMessage[]`

**GorgiasMessage**

**from\_agent** `boolean`

**public** `boolean`

**body\_text** `string`

**body\_html** `string`

**source** `object`

**source**

**extra** `object`

**message** `GorgiasMessage`

**GorgiasMessage**

**from\_agent** `boolean`

**public** `boolean`

**body\_text** `string`

**body\_html** `string`

**source** `object`

**source**

**extra** `object`

**body\_text** `string`

### Response

`object | object`

**ok** `boolean` *required*

Fixed value: `true`.

**threadId** `string` *required*

**messagesAdded** `integer` *required*

### Status codes

| Code | Meaning |
| - | - |
| `200` | Processed or skipped |
| `401` | Bad or missing `token` |
| `500` | Unhandled error |
| `503` | Production deployment without `GORGIAS_WEBHOOK_SECRET` |

### Using this contract

Read the [source OpenAPI document](https://docs.stateset.com/spec/chat-widget.json) for declared schemas and alternatives.
This page also includes documented corrections from the [spec overlays](https://github.com/stateset/docs/tree/main/spec/overlays).
Example IDs and values are illustrative; replace them with records from your workspace.

```bash cURL theme={null}
curl --silent --show-error --fail-with-body --request POST \
  --url 'https://api.example.com/api/webhooks/gorgias' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "ticket_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
  "ticket": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
  },
  "messages": [
    {
      "from_agent": true,
      "public": true,
      "body_text": "string",
      "body_html": "string",
      "source": {
        "extra": {
          "suppress_in_chat": true,
          "kind": "standard"
        }
      }
    }
  ],
  "message": {
    "from_agent": true,
    "public": true,
    "body_text": "string",
    "body_html": "string",
    "source": {
      "extra": {
        "suppress_in_chat": true,
        "kind": "standard"
      }
    }
  },
  "body_text": "string"
}'
```

```json 200 theme={null}
{
  "ok": true,
  "threadId": "string",
  "messagesAdded": 1
}
```


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