Agents

Read your agents and their settings, change them, check them and publish. Paths say `assistants`, the older name for agents. Requires `agents:read` to read and `agents:write` to change. Linking WhatsApp and the agent preview chat stay in the dashboard.

List agents
GET /assistants
Create an agent
POST /assistants
Get an agent
GET /assistants/{id}
Update an agent
PATCH /assistants/{id}
Delete an agent
DEL /assistants/{id}
Preview an agent's instructions
GET /assistants/{id}/prompt-preview
Publish an agent
POST /assistants/{id}/publish
Check an agent's tools
POST /assistants/{id}/validate

The Agent object

Returned by the agents endpoints.

Attributes
codeenum
—SUCCESS
messagestring
—
The Agent object
{
  "code": "SUCCESS",
  "message": "deleted"
}

List agents

GET https://api.trycareflow.com/assistants

Requires `agents:read`. Returns every agent in the API key's workspace, in no particular order and without paging. Draft and unpublished agents are included; check `status`. `assistants` is `null`, not an empty list, when the workspace has no agents.

curl https://api.trycareflow.com/assistants \
  -H "Authorization: Bearer sk_live_••••"
const Agent = await careflow.agents.list()
Response
{
  "code": "SUCCESS",
  "message": "ok",
  "data": {
    "assistants": [
      {
        "_id": "66f1c2a9e4b0f1a2b3c4d5e6",
        "createdAt": "2026-03-02T09:14:00Z",
        "updatedAt": "2026-10-06T08:30:12Z",
        "businessId": "66f1c2a9e4b0f1a2b3c4d5a1",
        "name": "Harbourview front desk",
        "status": "published",
        "firstMessage": "Thanks for calling Harbourview Hotel, how can I help you today?",
        "toolIds": [
          "66f1c2a9e4b0f1a2b3c4d5f0"
        ],
        "whatsApp": {
          "phoneNumberId": "",
          "verifyToken": ""
        },
        "pipelineMode": "modular",
        "voiceConfig": {
          "sttProvider": "deepgram",
          "llmProvider": "openrouter",
          "voiceKey": "charlotte",
          "temperature": 0.6,
          "speed": 1
        },
        "promptMode": "structured",
        "compiledPrompt": "You are the front desk assistant for Harbourview Hotel...",
        "role": "service",
        "language": "en-GB",
        "tone": "warm_friendly",
        "greeting": "Good morning, Harbourview Hotel.",
        "signOff": "Enjoy your stay.",
        "alwaysSay": [
          "Breakfast is served from 7am to 10:30am."
        ],
        "neverSay": [
          "Room rates for other hotels"
        ],
        "useFillers": true,
        "interruptionHandling": "finish_sentence",
        "speakingPace": "normal",
        "timezone": "Europe/London",
        "activeHours": {
          "mon": {
            "start": "07:00",
            "end": "22:00"
          },
          "tue": {
            "start": "07:00",
            "end": "22:00"
          },
          "wed": {
            "start": "07:00",
            "end": "22:00"
          },
          "thu": {
            "start": "07:00",
            "end": "22:00"
          },
          "fri": {
            "start": "07:00",
            "end": "23:00"
          },
          "sat": {
            "start": "08:00",
            "end": "23:00"
          }
        },
        "outOfHoursBehavior": "take_message",
        "handoffs": [
          {
            "routineId": "66f1c2a9e4b0f1a2b3c4d5b7",
            "triggers": [
              "speak to a manager"
            ]
          }
        ],
        "recogniseReturning": true,
        "systemTools": {
          "knowledgeBase": true,
          "webSearch": true,
          "end": true
        }
      }
    ]
  }
}
{
  "code": "ERROR",
  "message": "invalid businessId in token",
  "error": "the parse error"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "failed",
  "error": "the database error"
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}

Create an agent

POST https://api.trycareflow.com/assistants

