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

# Create Chat

> Creates a new chat session for a workflow or other resource. The chat ID is required when running workflows via the API.

Creates a new chat session. A chat is required before running a workflow via the API — the chat ID is passed to `POST /workflow-requests/run`.

## Usage

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://app.splox.io/api/v1/chats \
    -H "Authorization: Bearer YOUR_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "My Chat Session",
      "resource_type": "api",
      "resource_id": "0199e001-a23b-7c8d-1234-567890abcdef"
    }'
  ```

  ```python Python theme={null}
  from splox import SploxClient

  client = SploxClient(api_key="YOUR_API_KEY")
  chat = client.chats.create(
      name="My Chat Session",
      resource_id="0199e001-a23b-7c8d-1234-567890abcdef",
  )
  print(chat.id)
  ```

  ```typescript Node.js theme={null}
  import Splox from "splox";

  const client = new Splox("YOUR_API_KEY");
  const chat = await client.chats.create({
    name: "My Chat Session",
    resource_id: "0199e001-a23b-7c8d-1234-567890abcdef",
  });
  console.log(chat.id);
  ```

  ```go Go theme={null}
  client := splox.NewClient("YOUR_API_KEY")
  chat, err := client.Chats.Create(ctx, splox.CreateChatParams{
      Name:       "My Chat Session",
      ResourceID: "0199e001-a23b-7c8d-1234-567890abcdef",
  })
  fmt.Println(chat.ID)
  ```
</CodeGroup>

## Request Body

| Field           | Type   | Required | Description                                      |
| --------------- | ------ | -------- | ------------------------------------------------ |
| `name`          | string | Yes      | Display name for the chat session                |
| `resource_type` | string | Yes      | Must be `api`                                    |
| `resource_id`   | string | Yes      | ID of the resource (workflow ID, agent ID, etc.) |
| `metadata`      | object | No       | Optional metadata                                |

## Response

```json theme={null}
{
  "id": "0199f200-a11b-7c8d-4444-888890abcdef",
  "name": "My Chat Session",
  "user_id": "0199d001-c45d-9e0f-3456-789012cdef01",
  "resource_type": "workflow",
  "resource_id": "0199e001-a23b-7c8d-1234-567890abcdef",
  "is_public": false,
  "created_at": "2025-10-22T10:00:00Z",
  "updated_at": "2025-10-22T10:00:00Z"
}
```

## Notes

<Info>
  **Authentication required:** The chat is automatically associated with the authenticated user.
</Info>


## OpenAPI

````yaml POST /chats
openapi: 3.1.0
info:
  title: Splox API
  description: >-
    Run workflows, manage chats, receive events, and monitor execution via the
    Splox API
  version: 1.0.0
  contact:
    name: Splox Support
    email: support@splox.io
    url: https://community.splox.io
servers:
  - url: https://app.splox.io/api/v1
    description: Production API
security: []
tags:
  - name: MCP
    description: Discover MCP servers, manage connections, and execute MCP tools
  - name: Workflows
    description: List, get, and inspect workflows, versions, and nodes
  - name: Workflow Requests
    description: Run workflows, monitor execution, and retrieve results
  - name: Events
    description: Receive external events via Event Hub webhooks
  - name: Chats
    description: Manage chat sessions for workflow interactions
paths:
  /chats:
    post:
      tags:
        - Chats
      summary: Create Chat
      description: >-
        Creates a new chat session for a workflow or other resource. The chat ID
        is required when running workflows via the API.
      operationId: createChat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
                - resource_type
                - resource_id
              properties:
                name:
                  type: string
                  description: Display name for the chat session
                resource_type:
                  type: string
                  enum:
                    - api
                  description: Type of resource this chat is associated with
                resource_id:
                  type: string
                  description: ID of the resource (workflow ID, agent ID, etc.)
                metadata:
                  type: object
                  additionalProperties: true
                  description: Optional metadata for the chat
            example:
              name: Support Chat
              resource_type: api
              resource_id: 0199e001-a23b-7c8d-1234-567890abcdef
      responses:
        '201':
          description: Chat created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Chat'
      security:
        - bearerAuth: []
components:
  schemas:
    Chat:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        user_id:
          type: string
          format: uuid
        resource_type:
          type: string
          enum:
            - api
            - workflow
            - agent
            - gui
        resource_id:
          type: string
        is_public:
          type: boolean
        public_share_token:
          type: string
          nullable: true
        metadata:
          type: object
          additionalProperties: true
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token generated from your Splox account settings. Create tokens at
        https://app.splox.io/account?tab=settings

````