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

# Create Widget

> Creates a new widget.

### Headers

<ParamField header="authorization" type="string" required>
  Your API key for authentication.
</ParamField>

### Body

<ParamField body="pathway_id" type="string">
  UUID of the pathway to associate with the widget. Must be defined if `agent_prompt` is null.
</ParamField>

<ParamField body="agent_prompt" type="string">
  Prompt to use for the widget agent. Must be defined if `pathway_id` is null.
</ParamField>

<ParamField body="allowed_domains" type="string[]" required>
  Array of domains where the widget can be embedded.
</ParamField>

<ParamField body="messages_per_minute" type="number" required>
  Rate limit for messages (minimum: 0).
</ParamField>

<ParamField body="config" type="any" required>
  Widget configuration object (flexible JSON). Supports `timeoutSeconds` to configure conversation timeout (default: 86400 seconds / 24 hours).
</ParamField>

<ParamField body="agent_id" type="string">
  Optional UUID of agent to associate with widget.
</ParamField>

<ParamField body="webhook_url" type="string">
  Optional URL to receive post-conversation webhook payloads when conversations end. See [Post-Conversation Webhooks](/tutorials/chat-widget#post-conversation-webhooks) for payload details.
</ParamField>

### Response

<ResponseField name="status" type="number">
  HTTP status code (200 for success).
</ResponseField>

<ResponseField name="data" type="object">
  The created widget object containing:

  * `id` (string): Generated widget UUID
  * `pathway_id` (string): Associated pathway UUID
  * `agent_id` (string | null): Associated agent UUID or null
  * `allowed_domains` (string\[]): Array of allowed domains
  * `messages_per_minute` (number): Rate limit for messages
  * `config` (object): Widget configuration object
  * `webhook_url` (string | null): Post-conversation webhook URL or null
  * `created_at` (string): ISO timestamp
  * `updated_at` (string): ISO timestamp
</ResponseField>

<ResponseField name="errors" type="null">
  Always null on successful response.
</ResponseField>

<ResponseExample>
  ```json Response theme={null}
  {
    "status": 200,
    "data": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "pathway_id": "a0f0d4ed-f5f5-4f16-b3f9-22166594d7a7",
      "agent_id": null,
      "allowed_domains": ["example.com", "subdomain.example.com"],
      "messages_per_minute": 10,
      "config": {
        "theme": "light",
        "position": "bottom-right",
        "timeoutSeconds": 3600
      },
      "webhook_url": "https://example.com/webhook",
      "created_at": "2024-01-15T10:30:00Z",
      "updated_at": "2024-01-15T10:30:00Z"
    },
    "errors": null
  }
  ```
</ResponseExample>

***

Docs for agents: [llms.txt](/llms.txt)