Requires `agents:write`. Creates an agent in the API key's workspace. The new agent is `inactive`: it doesn't answer calls, the web widget or WhatsApp until you publish it. In `structured` mode (the default) send `role`, `tone` and `language`; the agent's instructions are built from them. If you don't send `voiceConfig`, the agent gets the platform voice defaults and a recommended voice. If you do, it replaces those defaults, so include `temperature` and `speed` if you care about them.

Parameters
namestringrequired
The agent's name, as shown in the dashboard.
firstMessagestringrequired
What the agent says first when a call or chat starts. 10 to 500 characters.
promptModeenumoptional
`structured` builds the agent's instructions from the persona fields (`role`, `tone`, `greeting`, hours and so on). `advanced` uses `behaviorPrompt` (or `systemPrompt`) as written.structuredadvanced
systemPromptstringoptional
Full instructions, used in `advanced` mode when `behaviorPrompt` is empty.
behaviorPromptstringoptional
Your own instructions for the agent, used in `advanced` mode.
roleenumoptional
What kind of job the agent does. Sets the "who I am" part of its instructions.salesserviceecommerceschedulingcustom
languagestringoptional
The language the agent speaks, as a language tag.
tonestringoptional
How the agent speaks: `warm_friendly`, `professional`, `casual` or `empathetic`. Other values fall back to a neutral tone.
greetingstringoptional
An exact opening line for the agent to use.
signOffstringoptional
The closing phrase the agent uses.
alwaysSayarray<string>optional
Things the agent should always mention when relevant.
neverSayarray<string>optional
Topics the agent must avoid.
useFillersbooleanoptional
On calls, use short fillers such as "let me check" while it works.
interruptionHandlingstringoptional
On calls, what the agent does when the caller talks over it: `stop_immediately`, `finish_sentence` or `ignore`.
speakingPacestringoptional
On calls, `slow`, `normal` or `fast`.
timezonestringoptional
IANA time zone the opening hours are in, such as `Europe/London`. Needed for `activeHours` to apply. It isn't checked: an unknown zone makes the agent count as closed all the time.
activeHoursobjectoptional
The agent's weekly opening hours, one entry per weekday. A day that is missing (or `null`) is closed. When you send this object it replaces the whole schedule, so include every day that should be open. Hours only take effect when the agent also has a `timezone`. With no `timezone`, or no `activeHours` at all, the agent counts as always open. An unknown `timezone` makes the agent count as closed all the time. Hours don't stop calls or messages from reaching the agent. They tell the agent whether the business is open right now and what to do out of hours (see `outOfHoursBehavior`), and they're checked each time a conversation starts.
outOfHoursBehaviorstringoptional
What the agent does when someone gets in touch while closed: `take_message`, `play_hours` (tell them when you next open) or `voicemail`.
recogniseReturningbooleanoptional
Recognise people who have been in touch before.
crossSessionMemorybooleanoptional
Remember what returning people said in earlier conversations.
toolIdsarray<string>optional
IDs of the tools the agent can use. Only live tools are offered to it.
workflowIdsarray<string>optional
IDs of workflows the agent can start.
pipelineModestringoptional
Voice pipeline. `modular` is the default for every agent; leave it alone.
voiceConfigobjectoptional
How the agent sounds and listens on calls. New agents get platform defaults (Deepgram speech recognition, the platform model, temperature 0.6, speed 1, and a recommended voice picked at random). Other fields may appear on older agents.
curl https://api.trycareflow.com/assistants \
  -H "Authorization: Bearer sk_live_••••" \
  -d name=Harbourview front desk \
  -d firstMessage=Thanks for calling Harbourview Hotel, how can I help you today? \
  -d promptMode=structured \
  -d systemPrompt=value
