---
type: api
title: Create a conversation
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-createconversation
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-createconversation
products:
  - Kibana
---

# Create a conversation

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/security_ai_assistant/current_user/conversations`
- `POST` `/s/{space_id}/api/security_ai_assistant/current_user/conversations`

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

Create a new Security AI Assistant conversation. This endpoint allows the user to initiate a conversation with the Security AI Assistant by providing the required parameters.

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Request body

`application/json`

- `apiConfig` (object) — optional
  - `actionTypeId` (string) — required
    Action type ID
  - `connectorId` (string) — required
    Connector ID
  - `defaultSystemPromptId` (string) — optional
    Default system prompt ID
  - `model` (string) — optional
    Model
  - `provider` (enum) — optional
    Provider
    Values: `OpenAI`, `Azure OpenAI`, `Other`
- `category` (enum) — optional
  The conversation category.
  Values: `assistant`, `insights`
- `excludeFromLastConversationStorage` (boolean) — optional
  Exclude from last conversation storage.
- `id` (string) — optional
  The conversation id.
- `messages` (object[]) — optional
  The conversation messages.
  - `content` (string) — required
    Message content.
  - `isError` (boolean) — optional
    Is error message.
  - `metadata` (object) — optional
    Message metadata
    - `contentReferences` (map string to oneOf) — optional
      A union of all content reference types
  - `reader` (object) — optional
  - `refusal` (string) — optional
    Refusal reason returned by the model when content is filtered.
  - `role` (enum) — required
    Message role.
    Values: `system`, `user`, `assistant`
  - `timestamp` (string · format: nonempty · min length: 1) — required
    A string that represents a timestamp in ISO 8601 format and does not contain only whitespace characters.
  - `traceData` (object) — optional
    Trace Data
    - `traceId` (string) — optional
      Could be any string, not necessarily a UUID
    - `transactionId` (string) — optional
      Could be any string, not necessarily a UUID
- `replacements` (map string to string) — optional
  Replacements object used to anonymize/deanonymize messages
- `title` (string) — required
  The conversation title.

## Responses

#### `200`

Indicates a successful call. The conversation was created successfully.

`application/json`

- `apiConfig` (object)
  - `actionTypeId` (string)
    Action type ID
  - `connectorId` (string)
    Connector ID
  - `defaultSystemPromptId` (string)
    Default system prompt ID
  - `model` (string)
    Model
  - `provider` (enum)
    Provider
    Values: `OpenAI`, `Azure OpenAI`, `Other`
- `category` (enum)
  The conversation category.
  Values: `assistant`, `insights`
- `createdAt` (string)
  The time conversation was created.
- `excludeFromLastConversationStorage` (boolean)
  Exclude from last conversation storage.
- `id` (string · format: nonempty · min length: 1)
  A string that does not contain only whitespace characters.
- `messages` (object[])
  The conversation messages.
  Same fields as `messages`
- `namespace` (string)
  Kibana space
- `replacements` (map string to string)
  Replacements object used to anonymize/deanonymize messages
- `summary` (object)
  - `confidence` (enum)
    The conversation confidence.
    Values: `low`, `medium`, `high`
  - `content` (string)
    Summary text of the conversation over time.
  - `public` (boolean)
    Define if summary is marked as publicly available.
  - `timestamp` (string · format: nonempty · min length: 1)
    A string that represents a timestamp in ISO 8601 format and does not contain only whitespace characters.
- `timestamp` (string · format: nonempty · min length: 1)
  A string that represents a timestamp in ISO 8601 format and does not contain only whitespace characters.
- `title` (string)
  The conversation title.
- `updatedAt` (string)
  The last time conversation was updated.
- `users` (object[])
  - `id` (string)
    User id.
  - `name` (string)
    User name.
#### `400`

Generic Error. This response indicates an issue with the request, such as missing required parameters or incorrect data.

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (number)
## Code examples

#### Console

```console
POST kbn:/api/security_ai_assistant/current_user/conversations
{
  "title": "Security AI Assistant Setup"
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/security_ai_assistant/current_user/conversations" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Security AI Assistant Setup"
  }'
```

## Response examples

#### 200

```json
{
  "apiConfig": {
    "actionTypeId": "67890",
    "connectorId": "12345"
  },
  "category": "assistant",
  "createdAt": "2023-10-31T12:01:00Z",
  "excludeFromLastConversationStorage": false,
  "id": "abc123",
  "messages": [
    {
      "content": "Hello, how can I assist you today?",
      "role": "system",
      "timestamp": "2023-10-31T12:00:00Z"
    }
  ],
  "replacements": {},
  "title": "Security Discussion",
  "updatedAt": "2023-10-31T12:01:00Z",
  "users": [
    {
      "id": "user1",
      "name": "John Doe"
    }
  ]
}
```

