Skip to Content
The Ngamia platform API is in preview. Endpoints may change before general availability.

Runs

Run agents for your users, read results, stream events, resume and cancel.

Run an agent

POST /v1/agents/{slug}/runs

With wait: true (default) the call returns when the run finishes. With wait: false it returns status: running at once; follow /v1/runs/{run_id}/events or poll /v1/runs/{run_id}. To continue a conversation, pass the last run’s ID as previous_run_id. Send an Idempotency-Key header to retry safely.

Parameters

ParameterInTypeNotes
slugpathstringrequired
Idempotency-Keyheaderstringmax length 128

Request body (application/json)

FieldTypeRequiredNotes
inputstringyesmin length 1, max length 49152
userstringYour own ID for the end user (API keys only). pattern ^[A-Za-z0-9._:@-]{1,128}$
previous_run_idstring (uuid)
waitbooleandefault true
curl -X POST https://api.ngamia.com/v1/agents/<slug>/runs \ -H "Authorization: Bearer $NGAMIA_TOKEN" \ -H 'content-type: application/json' \ -d '{"input": "Habari! Mnafungua saa ngapi?", "user": "customer-42"}'

Response 200 fields

FieldTypeRequiredNotes
statuscompleted | running | waiting_approval | failed | cancelledyes
run_idstring (uuid)yes
outputstringThe answer (completed). Knowledge answers end with numbered sources.
errorstringWhy the run failed (failed).
reasonstring

Responses

StatusMeaning
200The run’s outcome
400The request is invalid (invalid_request).
403The role or key scope does not allow this (forbidden).
404Not found in this workspace (not_found).
409Conflicts with the current state, e.g. a stale version or a taken slug (conflict).
503A platform service is unavailable (unavailable); retry with backoff.

Get a run’s status

GET /v1/runs/{run_id}

Parameters

ParameterInTypeNotes
run_idpathstring (uuid)required
userquerystringThe end user the run was started for (API keys). pattern ^[A-Za-z0-9._:@-]{1,128}$
curl -X GET https://api.ngamia.com/v1/runs/<run_id> \ -H "Authorization: Bearer $NGAMIA_TOKEN"

Response 200 fields

FieldTypeRequiredNotes
statuscompleted | running | waiting_approval | failed | cancelledyes
run_idstring (uuid)yes
outputstringThe answer (completed). Knowledge answers end with numbered sources.
errorstringWhy the run failed (failed).
reasonstring

Responses

StatusMeaning
200Current status
404Not found in this workspace (not_found).

Resume a run that stopped before finishing

POST /v1/runs/{run_id}/continue

Drives an unfinished run (for example one interrupted by a restart) to its end. To send a follow-up message, start a new run with previous_run_id.

Parameters

ParameterInTypeNotes
run_idpathstring (uuid)required

Request body (application/json)

FieldTypeRequiredNotes
userstringYour own ID for the end user (API keys only). pattern ^[A-Za-z0-9._:@-]{1,128}$
curl -X POST https://api.ngamia.com/v1/runs/<run_id>/continue \ -H "Authorization: Bearer $NGAMIA_TOKEN" \ -H 'content-type: application/json' \ -d '{}'

Response 200 fields

FieldTypeRequiredNotes
statuscompleted | running | waiting_approval | failed | cancelledyes
run_idstring (uuid)yes
outputstringThe answer (completed). Knowledge answers end with numbered sources.
errorstringWhy the run failed (failed).
reasonstring

Responses

StatusMeaning
200The run’s outcome

Cancel a run

POST /v1/runs/{run_id}/cancel

Parameters

ParameterInTypeNotes
run_idpathstring (uuid)required

Request body (application/json)

FieldTypeRequiredNotes
reasonstringmax length 500
userstringYour own ID for the end user (API keys only). pattern ^[A-Za-z0-9._:@-]{1,128}$
curl -X POST https://api.ngamia.com/v1/runs/<run_id>/cancel \ -H "Authorization: Bearer $NGAMIA_TOKEN" \ -H 'content-type: application/json' \ -d '{}'

Response 200 fields

FieldTypeRequiredNotes
statuscompleted | running | waiting_approval | failed | cancelledyes
run_idstring (uuid)yes
outputstringThe answer (completed). Knowledge answers end with numbered sources.
errorstringWhy the run failed (failed).
reasonstring

Responses

StatusMeaning
200Cancelled

Stream a run’s events (Server-Sent Events)

GET /v1/runs/{run_id}/events

Event names: run.started, model.replied (text, tool_calls, token counts), tool.started, tool.finished, approval.requested, approval.resolved, run.completed (output), run.failed (error), run.cancelled. Reconnect with Last-Event-ID to resume without gaps.

Each person may hold 10 streams open at once (each API key 100); a stream ends after 30 minutes (and when the server restarts), so reconnect with Last-Event-ID when it closes before the run finishes.

Parameters

ParameterInTypeNotes
run_idpathstring (uuid)required
userquerystringThe end user the run was started for (API keys). pattern ^[A-Za-z0-9._:@-]{1,128}$
Last-Event-IDheaderstring
curl -X GET https://api.ngamia.com/v1/runs/<run_id>/events \ -H "Authorization: Bearer $NGAMIA_TOKEN"

Responses

StatusMeaning
200Event stream
429Too many open streams (too_many_streams) or requests (rate_limited).
Last updated on