const Agent = await careflow.agents.create({
  name: 'Harbourview front desk',
  firstMessage: 'Thanks for calling Harbourview Hotel, how can I help you today?',
  promptMode: 'structured',
  systemPrompt: 'value',
})
Response
{
  "code": "SUCCESS",
  "message": "created",
  "data": {
    "assistant": {
      "_id": "66f1c2a9e4b0f1a2b3c4d5e6",
      "createdAt": "2026-03-02T09:14:00Z",
      "updatedAt": "2026-03-02T09:14:00Z",
      "businessId": "66f1c2a9e4b0f1a2b3c4d5a1",
      "name": "Harbourview front desk",
      "status": "inactive",
      "firstMessage": "Thanks for calling Harbourview Hotel, how can I help you today?",
      "toolIds": [
        "66f1c2a9e4b0f1a2b3c4d5f0"
      ],
      "whatsApp": {
        "phoneNumberId": "",
        "verifyToken": ""
      },
      "pipelineMode": "modular",
      "voiceConfig": {
        "sttProvider": "deepgram",
        "llmProvider": "openrouter",
        "voiceKey": "charlotte",
        "temperature": 0.6,
        "speed": 1
      },
      "promptMode": "structured",
      "compiledPrompt": "You are the front desk assistant for Harbourview Hotel...",
      "role": "service",
      "language": "en-GB",
      "tone": "warm_friendly",
      "greeting": "Good morning, Harbourview Hotel.",
      "signOff": "Enjoy your stay.",
      "alwaysSay": [
        "Breakfast is served from 7am to 10:30am."
      ],
      "neverSay": [
        "Room rates for other hotels"
      ],
      "useFillers": true,
      "interruptionHandling": "finish_sentence",
      "speakingPace": "normal",
      "timezone": "Europe/London",
      "activeHours": {
        "mon": {
          "start": "07:00",
          "end": "22:00"
        },
        "tue": {
          "start": "07:00",
          "end": "22:00"
        },
        "wed": {
          "start": "07:00",
          "end": "22:00"
        },
        "thu": {
          "start": "07:00",
          "end": "22:00"
        },
        "fri": {
          "start": "07:00",
          "end": "23:00"
        },
        "sat": {
          "start": "08:00",
          "end": "23:00"
        }
      },
      "outOfHoursBehavior": "take_message",
      "handoffs": [
        {
          "routineId": "66f1c2a9e4b0f1a2b3c4d5b7",
          "triggers": [
            "speak to a manager"
          ]
        }
      ],
      "recogniseReturning": true,
      "systemTools": {
        "knowledgeBase": true,
        "webSearch": true,
        "end": true
      }
    }
  }
}
{
  "code": "ERROR",
  "message": "validation failed",
  "error": "invalid_payload (with `details`)"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "failed to create",
  "error": "the database error"
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}

Get an agent

GET https://api.trycareflow.com/assistants/{id}

Requires `agents:read`. Returns one agent from the API key's workspace.

Path parameters
idstringrequired
The agent's ID, a 24-character hex string.
curl https://api.trycareflow.com/assistants/value \
  -H "Authorization: Bearer sk_live_••••"
