Moonborn — API · chat
End a chat session (idempotent) preserving its history
POST/v1/chat/sessions/{id}/endscope · Bearer (API key or session JWT)
Path parameters
| Field | Type | Description |
|---|---|---|
| idreq | string | Chat session id (e.g. `chs_*`). |
Responses
200OK
Body
| Field | Type | Description |
|---|---|---|
| sessionreq | object | |
| session.sessionIdreq | string | |
| session.orgIdreq | string | |
| session.workspaceIdreq | string | |
| session.personaIdreq | string | |
| session.userIdreq | string | |
| session.titlereq | string | |
| session.statusreq | string · "active" | "ended" | "archived" | |
| session.messageCountreq | number | |
| session.inputTokensreq | number | |
| session.outputTokensreq | number | |
| session.costUsdMicrosreq | number | |
| session.startedAtreq | string | |
| session.lastActiveAtreq | string | |
| session.endedAtreq | string | |
| alreadyEndedreq | boolean |
401Unauthenticated
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
404Session not found
Body
| Field | Type | Description |
|---|---|---|
| errorreq | object | |
| error.codereq | string | |
| error.messagereq | string |
Examples
cURL
curl -X POST https://api.moonborn.co/v1/chat/sessions/<id>/end \ -H "Authorization: Bearer $MOONBORN_API_KEY"
TypeScript
import Moonborn from '@moonborn/sdk';
const client = new Moonborn({ apiKey: process.env.MOONBORN_API_KEY });
const result = await client.chat.endChatSession({
id: '<id>',
});Python
import os
from moonborn import Moonborn
client = Moonborn(api_key=os.environ["MOONBORN_API_KEY"])
result = client.chat.end_chat_session(
id="<id>",
)