Agent Chat & Conversations

ReferenceUpdated June 14, 2026

Agent Chat & Conversations

Chat with the campaign AI assistant and read past conversations. The assistant answers from the campaign's knowledge base (vector store) built during campaign generation.

Chat requires the agent:write scope; reading conversations requires agent:read. All operations are scoped to the API key's workspace.

Synchronous & free. The public chat endpoint returns a single JSON reply (no streaming). It consumes no credits — abuse is controlled by per-key rate limiting. Both the user and assistant messages are persisted server-side, so they appear in conversation history.


Send a chat message

POST /api/v1/agent/chat · scope agent:write

Request body

FieldTypeRequiredDescription
messagestringYesThe user message (1–8000 chars, trimmed).
campaign_idstringYesThe campaign whose knowledge base to use. Must belong to your workspace.
conversation_idstringNoContinue an existing conversation. Omit to start a new one.

Example request

curl -X POST "https://app.machfive.io/api/v1/agent/chat" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "What social proof should I use for SaaS founders?",
    "campaign_id": "campaign-uuid"
  }'

Response (200 OK)

{
  "conversation_id": "conv_abc123",
  "message": {
    "role": "assistant",
    "content": "For SaaS founders, lead with the Client X case study ..."
  },
  "citations": [
    { "file_id": "file_123", "filename": "Social Proof Ranker.pdf" }
  ]
}
FieldTypeDescription
conversation_idstringThe conversation ID (reuse it to continue the thread).
message.rolestringAlways assistant.
message.contentstringThe assistant reply.
citations[]arrayKnowledge-base sources referenced (may be empty).
citations[].file_idstring | nullSource file identifier (may be null).
citations[].filenamestring | nullSource file name (may be null).

Error responses

StatusErrorDescription
400BAD_REQUESTEmpty message or missing campaign_id.
401UNAUTHORIZEDMissing or invalid API key.
403FORBIDDENKey missing the agent:write scope.
404NOT_FOUNDCampaign (or supplied conversation_id) not found in this workspace.
409NOT_READYThe campaign has no knowledge base yet — generate the campaign first.
429RATE_LIMITEDPer-key rate limit exceeded.

List conversations

GET /api/v1/conversations · scope agent:read

Workspace-scoped, newest activity first. Optional ?campaign_id filter.

Query parameters

ParameterTypeRequiredDescription
campaign_idstringNoOnly conversations for this campaign.
limitnumberNoMax results (default 50, max 100).
offsetnumberNoPagination offset (default 0).

Response (200 OK)

{
  "data": [
    {
      "id": "conv_abc123",
      "title": "What social proof should I use ...",
      "campaign_id": "campaign-uuid",
      "created_at": "2026-06-14T12:00:00.000Z",
      "last_message_at": "2026-06-14T12:05:00.000Z"
    }
  ],
  "has_more": false,
  "total": 1
}

Error responses

StatusErrorDescription
401UNAUTHORIZEDMissing or invalid API key.
403FORBIDDENKey missing the agent:read scope.
500INTERNAL_ERRORServer error.

Get conversation messages

GET /api/v1/conversations/:id/messages · scope agent:read

Messages for a conversation, oldest first. The conversation must belong to your workspace.

Path parameters

ParameterTypeDescription
idstringConversation ID.

Query parameters

ParameterTypeRequiredDescription
limitnumberNoMax results (default 50, max 100).
offsetnumberNoPagination offset (default 0).

Response (200 OK)

{
  "data": [
    { "role": "user", "content": "What social proof should I use?", "created_at": "2026-06-14T12:00:00.000Z" },
    { "role": "assistant", "content": "For SaaS founders, lead with ...", "created_at": "2026-06-14T12:00:01.000Z" }
  ],
  "has_more": false,
  "total": 2
}
FieldTypeDescription
data[].rolestringuser or assistant.
data[].contentstringMessage text.
data[].created_atstring | nullTimestamp (ISO 8601).

Error responses

StatusErrorDescription
401UNAUTHORIZEDMissing or invalid API key.
403FORBIDDENKey missing the agent:read scope.
404NOT_FOUNDConversation not found in this workspace.