const Agent = await careflow.agents.retrieve('value')
Response
{
  "code": "SUCCESS",
  "message": "ok",
  "data": {
    "assistant": {
      "_id": "66f1c2a9e4b0f1a2b3c4d5e6",
      "createdAt": "2026-03-02T09:14:00Z",
      "updatedAt": "2026-10-06T08:30:12Z",
      "businessId": "66f1c2a9e4b0f1a2b3c4d5a1",
      "name": "Harbourview front desk",
      "status": "published",
      "firstMessage": "Thanks for calling Harbourview Hotel, how can I help you today?",
      "toolIds": [
        "66f1c2a9e4b0f1a2b3c4d5f0"
      ],
      "whatsApp": {
        "phoneNumberId": "",
        "verifyToken": ""
      },
      "pipelineMode": "modular",
      "voiceConfig": {
        "sttProvider": "deepgram",
        "llmProvider": "openrouter",
        "voiceKey": "charlotte",
        "temperature": 0.6,
        "speed": 1
      },
      "promptMode": "structured",
      "compiledPrompt": "You are the front desk assistant for Harbourview Hotel...",
      "role": "service",
      "language": "en-GB",
      "tone": "warm_friendly",
      "greeting": "Good morning, Harbourview Hotel.",
      "signOff": "Enjoy your stay.",
      "alwaysSay": [
        "Breakfast is served from 7am to 10:30am."
      ],
      "neverSay": [
        "Room rates for other hotels"
      ],
      "useFillers": true,
      "interruptionHandling": "finish_sentence",
      "speakingPace": "normal",
      "timezone": "Europe/London",
      "activeHours": {
        "mon": {
          "start": "07:00",
          "end": "22:00"
        },
        "tue": {
          "start": "07:00",
          "end": "22:00"
        },
        "wed": {
          "start": "07:00",
          "end": "22:00"
        },
        "thu": {
          "start": "07:00",
          "end": "22:00"
        },
        "fri": {
          "start": "07:00",
          "end": "23:00"
        },
        "sat": {
          "start": "08:00",
          "end": "23:00"
        }
      },
      "outOfHoursBehavior": "take_message",
      "handoffs": [
        {
          "routineId": "66f1c2a9e4b0f1a2b3c4d5b7",
          "triggers": [
            "speak to a manager"
          ]
        }
      ],
      "recogniseReturning": true,
      "systemTools": {
        "knowledgeBase": true,
        "webSearch": true,
        "end": true
      }
    }
  }
}
{
  "code": "ERROR",
  "message": "invalid id",
  "error": "the parse error"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "not found",
  "error": "mongo: no documents in result"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}

Update an agent

PATCH https://api.trycareflow.com/assistants/{id}

Requires `agents:write`. Changes the fields you send and leaves the rest alone. Objects such as `activeHours`, `voiceConfig` and `systemTools` are replaced as a whole, so send the complete object. To make the agent always open, send `"alwaysOpen": true`. Changes apply straight away, including on a published agent: there's no separate draft, and you don't need to publish again. You can't clear a value here: an empty string, `false` or an empty list is ignored when saving, even though the response shows it. Unlike create, this endpoint doesn't check `firstMessage` length or `role`. The response is the agent as the handler built it, which can differ from what was stored for those ignored values. Get the agent again if you need to be sure.

Path parameters
idstringrequired
The agent's ID, a 24-character hex string.
Parameters
namestringoptional
The agent's name, as shown in the dashboard.
firstMessagestringoptional
What the agent says first when a call or chat starts. The dashboard keeps it to 10 to 500 characters; this endpoint doesn't check the length.
promptModeenumoptional
`structured` builds the agent's instructions from the persona fields (`role`, `tone`, `greeting`, hours and so on). `advanced` uses `behaviorPrompt` (or `systemPrompt`) as written.structuredadvanced
systemPromptstringoptional
Full instructions, used in `advanced` mode when `behaviorPrompt` is empty.
behaviorPromptstringoptional
Your own instructions for the agent, used in `advanced` mode.
roleenumoptional
What kind of job the agent does. This endpoint doesn't check the value, so send one of the listed values.salesserviceecommerceschedulingcustom
languagestringoptional
The language the agent speaks, as a language tag.
tonestringoptional
How the agent speaks: `warm_friendly`, `professional`, `casual` or `empathetic`. Other values fall back to a neutral tone.
greetingstringoptional
An exact opening line for the agent to use.
signOffstringoptional
The closing phrase the agent uses.
alwaysSayarray<string>optional
Things the agent should always mention when relevant.
neverSayarray<string>optional
Topics the agent must avoid.
useFillersbooleanoptional
On calls, use short fillers such as "let me check" while it works.
interruptionHandlingstringoptional
On calls, what the agent does when the caller talks over it: `stop_immediately`, `finish_sentence` or `ignore`.
speakingPacestringoptional
On calls, `slow`, `normal` or `fast`.
timezonestringoptional
IANA time zone the opening hours are in, such as `Europe/London`. Needed for `activeHours` to apply. It isn't checked: an unknown zone makes the agent count as closed all the time.
activeHoursobjectoptional
The new weekly schedule. Replaces the whole schedule: days you leave out become closed.
outOfHoursBehaviorstringoptional
What the agent does when someone gets in touch while closed: `take_message`, `play_hours` (tell them when you next open) or `voicemail`.
recogniseReturningbooleanoptional
Recognise people who have been in touch before.
crossSessionMemorybooleanoptional
Remember what returning people said in earlier conversations.
toolIdsarray<string>optional
IDs of the tools the agent can use. Only live tools are offered to it.
workflowIdsarray<string>optional
IDs of workflows the agent can start.
pipelineModestringoptional
Voice pipeline. `modular` is the default for every agent; leave it alone.
voiceConfigobjectoptional
Replaces the whole voice setup, not just the fields you send. Read the agent first and send back every field you want to keep (such as `temperature` and `speed`).
alwaysOpenbooleanoptional
Send `true` to remove the schedule so the agent is always open. It wins over `activeHours` in the same request. `false` does nothing.
handoffsarray<object>optional
Replaces the attached handoff routines. Entries with an invalid `routineId` are dropped.
systemToolsobjectoptional
Replaces all five switches; any you leave out turn off.
statusenumoptional
Takes the agent off its channels. To go live, use the publish endpoint; `published` is refused here.inactivedisabled
curl -X PATCH https://api.trycareflow.com/assistants/value \
  -H "Authorization: Bearer sk_live_••••" \
  -d name=Harbourview front desk \
  -d firstMessage=Thanks for calling Harbourview Hotel, how can I help you today? \
  -d promptMode=structured \
  -d systemPrompt=value
