---
title: "Create conversation"
url: https://docs.gleap.ai/en/reference/rest-api/create-conversation
method: POST
path: "/s2s/contacts/{userId}/conversations"
api: "API Reference"
tag: "S2S Contacts"
operationId: "CreateConversation"
updatedAt: "2026-11-01T18:40:15.677Z"
language: en
---

# Create conversation

`POST https://api.gleap.io/v3/s2s/contacts/{userId}/conversations`

Open a conversation for a contact, authored as the contact. Pass workflowId to start a workflow, or agentId to engage an AI agent. The contact is created on the fly if it does not exist yet.

## Authorization

- `Authorization` (header, required): `Bearer <token>`

## Path parameters

- `userId` (string, required)

## Request body (`application/json`, required)

- `title` (string)
- `message` (string, required): The customer's first message.
- `attributes` (any): Ticket attributes (data attributes); agent-only when the attribute's shared visibility is disabled.
- `source` (string): Free-form source tag, e.g. "abb-mobile".
- `type` (string): Ticket type, e.g. "BUG". One of the project's ticket types; defaults to "INQUIRY". FEATURE\_REQUEST and CRASH are not allowed.
- `tags` (string[])
- `attachments` (object[])
  - `url` (string, required)
  - `name` (string)
  - `contentType` (string)
- `workflowId` (string): Start this workflow immediately (wf\_… or bare id). Mutually exclusive with agentId.
- `agentId` (string): Engage this AI agent directly. Mutually exclusive with workflowId.

## Example request

```bash
curl --request POST \
  --url 'https://api.gleap.io/v3/s2s/contacts/{userId}/conversations' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "message": "<message>",
  "type": "BUG"
}'
```

## Responses

### 201 (`application/json`)

Created

- `id` (string, required)
- `number` (number<double>)
- `title` (string)
- `type` (string)
- `status` (string)
- `closed` (boolean, required)
- `archived` (boolean, required)
- `unread` (boolean, required)
- `rating` (number<double>): CSAT rating 0-10 given by the contact (rateconversation step or POST …/rating).
- `workflowActive` (boolean, required)
- `workflowId` (string)
- `assignee` (object | null)
  - `type` (enum<string>, required): One of: `contact`, `agent`, `bot`, `system`.
  - `id` (string)
  - `name` (string)
  - `avatar` (string)
- `attributes` (object): Construct a type with a set of properties K of type T
- `contact` (object)
  - `userId` (string)
- `latestMessage` (object)
  - `id` (string, required)
  - `conversationId` (string, required)
  - `text` (string)
  - `author` (object, required)
    - `type` (enum<string>, required): One of: `contact`, `agent`, `bot`, `system`.
    - `id` (string)
    - `name` (string)
    - `avatar` (string)
  - `attachments` (object[], required)
    - `url` (string, required)
    - `name` (string)
    - `contentType` (string)
  - `replyToMessageId` (string)
  - `rating` (string)
  - `unread` (boolean, required)
  - `createdAt` (string<date-time>, required)
- `createdAt` (string<date-time>)
- `lastActivityAt` (string<date-time>)

```json
{
  "id": "string",
  "number": 0,
  "title": "string",
  "type": "string",
  "status": "string",
  "closed": true,
  "archived": true,
  "unread": true,
  "rating": 0,
  "workflowActive": true,
  "workflowId": "string",
  "assignee": {
    "type": "contact",
    "id": "string",
    "name": "string",
    "avatar": "string"
  },
  "attributes": {},
  "contact": {
    "userId": "string"
  },
  "latestMessage": {
    "id": "string",
    "conversationId": "string",
    "text": "string",
    "author": {
      "type": "contact",
      "id": "string",
      "name": "string",
      "avatar": "string"
    },
    "attachments": [
      {
        "url": "string",
        "name": "string",
        "contentType": "string"
      }
    ],
    "replyToMessageId": "string",
    "rating": "string",
    "unread": true,
    "createdAt": "2026-01-01T12:00:00Z"
  },
  "createdAt": "2026-01-01T12:00:00Z",
  "lastActivityAt": "2026-01-01T12:00:00Z"
}
```
