Key Features
Using the Ability API Endpoint
If you've deployed an ability (workflow) you built in Agentria as an API, external services can call its API endpoint to run the ability. The Ability API is a REST API that supports async execution, SSE (Server-Sent Events) streaming, status queries, and request cancellation.
This guide walks through how to call each endpoint and how to safely retrieve execution results.
Before You Begin
The ability must already be deployed as an API. If you haven't deployed it yet, complete the ๐API Release guide first.
You'll need the endpoint code (
api_endpoint) and API key issued during deployment.
The base URL and authentication method apply to every endpoint below.
Base URL
Every request requires an X-API-KEY header.
Step 1: Run an Ability Asynchronously
Runs the ability asynchronously and immediately returns a request_id (transaction ID). You can retrieve the result via the status query API (Step 3) or a callback URL.
Path Parameters
Parameter | Type | Description |
|---|---|---|
| string | Ability code (unique identifier of the released ability) |
Headers
Header | Type | Required | Description |
|---|---|---|---|
| string | Yes | API access token |
Request Body (multipart/form-data)
Field | Type | Required | Description |
|---|---|---|---|
| string (JSON) | Yes | Input parameters for the ability |
| string | No | Callback URL that receives the result via POST |
| boolean | No | Debug mode (default: |
| string | No | Client-issued external request identifier (up to 128 characters, |
| file[] | No | Files to upload |
params_json takes a JSON object matching the input parameters defined on the ability. Fields vary by ability, so check the target ability's input spec first.
external_request_id is an identifier the client issues before sending the request, and it serves two purposes. First, if the same external_request_id is submitted again, the server treats it as the same request and rejects it with 409 Conflict, which prevents duplicate execution (idempotency) from things like network retries. Second, because the client already holds this identifier before making the call, you can track and query the request by this value even before the server returns its own request_id in the response.
Response
On success, returns 200 OK with the request ID (string).
Error Responses
Status | Description |
|---|---|
|
|
| API key authentication failed |
| Ability not found |
| The same |
| Internal server error |
Example Request
Step 2: Receive Real-Time Streaming via SSE
Runs the ability and streams each node's execution result in real time via SSE.
Path Parameters / Headers
Same as Step 1 โ requires the api_endpoint path parameter and the X-API-KEY header.
Request Body (multipart/form-data)
Field | Type | Required | Description |
|---|---|---|---|
| string (JSON) | Yes | Input parameters for the ability (same as Step 1) |
| boolean | No | Debug mode (default: |
| string | No | Client-issued external request identifier. Same format rules as Step 1. Once the SSE stream ends, you can also query status/results by this value. |
Response
The response Content-Type is text/event-stream.
The X-Ability-Request-Id response header carries the request ID. Even if the connection drops before the first event arrives, you can use this value to re-query โ it matches the first request_id event.
Note: The
X-Request-Idheader is a separate value used for HTTP tracing. Don't confuse it withX-Ability-Request-Id.
Each event is delivered in a self-defined SSE line format that is not compatible with the standard EventSource format. A blank line separates events.
event_type Values and Body Shapes
event_type | When it fires | Body shape |
|---|---|---|
| Right after the stream starts (first, once) | Plain string (UUID). The request ID to use for re-querying results if the stream is lost |
| Each time a node finishes executing (intermediate, repeats per node) | JSON: |
| Ability completes successfully (final, once) | JSON: |
| Ability fails or a processing error occurs (final, once) | JSON: |
If event_type is request_id, it's a meta event; node is an intermediate event; response or error is the final event. Alternatively, if the body JSON has a status key set to COMPLETED or FAILURE, treat it as final. The connection closes once the stream ends.
Re-Querying Results After a Lost Stream
If a network drop causes you to miss the final event, don't resend the same request โ that would re-run the ability. Instead, re-query, since the server completes execution and records the result regardless of the stream connection.
Poll
GET /{api_endpoint}/{request_id}/resultusing the request ID from therequest_idevent (or theX-Ability-Request-Idheader) โ see Step 3.If you assigned an
external_request_id, you can also queryGET /{api_endpoint}/external/{external_request_id}/resultโ see Step 3.
Poll until status becomes COMPLETED, FAILURE, or CANCELED. Resending with the same external_request_id is rejected with 409 Conflict, so using an external ID also protects you against accidental duplicate runs.
Example Request
The -N (--no-buffer) option is required โ without it, chunks arrive in bursts.
Example Response (Wire Format)
JavaScript Client Example
Note (Python client): The same line buffering is required.
httpx.AsyncClient.stream()'saiter_lines()yields one line at a time, so skipnode:/response:/error:prefix lines with a JSON parse error and only parse JSON lines. However, therequest_idevent's body (a plain UUID) isn't JSON โ if you need the ID for re-querying, either track whether the previous line wasrequest_id:or use theX-Ability-Request-Idresponse header.
Step 3: Check Request Status and Results
Queries the processing status and result of an async execution request.
Both endpoints return the same response.
Path Parameters
Parameter | Type | Description |
|---|---|---|
| string | Ability code |
| string | Async request ID (returned by the execution API) |
Response
On success, returns 200 OK with the result below.
external_request_id is populated only if an external ID was assigned at request time; otherwise it's null.
status Values
Value | Description |
|---|---|
| Initial state (awaiting processing) |
| Processing |
| Completed |
| Failed (see the |
| Canceled |
Example Request
Querying by External Request ID
If you assigned an external_request_id at request time, you can query the same response using that value instead.
Status | Description |
|---|---|
|
|
| No request is registered under that external ID |
Step 4: Cancel a Request
Cancels an in-progress async request.
Path Parameters
Parameter | Type | Description |
|---|---|---|
| string | Ability code |
| string | ID of the request to cancel |
Response
On success, returns 200 OK with true.
Error Responses
Status | Description |
|---|---|
| Cancellation failed |
Example Request
Canceling Multiple Requests at Once
You can also cancel multiple async requests in a single call.
Parameter | Type | Required | Description |
|---|---|---|---|
| list[string] | Yes | List of request IDs to cancel (repeated query parameter) |
Usage Flows at a Glance
Pick one of the four flows below depending on your use case.
Flow 1: Async Execution + Polling
Flow 2: Async Execution + Callback
Example callback payloads:
Requests without an external ID never include the
external_request_idkey in the callback payload โ this preserves compatibility with existing integration code.
Flow 3: Real-Time Streaming
Flow 4: Canceling a Request
Next Steps
You've learned how to use the Ability API endpoints.
You can now call abilities directly from an external service and retrieve their execution results.
๐ API Release โ revisit the endpoint and API key issuance steps.
Frequently Asked Questions
What is the Ability API?
The Ability API lets external services run an ability you've built in Agentria via a REST API. It supports async execution, SSE streaming, status/result queries, and request cancellation, and every request is authenticated with an X-API-KEY header.
When should I use the Ability API?
Use it when an external backend server or another service needs to receive an ability's execution result without going through the Agentria UI. For example, it fits cases where you want an event in your own service to trigger an ability, or you want the execution result reflected automatically in your own system.
How can I receive an ability's execution result?
There are three ways: poll GET /{api_endpoint}/{request_id}/status (or /result), specify a callback_url at request time to receive the result via callback once it's done, or use the /sse endpoint to stream each node's result in real time while it runs.
What happens if the real-time streaming (SSE) connection drops?
The server keeps running the ability to completion and records the result regardless of the stream connection. If the connection drops before you receive the final event, don't resend the same request โ poll the status/result query API using the request_id (or external_request_id) instead. Resending the same request re-runs the ability.
What do I need before using the Ability API?
The ability must already be deployed as an API, and you'll need the endpoint code (api_endpoint) and API key issued at deployment time. If you haven't deployed it yet, complete the API Release guide's deployment steps first.