const Agent = await careflow.agents.update({
  name: 'Harbourview front desk',
  firstMessage: 'Thanks for calling Harbourview Hotel, how can I help you today?',
  promptMode: 'structured',
  systemPrompt: 'value',
})
Response
{
  "code": "SUCCESS",
  "message": "updated",
  "data": {
    "assistant": {
      "_id": "66f1c2a9e4b0f1a2b3c4d5e6",
      "createdAt": "2026-03-02T09:14:00Z",
      "updatedAt": "2026-10-06T08:30:12Z",
      "businessId": "66f1c2a9e4b0f1a2b3c4d5a1",
      "name": "Harbourview front desk",
      "status": "published",
      "firstMessage": "Thanks for calling Harbourview Hotel, how can I help you today?",
      "toolIds": [
        "66f1c2a9e4b0f1a2b3c4d5f0"
      ],
      "whatsApp": {
        "phoneNumberId": "",
        "verifyToken": ""
      },
      "pipelineMode": "modular",
      "voiceConfig": {
        "sttProvider": "deepgram",
        "llmProvider": "openrouter",
        "voiceKey": "charlotte",
        "temperature": 0.6,
        "speed": 1
      },
      "promptMode": "structured",
      "compiledPrompt": "You are the front desk assistant for Harbourview Hotel...",
      "role": "service",
      "language": "en-GB",
      "tone": "warm_friendly",
      "greeting": "Good morning, Harbourview Hotel.",
      "signOff": "Enjoy your stay.",
      "alwaysSay": [
        "Breakfast is served from 7am to 10:30am."
      ],
      "neverSay": [
        "Room rates for other hotels"
      ],
      "useFillers": true,
      "interruptionHandling": "finish_sentence",
      "speakingPace": "normal",
      "timezone": "Europe/London",
      "activeHours": {
        "mon": {
          "start": "07:00",
          "end": "22:00"
        },
        "tue": {
          "start": "07:00",
          "end": "22:00"
        },
        "wed": {
          "start": "07:00",
          "end": "22:00"
        },
        "thu": {
          "start": "07:00",
          "end": "22:00"
        },
        "fri": {
          "start": "07:00",
          "end": "23:00"
        },
        "sat": {
          "start": "08:00",
          "end": "23:00"
        }
      },
      "outOfHoursBehavior": "take_message",
      "handoffs": [
        {
          "routineId": "66f1c2a9e4b0f1a2b3c4d5b7",
          "triggers": [
            "speak to a manager"
          ]
        }
      ],
      "recogniseReturning": true,
      "systemTools": {
        "knowledgeBase": true,
        "webSearch": true,
        "end": true
      }
    }
  }
}
{
  "code": "ERROR",
  "message": "invalid id",
  "error": "the parse error"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "not found",
  "error": "mongo: no documents in result"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "failed to update",
  "error": "the database error"
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}

