Tools
The tools your agents use to call your own systems and connected services: create, change, test and remove them, and read their runs, health and usage. Requires `tools:read` to read and `tools:write` to change or test.
The Tool object
Returned by the tools endpoints.
successemptyfailurelivemocknot_connectedunknown_toolinvalid_inputprovidertimeouthttp_statusblockedcancelledno_idem_key{ "outcome": "success", "class": "success", "vars": { "check_in_date": "2026-10-17" }, "raw": "{"booking":{"reference":"HV-20481","checkIn":"2026-10-17"}}", "latencyMs": 412, "mode": "live", "decider": "structural", "note": "every kept value came back blank", "failureCode": "http_status", "error": "the endpoint answered 404" }
List tools
Requires `tools:read`. Returns every tool in the API key's workspace, in any status, in no particular order. There's no paging. Secrets in `endpoint` are masked.
curl https://api.trycareflow.com/tools \ -H "Authorization: Bearer sk_live_••••"
const Tool = await careflow.tools.list()
{ "code": "SUCCESS", "message": "ok", "data": { "tools": [ { "_id": "66f1c2a9e4b0f1a2b3c4d5e6", "createdAt": "2026-09-14T09:12:00Z", "updatedAt": "2026-09-14T09:40:00Z", "businessId": "66f1c2a9e4b0f1a2b3c4d501", "key": "look_up_booking", "displayName": "Look up a booking", "name": "look_up_booking", "description": "Use when a guest asks about an existing reservation and gives a booking reference.", "type": "api", "effect": "read", "resolvedEffect": "read", "integrationKey": "", "catalogToolName": "", "endpoint": { "method": "GET", "url": "https://api.harbourviewhotel.example/v1/bookings/$input.booking_reference", "headers": [ { "name": "Accept", "value": "application/json" } ], "auth": { "type": "bearer", "token": "••••••••" }, "bodyMode": "none" }, "parameters": [ { "field": "booking_reference", "mode": "fetch_from_agent", "paramName": "booking_reference", "paramDescription": "The guest's booking reference, such as HV-20481", "type": "string", "required": true, "identity": true }, { "field": "property", "mode": "static", "value": "harbourview-main" } ], "status": "draft", "vars": [ { "name": "check_in_date", "path": "$.booking.checkIn", "type": "date" } ], "lastTest": { "at": "2026-09-14T09:38:12Z", "mode": "live", "outcome": "success", "class": "success", "latencyMs": 412 } }, { "_id": "66f1c2a9e4b0f1a2b3c4d5e7", "createdAt": "2026-08-02T14:05:00Z", "updatedAt": "2026-08-20T10:11:00Z", "businessId": "66f1c2a9e4b0f1a2b3c4d501", "key": "check_todays_slots", "displayName": "Check today's availability", "name": "check_todays_slots", "description": "Use when a caller asks what times are free today.", "type": "integration", "resolvedEffect": "read", "integrationKey": "google_calendar", "catalogToolName": "google_calendar_list_events", "catalogOutputs": [ { "name": "events", "type": "array", "description": "Events in the window" } ], "parameters": [ { "field": "timeMin", "mode": "static", "value": "{env.today_start}" } ], "status": "active" } ] } }
{ "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": "<database error>" }
{ "code": "ERROR", "message": "service_unavailable", "error": "key lookup failed" }
Create a tool
Requires `tools:write`. Creates a tool in the API key's workspace. Every new tool starts as a `draft`, which agents never use. Test it with `POST /tools/{id}/test`, then set `status` to `active`. For an `integration` tool, set `integrationKey` and `catalogToolName` to an operation of an app the workspace has connected. For an `api` tool, set `type` to `api` and describe the HTTPS request in `endpoint`. Credentials in `endpoint` are encrypted when stored and are never returned; responses show `••••••••` in their place. Response values can't be named on create; send `vars` with `PATCH /tools/{id}`.
integrationapifunctionmcpreadwriteirreversiblecurl https://api.trycareflow.com/tools \ -H "Authorization: Bearer sk_live_••••" \ -d name=look_up_booking \ -d type=api \ -d key=look_up_booking \ -d displayName=Look up a booking
const Tool = await careflow.tools.create({ name: 'look_up_booking', type: 'api', key: 'look_up_booking', displayName: 'Look up a booking', })
{ "code": "SUCCESS", "message": "created", "data": { "tool": { "_id": "66f1c2a9e4b0f1a2b3c4d5e6", "createdAt": "2026-09-14T09:12:00Z", "updatedAt": "2026-09-14T09:40:00Z", "businessId": "66f1c2a9e4b0f1a2b3c4d501", "key": "look_up_booking", "displayName": "Look up a booking", "name": "look_up_booking", "description": "Use when a guest asks about an existing reservation and gives a booking reference.", "type": "api", "effect": "read", "resolvedEffect": "read", "integrationKey": "", "catalogToolName": "", "endpoint": { "method": "GET", "url": "https://api.harbourviewhotel.example/v1/bookings/$input.booking_reference", "headers": [ { "name": "Accept", "value": "application/json" } ], "auth": { "type": "bearer", "token": "••••••••" }, "bodyMode": "none" }, "parameters": [ { "field": "booking_reference", "mode": "fetch_from_agent", "paramName": "booking_reference", "paramDescription": "The guest's booking reference, such as HV-20481", "type": "string", "required": true, "identity": true }, { "field": "property", "mode": "static", "value": "harbourview-main" } ], "status": "draft", "vars": [ { "name": "check_in_date", "path": "$.booking.checkIn", "type": "date" } ], "lastTest": { "at": "2026-09-14T09:38:12Z", "mode": "live", "outcome": "success", "class": "success", "latencyMs": 412 } } } }
{ "code": "ERROR", "message": "validation failed", "error": "invalid_payload", "details": { "Name": "required" } }
{ "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": "<database error>" }
{ "code": "ERROR", "message": "service_unavailable", "error": "key lookup failed" }
Get call totals for all tools
Requires `tools:read`. Returns call totals for the last 7 days for every tool in the workspace in one request, keyed by tool ID. Tools with no calls in that time are left out. Test runs aren't counted. `usedBy` is always 0 for now.
curl https://api.trycareflow.com/tools/overview \ -H "Authorization: Bearer sk_live_••••"
const Tool = await careflow.tools.list()
{ "code": "SUCCESS", "message": "ok", "data": { "windowDays": 7, "tools": { "66f1c2a9e4b0f1a2b3c4d5e6": { "total": 120, "failures": 4, "failureRate": 0.0333, "usedBy": 0 } } } }
{ "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": "<database error>" }
{ "code": "ERROR", "message": "service_unavailable", "error": "key lookup failed" }
Get a tool
Requires `tools:read`. Returns one tool from the API key's workspace. Secrets in `endpoint` are masked as `••••••••`. `resolvedEffect` and `notCallableBecause` tell you how agents will treat the tool.
curl https://api.trycareflow.com/tools/value \ -H "Authorization: Bearer sk_live_••••"
const Tool = await careflow.tools.retrieve('value')
{ "code": "SUCCESS", "message": "ok", "data": { "tool": { "_id": "66f1c2a9e4b0f1a2b3c4d5e6", "createdAt": "2026-09-14T09:12:00Z", "updatedAt": "2026-09-14T09:40:00Z", "businessId": "66f1c2a9e4b0f1a2b3c4d501", "key": "look_up_booking", "displayName": "Look up a booking", "name": "look_up_booking", "description": "Use when a guest asks about an existing reservation and gives a booking reference.", "type": "api", "effect": "read", "resolvedEffect": "read", "integrationKey": "", "catalogToolName": "", "endpoint": { "method": "GET", "url": "https://api.harbourviewhotel.example/v1/bookings/$input.booking_reference", "headers": [ { "name": "Accept", "value": "application/json" } ], "auth": { "type": "bearer", "token": "••••••••" }, "bodyMode": "none" }, "parameters": [ { "field": "booking_reference", "mode": "fetch_from_agent", "paramName": "booking_reference", "paramDescription": "The guest's booking reference, such as HV-20481", "type": "string", "required": true, "identity": true }, { "field": "property", "mode": "static", "value": "harbourview-main" } ], "status": "draft", "vars": [ { "name": "check_in_date", "path": "$.booking.checkIn", "type": "date" } ], "lastTest": { "at": "2026-09-14T09:38:12Z", "mode": "live", "outcome": "success", "class": "success", "latencyMs": 412 } } } }
{ "code": "ERROR", "message": "invalid id", "error": "the provided hex string is not a valid ObjectID" }
{ "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 a tool
Requires `tools:write`. Changes the fields you send and leaves the rest. `parameters`, `vars` and `endpoint` each replace the stored value as a whole. To keep a stored secret in `endpoint`, send it back as `••••••••`; it's kept only while the URL's host stays the same. Setting `status` to `active` works only after a live test that reached the provider. Changing a tool doesn't reset its last test. This endpoint doesn't check `status`, `type`, `effect` or the inputs' `mode` against their allowed values, so send only the values listed here.
integrationapifunctionmcpreadwriteirreversibledraftactivedisabledcurl -X PATCH https://api.trycareflow.com/tools/value \ -H "Authorization: Bearer sk_live_••••" \ -d type=api \ -d key=look_up_booking \ -d displayName=Look up a booking \ -d name=look_up_booking
const Tool = await careflow.tools.update({ type: 'api', key: 'look_up_booking', displayName: 'Look up a booking', name: 'look_up_booking', })
{ "code": "SUCCESS", "message": "updated", "data": { "tool": { "_id": "66f1c2a9e4b0f1a2b3c4d5e6", "createdAt": "2026-09-14T09:12:00Z", "updatedAt": "2026-09-14T10:02:00Z", "businessId": "66f1c2a9e4b0f1a2b3c4d501", "key": "look_up_booking", "displayName": "Look up a booking", "name": "look_up_booking", "description": "Use when a guest asks about an existing reservation and gives a booking reference.", "type": "api", "effect": "read", "resolvedEffect": "read", "integrationKey": "", "catalogToolName": "", "endpoint": { "method": "GET", "url": "https://api.harbourviewhotel.example/v1/bookings/$input.booking_reference", "headers": [ { "name": "Accept", "value": "application/json" } ], "auth": { "type": "bearer", "token": "••••••••" }, "bodyMode": "none" }, "parameters": [ { "field": "booking_reference", "mode": "fetch_from_agent", "paramName": "booking_reference", "paramDescription": "The guest's booking reference, such as HV-20481", "type": "string", "required": true, "identity": true }, { "field": "property", "mode": "static", "value": "harbourview-main" } ], "status": "active", "vars": [ { "name": "check_in_date", "path": "$.booking.checkIn", "type": "date" } ], "lastTest": { "at": "2026-09-14T09:38:12Z", "mode": "live", "outcome": "success", "class": "success", "latencyMs": 412 } } } }
{ "code": "ERROR", "message": "invalid id", "error": "the provided hex string is not a valid ObjectID" }
{ "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": "test before going live", "error": "run a live test — a run that reached the provider is what lets this tool go live" }
{ "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": "<database error>" }
{ "code": "ERROR", "message": "service_unavailable", "error": "key lookup failed" }
Delete a tool
Requires `tools:write`. Deletes the tool for good. Agents stop using it straight away. Its call log isn't deleted.
curl -X DELETE https://api.trycareflow.com/tools/value \ -H "Authorization: Bearer sk_live_••••"
const Tool = await careflow.tools.del('value')
{ "code": "SUCCESS", "message": "deleted" }
{ "code": "ERROR", "message": "invalid id", "error": "the provided hex string is not a valid ObjectID" }
{ "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 delete", "error": "<database error>" }
{ "code": "ERROR", "message": "service_unavailable", "error": "key lookup failed" }
Test a tool
Requires `tools:write`. Runs the tool once and returns what happened. A live test (`mock` false) makes the real call: an `integration` tool runs against the app with the workspace's stored connection, and an `api` tool sends the HTTPS request to your endpoint with its stored credentials. A `write` tool really changes things in that system, so test with safe data. With `mock` true, nothing is called and the saved `mockResponse` is read as if it were the response. The result is saved on the tool as `lastTest`. Only a live run whose class is `success` or `empty` lets the tool go `active`. A call that fails still returns 200; check `class` and `failureCode`. Each call has 15 seconds, and the whole test 30. `raw` holds the full response body from the provider, which can include customer data. Test runs aren't counted in runs or health.
curl https://api.trycareflow.com/tools/value/test \ -H "Authorization: Bearer sk_live_••••" \ -d args=[object Object] \ -d mock=false
const Tool = await careflow.tools.create({ args: '[object Object]', mock: 'false', })
{ "code": "SUCCESS", "message": "ok", "data": { "outcome": "success", "class": "success", "vars": { "check_in_date": "2026-10-17" }, "raw": "{"booking":{"reference":"HV-20481","checkIn":"2026-10-17"}}", "latencyMs": 412, "mode": "live", "decider": "structural" } }
{ "code": "ERROR", "message": "invalid id", "error": "the provided hex string is not a valid ObjectID" }
{ "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" }
List a tool's recent calls
Requires `tools:read`. Returns the calls agents made to this tool, newest first. Calls are kept for 30 days. Test runs aren't included. An ID that matches no tool returns an empty list rather than 404.
curl https://api.trycareflow.com/tools/value/runs \ -H "Authorization: Bearer sk_live_••••"
const Tool = await careflow.tools.retrieve('value')
{ "code": "SUCCESS", "message": "ok", "data": { "runs": [ { "id": "6710b3e2c4a1f09d8e7b6a52", "toolId": "66f1c2a9e4b0f1a2b3c4d5e6", "businessId": "66f1c2a9e4b0f1a2b3c4d501", "at": "2026-10-03T15:21:09Z", "outcome": "success", "class": "success", "latencyMs": 388 } ] } }
{ "code": "ERROR", "message": "invalid id", "error": "the provided hex string is not a valid ObjectID" }
{ "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": "<database error>" }
{ "code": "ERROR", "message": "service_unavailable", "error": "key lookup failed" }
Get a tool's health
Requires `tools:read`. Sums up the tool's calls over the last 7 days: totals per class, failure rate and average time. Test runs aren't counted. An ID that matches no tool returns zero totals rather than 404.
curl https://api.trycareflow.com/tools/value/health \ -H "Authorization: Bearer sk_live_••••"
const Tool = await careflow.tools.retrieve('value')
{ "code": "SUCCESS", "message": "ok", "data": { "windowDays": 7, "total": 120, "byClass": { "success": 110, "empty": 6, "failure": 4 }, "failureRate": 0.0333, "avgLatencyMs": 402.5 } }
{ "code": "ERROR", "message": "invalid id", "error": "the provided hex string is not a valid ObjectID" }
{ "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": "<database error>" }
{ "code": "ERROR", "message": "service_unavailable", "error": "key lookup failed" }
List playbooks that use a tool
Requires `tools:read`. Meant to list the playbooks that use this tool. For now it always returns an empty list.
curl https://api.trycareflow.com/tools/value/usage \ -H "Authorization: Bearer sk_live_••••"
const Tool = await careflow.tools.retrieve('value')
{ "code": "SUCCESS", "message": "ok", "data": { "playbooks": [] } }
{ "code": "ERROR", "message": "invalid id", "error": "the provided hex string is not a valid ObjectID" }
{ "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": "service_unavailable", "error": "key lookup failed" }