---
title: "Create a persisted copilot chat after the first user message"
method: POST
path: "/api/copilot/chats"
tags: ["Copilot"]
---

# Create a persisted copilot chat after the first user message

`POST /api/copilot/chats`

## Request

- Base URL: `https://api.setluca.com`
- URL: `https://api.setluca.com/api/copilot/chats`
- Auth: API key in cookie `luca.session_token`

Creates the chat once the coach has actually said something, so a panel that's opened and abandoned leaves nothing behind. The title comes from the first message and can be renamed later.

**Session-only.** This endpoint isn't on the API-key allowlist. An organization API key gets a 403 here, whatever scopes it holds.

## Headers

- `idempotency-key` string, uuid: The first-message creation identity. Reusing it recovers the same owned chat; GET performs a read-only lookup of that identity.
- `Luca-API-Version` '1'

## Request body

- CopilotChatCreate
  - `firstMessage` string, required
  - `scopeType` 'global' | 'lead' | 'campaign' | 'analytics'
  - `scopeId` string

## Response `200`

ok

- CopilotChat
  - `id` string, uuid, required
  - `title` string, required
  - `scopeType` 'global' | 'lead' | 'campaign' | 'analytics', required
  - `scopeId` string, required
  - `doId` string, required
  - `lastActiveAt` string, required
  - `createdAt` string, required

## Other responses

- `400`: bad request
- `401`: unauthorized
- `409`: conflict
- `429`: rate limited
- `500`: internal error
- `503`: service unavailable

---

[API](https://skmtc.dev/setluca/apis/luca-api.md) · [All operations](https://skmtc.dev/setluca/apis/luca-api/llms.txt) · [OpenAPI document](https://skmtc.dev/setluca/apis/luca-api/revisions/90a200e4100b?raw)