Delete an agent

DEL https://api.trycareflow.com/assistants/{id}

Requires `agents:write`. Deletes the agent for good. First, every phone number pointing at it is unlinked (numbers stay in your workspace, unassigned, and Twilio numbers have their call webhook cleared), and its web widget and other channel connections are removed. Its WhatsApp link goes with it. If a number can't be unlinked at the carrier, nothing is deleted and you get `502`; try again. Conversations already recorded stay in the Inbox. The success response has no `data`.

Path parameters
idstringrequired
The agent's ID, a 24-character hex string.
curl -X DELETE https://api.trycareflow.com/assistants/value \
  -H "Authorization: Bearer sk_live_••••"
const Agent = await careflow.agents.del('value')
Response
{
  "code": "SUCCESS",
  "message": "deleted"
}
{
  "code": "ERROR",
  "message": "invalid id",
  "error": "the parse error"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "not found",
  "error": "mongo: no documents in result"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "failed to remove channels",
  "error": "the database error"
}
{
  "code": "ERROR",
  "message": "failed to release phone numbers",
  "error": "unlink +442071234567: <carrier error>"
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}

Preview an agent's instructions

GET https://api.trycareflow.com/assistants/{id}/prompt-preview

Requires `agents:read`. Returns the full instructions the agent would get if a conversation started now, built from its current settings, including whether it's open right now. Nothing is saved. In `advanced` mode this is `behaviorPrompt`, or `systemPrompt` when that's empty.

Path parameters
idstringrequired
The agent's ID, a 24-character hex string.
curl https://api.trycareflow.com/assistants/value/prompt-preview \
  -H "Authorization: Bearer sk_live_••••"
const Agent = await careflow.agents.retrieve('value')
Response
{
  "code": "SUCCESS",
  "message": "ok",
  "data": {
    "prompt": "You are the front desk assistant for Harbourview Hotel. Speak in a warm, friendly, and conversational tone...

Monday: 07:00 - 22:00
...
Sunday: Closed",
    "promptMode": "structured"
  }
}
{
  "code": "ERROR",
  "message": "invalid id",
  "error": "the parse error"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "not found",
  "error": "mongo: no documents in result"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}

Publish an agent

POST https://api.trycareflow.com/assistants/{id}/publish

Requires `agents:write`. Sets the agent's status to `published`, so it answers on every channel linked to it: phone numbers, the web widget and WhatsApp. There are no checks: an agent with no phone number or channel still publishes. Call the validate endpoint first if you want advice on its tools. Publishing an agent that's already published is safe and changes nothing else. Settings changes made with update are live as soon as they're saved, so you only need to publish to take an agent live. There's no unpublish endpoint for API keys; use update with `status` if you must. The first publish sends a "published" notification.

Path parameters
idstringrequired
The agent's ID, a 24-character hex string.
curl https://api.trycareflow.com/assistants/value/publish \
  -H "Authorization: Bearer sk_live_••••"
