Skip to main content
PATCH
/
api
/
campaigns
/
ai-chat-sessions
/
{id}
Update a campaign AI chat session
curl --request PATCH \
  --url https://app.puffle.ai/api/campaigns/ai-chat-sessions/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "messages": [
    {}
  ],
  "title": "<string>",
  "draft_subject": "<string>",
  "draft_body": "<string>",
  "skeleton": {},
  "skeleton_history": [
    {}
  ],
  "draft_history": [
    {}
  ],
  "framework_version": 0,
  "generated_examples": [
    {}
  ],
  "task_status": "chat_processing"
}
'
{
  "session": {
    "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "campaign_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "node_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "title": "<string>",
    "messages": [
      {
        "role": "user",
        "content": "<string>"
      }
    ],
    "draft_subject": "<string>",
    "draft_body": "<string>",
    "skeleton": {},
    "skeleton_history": [
      {}
    ],
    "draft_history": [
      {}
    ],
    "framework_version": 0,
    "generated_examples": [
      {
        "lead_id": "<string>",
        "subject": "<string>",
        "body": "<string>"
      }
    ],
    "task_status": "chat_processing",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  }
}

Overview

Partial update of session fields. All fields are optional; the server only applies keys present in the body. Most fields are server-managed (written by /turn and /generate-examples Trigger.dev tasks) — agents typically only PATCH title or manually-edited draft_subject/draft_body.
This operation shares the URL path /api/campaigns/ai-chat-sessions/{id} with other verbs. See the sibling page for related operations on the same resource.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string<uuid>
required

AI chat session UUID

Pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$

Body

application/json

All fields are optional. Only keys present in the body are written — other fields are left untouched. The handler does NOT validate whether the session is currently running; writes during a live Trigger.dev run may race.

messages
object[]

Replace the chat transcript. Typically managed by the server via /turn; agents should rarely PATCH this directly.

title
string

Human-readable session title surfaced in the UI.

draft_subject
string

Current draft email subject. Accepts template variables.

draft_body
string

Current draft email body. Accepts template variables.

skeleton
object

Structural framework (hook, value prop, CTA, etc.). Overwriting this invalidates generated_examples.

skeleton_history
object[]

Prior skeleton versions for undo/rollback.

draft_history
object[]

Prior draft subject/body versions.

framework_version
integer

Monotonically-increasing revision counter for the skeleton.

Required range: -9007199254740991 <= x <= 9007199254740991
generated_examples
object[]

Per-lead sample emails. Usually written by the generate-email-examples Trigger.dev task — PATCH it directly only to clear or manually override.

task_status
enum<string> | null

Busy-flag for async Trigger.dev work owned by this session. null means idle — new turns or generate-examples calls can be accepted. While non-null, concurrent POSTs to /turn or /generate-examples return 409 until the task completes and clears the flag.

Available options:
chat_processing,
generating_examples

Response

Session updated. Returns the full updated row.

session
object
required

Canonical campaign AI chat session. One session drafts one email (one sequence node) through a back-and-forth chat with the framework LLM.