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
| Parameter | In | Type | Notes |
|---|---|---|---|
slug | path | string | required |
Idempotency-Key | header | string | max length 128 |
Request body (application/json)
| Field | Type | Required | Notes |
|---|---|---|---|
input | string | yes | min length 1, max length 49152 |
user | string | Your own ID for the end user (API keys only). pattern ^[A-Za-z0-9._:@-]{1,128}$ | |
previous_run_id | string (uuid) | ||
wait | boolean | default 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
| Field | Type | Required | Notes |
|---|---|---|---|
status | completed | running | waiting_approval | failed | cancelled | yes | |
run_id | string (uuid) | yes | |
output | string | The answer (completed). Knowledge answers end with numbered sources. | |
error | string | Why the run failed (failed). | |
reason | string |
Responses
| Status | Meaning |
|---|---|
200 | The run’s outcome |
400 | The request is invalid (invalid_request). |
403 | The role or key scope does not allow this (forbidden). |
404 | Not found in this workspace (not_found). |
409 | Conflicts with the current state, e.g. a stale version or a taken slug (conflict). |
503 | A platform service is unavailable (unavailable); retry with backoff. |
Get a run’s status
GET /v1/runs/{run_id}
Parameters
| Parameter | In | Type | Notes |
|---|---|---|---|
run_id | path | string (uuid) | required |
user | query | string | The 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
| Field | Type | Required | Notes |
|---|---|---|---|
status | completed | running | waiting_approval | failed | cancelled | yes | |
run_id | string (uuid) | yes | |
output | string | The answer (completed). Knowledge answers end with numbered sources. | |
error | string | Why the run failed (failed). | |
reason | string |
Responses
| Status | Meaning |
|---|---|
200 | Current status |
404 | Not 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
| Parameter | In | Type | Notes |
|---|---|---|---|
run_id | path | string (uuid) | required |
Request body (application/json)
| Field | Type | Required | Notes |
|---|---|---|---|
user | string | Your 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
| Field | Type | Required | Notes |
|---|---|---|---|
status | completed | running | waiting_approval | failed | cancelled | yes | |
run_id | string (uuid) | yes | |
output | string | The answer (completed). Knowledge answers end with numbered sources. | |
error | string | Why the run failed (failed). | |
reason | string |
Responses
| Status | Meaning |
|---|---|
200 | The run’s outcome |
Cancel a run
POST /v1/runs/{run_id}/cancel
Parameters
| Parameter | In | Type | Notes |
|---|---|---|---|
run_id | path | string (uuid) | required |
Request body (application/json)
| Field | Type | Required | Notes |
|---|---|---|---|
reason | string | max length 500 | |
user | string | Your 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
| Field | Type | Required | Notes |
|---|---|---|---|
status | completed | running | waiting_approval | failed | cancelled | yes | |
run_id | string (uuid) | yes | |
output | string | The answer (completed). Knowledge answers end with numbered sources. | |
error | string | Why the run failed (failed). | |
reason | string |
Responses
| Status | Meaning |
|---|---|
200 | Cancelled |
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
| Parameter | In | Type | Notes |
|---|---|---|---|
run_id | path | string (uuid) | required |
user | query | string | The end user the run was started for (API keys). pattern ^[A-Za-z0-9._:@-]{1,128}$ |
Last-Event-ID | header | string |
curl -X GET https://api.ngamia.com/v1/runs/<run_id>/events \
-H "Authorization: Bearer $NGAMIA_TOKEN"Responses
| Status | Meaning |
|---|---|
200 | Event stream |
429 | Too many open streams (too_many_streams) or requests (rate_limited). |