RecoupGet a Free AuditFree Audit

API REFERENCE

Update Session Chat

On this page
PATCH/api/sessions/{sessionId}/chats/{chatId}

Applies a partial update to the chat. Body must include at least one of title or modelId and any provided value must be a non-empty string (whitespace is trimmed for title).

Authentication

x-api-key in header

BearerAuth bearer

Request

cURL
curl --request PATCH \
  --url 'https://api.recoupable.dev/api/sessions/YOUR_SESSION_ID/chats/YOUR_CHAT_ID' \
  --header 'x-api-key: YOUR_API_KEY' \
  --header 'Content-Type: application/json'

Replace the YOUR_ placeholders with your values. Required query parameters are included; optional parameters are listed below.

Parameters

Path parameters

sessionIdstringrequired

The id of the parent session.

chatIdstringrequired

The id of the chat being updated.

Request body required

application/json

titlestring

New display title for the chat. Trimmed; must be non-empty after trimming.

minLength: 1 · pattern: \S

modelIdstring

AI Gateway model identifier the chat should be configured to use. Trimmed; must be non-empty after trimming.

minLength: 1 · pattern: \S

anyOf · any 1

Required: title

anyOf · any 2

Required: modelId

Responses

200Chat updated successfully.

application/json

chatobjectrequired
Properties for chat
idstringrequired

Chat id (nanoid).

sessionIdstringrequired

Owning session id.

titlestringrequired

Display title for the chat. The initial chat created with a session is titled New chat.

modelIdstringrequired

AI Gateway model identifier the chat is configured to use (e.g. openai/gpt-5.4).

activeStreamIdstringnullable

Id of an in-flight assistant stream, if one is active.

lastAssistantMessageAtstringnullable

Timestamp of the most recent assistant message in this chat.

format: date-time

createdAtstringrequired

format: date-time

updatedAtstringrequired

format: date-time

400Invalid body — JSON parse failed, neither title nor modelId was provided, or one of them was empty.

application/json

statusstring · enumrequired

Always "error" for error responses.

Values: "error"

errorstringrequired

Human-readable error message.

401Unauthorized — invalid or missing API key / Bearer token.

application/json

statusstring · enumrequired

Always "error" for error responses.

Values: "error"

errorstringrequired

Human-readable error message.

403Forbidden — the authenticated account does not own this session.

application/json

statusstring · enumrequired

Always "error" for error responses.

Values: "error"

errorstringrequired

Human-readable error message.

404Not found — no session exists with the given id, the chat does not exist, or the chat belongs to a different session.

application/json

statusstring · enumrequired

Always "error" for error responses.

Values: "error"

errorstringrequired

Human-readable error message.

500Server error — the chat could not be updated.

application/json

statusstring · enumrequired

Always "error" for error responses.

Values: "error"

errorstringrequired

Human-readable error message.

Full specification

Download the OpenAPI file for complete schemas, constraints, and examples.

Download sessions.json
View operation source
json
{
  "summary": "Update session chat",
  "description": "Applies a partial update to the chat. Body must include at least one of `title` or `modelId` and any provided value must be a non-empty string (whitespace is trimmed for `title`).",
  "parameters": [
    {
      "name": "sessionId",
      "in": "path",
      "required": true,
      "description": "The id of the parent session.",
      "schema": {
        "type": "string"
      }
    },
    {
      "name": "chatId",
      "in": "path",
      "required": true,
      "description": "The id of the chat being updated.",
      "schema": {
        "type": "string"
      }
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/UpdateSessionChatRequest"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Chat updated successfully.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/UpdateSessionChatResponse"
          }
        }
      }
    },
    "400": {
      "description": "Invalid body — JSON parse failed, neither `title` nor `modelId` was provided, or one of them was empty.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "401": {
      "description": "Unauthorized — invalid or missing API key / Bearer token.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "403": {
      "description": "Forbidden — the authenticated account does not own this session.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "404": {
      "description": "Not found — no session exists with the given id, the chat does not exist, or the chat belongs to a different session.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "500": {
      "description": "Server error — the chat could not be updated.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  }
}