const Agent = await careflow.agents.create('value')
Response
{
  "code": "SUCCESS",
  "message": "published",
  "data": {
    "assistant": {
      "_id": "66f1c2a9e4b0f1a2b3c4d5e6",
      "createdAt": "2026-03-02T09:14:00Z",
      "updatedAt": "2026-10-06T08:30:12Z",
      "businessId": "66f1c2a9e4b0f1a2b3c4d5a1",
      "name": "Harbourview front desk",
      "status": "published",
      "firstMessage": "Thanks for calling Harbourview Hotel, how can I help you today?",
      "toolIds": [
        "66f1c2a9e4b0f1a2b3c4d5f0"
      ],
      "whatsApp": {
        "phoneNumberId": "",
        "verifyToken": ""
      },
      "pipelineMode": "modular",
      "voiceConfig": {
        "sttProvider": "deepgram",
        "llmProvider": "openrouter",
        "voiceKey": "charlotte",
        "temperature": 0.6,
        "speed": 1
      },
      "promptMode": "structured",
      "compiledPrompt": "You are the front desk assistant for Harbourview Hotel...",
      "role": "service",
      "language": "en-GB",
      "tone": "warm_friendly",
      "greeting": "Good morning, Harbourview Hotel.",
      "signOff": "Enjoy your stay.",
      "alwaysSay": [
        "Breakfast is served from 7am to 10:30am."
      ],
      "neverSay": [
        "Room rates for other hotels"
      ],
      "useFillers": true,
      "interruptionHandling": "finish_sentence",
      "speakingPace": "normal",
      "timezone": "Europe/London",
      "activeHours": {
        "mon": {
          "start": "07:00",
          "end": "22:00"
        },
        "tue": {
          "start": "07:00",
          "end": "22:00"
        },
        "wed": {
          "start": "07:00",
          "end": "22:00"
        },
        "thu": {
          "start": "07:00",
          "end": "22:00"
        },
        "fri": {
          "start": "07:00",
          "end": "23:00"
        },
        "sat": {
          "start": "08:00",
          "end": "23:00"
        }
      },
      "outOfHoursBehavior": "take_message",
      "handoffs": [
        {
          "routineId": "66f1c2a9e4b0f1a2b3c4d5b7",
          "triggers": [
            "speak to a manager"
          ]
        }
      ],
      "recogniseReturning": true,
      "systemTools": {
        "knowledgeBase": true,
        "webSearch": true,
        "end": true
      }
    }
  }
}
{
  "code": "ERROR",
  "message": "invalid id",
  "error": "the parse error"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "not found",
  "error": "mongo: no documents in result"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "failed to publish",
  "error": "the database error"
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}

Check an agent's tools

POST https://api.trycareflow.com/assistants/{id}/validate

Requires `agents:write`. Looks at every tool the agent will be offered (its live tools, its workflows and the workspace's connected integrations) and reports problems that make agents behave badly: tools with no description, tools with confusingly similar names or descriptions, tools that look like steps of one process, and tools with identical parameters. It only reports. Nothing is changed, and publishing isn't blocked even when `valid` is `false`.

Path parameters
idstringrequired
The agent's ID, a 24-character hex string.
curl https://api.trycareflow.com/assistants/value/validate \
  -H "Authorization: Bearer sk_live_••••"
const Agent = await careflow.agents.create('value')
Response
{
  "code": "SUCCESS",
  "message": "validated",
  "data": {
    "report": {
      "valid": true,
      "issues": [
        {
          "severity": "warning",
          "message": "Tools 'check_booking' and 'check_booking_status' have similar names. The AI agent may confuse them.",
          "suggestion": "Consider merging these into a single workflow if they represent steps of one process, or make the names more distinct.",
          "affectedTools": [
            "check_booking",
            "check_booking_status"
          ]
        }
      ]
    }
  }
}
{
  "code": "ERROR",
  "message": "invalid assistant ID",
  "error": "the parse error"
}
{
  "code": "ERROR",
  "message": "unauthorized",
  "error": "invalid or revoked API key"
}
{
  "code": "ERROR",
  "message": "insufficient_scope",
  "error": "this API key needs the knowledge:write scope"
}
{
  "code": "ERROR",
  "message": "assistant not found",
  "error": "mongo: no documents in result"
}
{
  "code": "ERROR",
  "message": "too_many_requests",
  "error": "You have exceeded the rate limit for api. Please try again in 12s."
}
{
  "code": "ERROR",
  "message": "failed to load tools",
  "error": "the error"
}
{
  "code": "ERROR",
  "message": "service_unavailable",
  "error": "key lookup failed"
}