A2a API
This page documents the 5 gateway endpoints tagged a2a in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.
| Method | Path | Summary |
|---|---|---|
| POST | /a2a/{agent_id} | Send a message to an agent (JSON-RPC) |
| GET | /a2a/{agent_id}/.well-known/agent-card.json | Read an agent's card |
| GET | /a2a/{agent_id}/.well-known/agent.json | Read an agent's card (older path) |
| POST | /a2a/{agent_id}/message/send | Send a message to an agent (JSON-RPC) |
| POST | /v1/a2a/{agent_id}/message/send | Send a message to an agent (JSON-RPC) |
Endpoints
POST /a2a/{agent_id}
Send a message to an agent (JSON-RPC)
Send one A2A request (JSON-RPC 2.0) to a registered agent through the gateway, so the key's agent grants, budgets, guardrails and spend logs apply. message/send answers the agent's reply and message/stream answers server-sent events. The task methods (tasks/get, tasks/list, tasks/cancel, tasks/resubscribe), the tasks/pushNotificationConfig methods (push URLs must be public HTTPS) and agent/getAuthenticatedExtendedCard are passed on too, as are the A2A 1.0 names such as SendMessage and GetTask.
The gateway speaks A2A 0.3 unless the agent card pins 1.0, the request uses a 1.0 method name or sends the
a2a-version: 1.x header, and translates between the two. Failures answer the JSON-RPC error envelope with a
matching HTTP status: -32600 invalid request, -32601 unknown method, -32602 bad params, -32000 agent not found
or not set up, -32603 the agent call failed.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or integer or null | No | Id |
jsonrpc | "2.0" | Yes | Jsonrpc |
method | string | Yes | Method |
params | object | No | Params |
Example request:
curl -X POST "http://localhost:4000/a2a/agent_id-123" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"jsonrpc": "2.0",
"method": "message/send",
"params": {
"message": {
"messageId": "msg-1",
"parts": [
{
"kind": "text",
"text": "Summarise the open incidents"
}
],
"role": "user"
}
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The agent's JSON-RPC reply | application/json SpanwaySendMessageResponse |
| 400 | The JSON-RPC request was refused. Most refusals answer the JSON-RPC error envelope with a code: -32600 for a body that is not JSON-RPC 2.0, -32601 for an unknown method and -32602 for bad params. An agent that requires a trace id answers a plain detail instead. | application/json A2AJsonRpcError or ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key may not call this agent (plain detail), or the agent is a custom agent and the license lacks custom_agents (JSON-RPC envelope) | application/json A2AJsonRpcError or ErrorDetail |
| 404 | No agent with this id or name is visible to the key | application/json A2AJsonRpcError |
| 422 | Validation Error | application/json HTTPValidationError |
| 429 | A rate or concurrency limit was reached, retry after Retry-After seconds | application/json ErrorDetail |
| 500 | The agent has no URL, or the call to the agent failed. The gateway log has the cause | application/json A2AJsonRpcError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
error | object or null | No | Error |
id | string or integer or null | No | Id |
jsonrpc | string | No | Jsonrpc |
result | object or null | No | Result |
usage | object or null | No | Usage |
GET /a2a/{agent_id}/.well-known/agent-card.json
Read an agent's card
Get the agent card for an agent (A2A discovery endpoint).
Supports both standard paths:
- /.well-known/agent-card.json
- /.well-known/agent.json
The URL in the agent card is rewritten to point to the Spanway proxy, so all subsequent A2A calls go through Spanway for logging and cost tracking.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/a2a/agent_id-123/.well-known/agent-card.json" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The agent card | application/json any |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
GET /a2a/{agent_id}/.well-known/agent.json
Read an agent's card (older path)
Get the agent card for an agent (A2A discovery endpoint).
Supports both standard paths:
- /.well-known/agent-card.json
- /.well-known/agent.json
The URL in the agent card is rewritten to point to the Spanway proxy, so all subsequent A2A calls go through Spanway for logging and cost tracking.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | string | Yes |
Example request:
curl -X GET "http://localhost:4000/a2a/agent_id-123/.well-known/agent.json" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The agent card | application/json any |
| 401 | No valid key or Admin UI session was presented | application/json ErrorDetail |
| 403 | The key's role, grants or license do not allow this action | application/json ErrorDetail |
| 404 | No object with that id is visible to the caller | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
POST /a2a/{agent_id}/message/send
Send a message to an agent (JSON-RPC)
Send one A2A request (JSON-RPC 2.0) to a registered agent through the gateway, so the key's agent grants, budgets, guardrails and spend logs apply. message/send answers the agent's reply and message/stream answers server-sent events. The task methods (tasks/get, tasks/list, tasks/cancel, tasks/resubscribe), the tasks/pushNotificationConfig methods (push URLs must be public HTTPS) and agent/getAuthenticatedExtendedCard are passed on too, as are the A2A 1.0 names such as SendMessage and GetTask.
The gateway speaks A2A 0.3 unless the agent card pins 1.0, the request uses a 1.0 method name or sends the
a2a-version: 1.x header, and translates between the two. Failures answer the JSON-RPC error envelope with a
matching HTTP status: -32600 invalid request, -32601 unknown method, -32602 bad params, -32000 agent not found
or not set up, -32603 the agent call failed.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or integer or null | No | Id |
jsonrpc | "2.0" | Yes | Jsonrpc |
method | string | Yes | Method |
params | object | No | Params |
Example request:
curl -X POST "http://localhost:4000/a2a/agent_id-123/message/send" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"jsonrpc": "2.0",
"method": "message/send",
"params": {
"message": {
"messageId": "msg-1",
"parts": [
{
"kind": "text",
"text": "Summarise the open incidents"
}
],
"role": "user"
}
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The agent's JSON-RPC reply | application/json SpanwaySendMessageResponse |
| 400 | The JSON-RPC request was refused. Most refusals answer the JSON-RPC error envelope with a code: -32600 for a body that is not JSON-RPC 2.0, -32601 for an unknown method and -32602 for bad params. An agent that requires a trace id answers a plain detail instead. | application/json A2AJsonRpcError or ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key may not call this agent (plain detail), or the agent is a custom agent and the license lacks custom_agents (JSON-RPC envelope) | application/json A2AJsonRpcError or ErrorDetail |
| 404 | No agent with this id or name is visible to the key | application/json A2AJsonRpcError |
| 422 | Validation Error | application/json HTTPValidationError |
| 429 | A rate or concurrency limit was reached, retry after Retry-After seconds | application/json ErrorDetail |
| 500 | The agent has no URL, or the call to the agent failed. The gateway log has the cause | application/json A2AJsonRpcError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
error | object or null | No | Error |
id | string or integer or null | No | Id |
jsonrpc | string | No | Jsonrpc |
result | object or null | No | Result |
usage | object or null | No | Usage |
POST /v1/a2a/{agent_id}/message/send
Send a message to an agent (JSON-RPC)
Send one A2A request (JSON-RPC 2.0) to a registered agent through the gateway, so the key's agent grants, budgets, guardrails and spend logs apply. message/send answers the agent's reply and message/stream answers server-sent events. The task methods (tasks/get, tasks/list, tasks/cancel, tasks/resubscribe), the tasks/pushNotificationConfig methods (push URLs must be public HTTPS) and agent/getAuthenticatedExtendedCard are passed on too, as are the A2A 1.0 names such as SendMessage and GetTask.
The gateway speaks A2A 0.3 unless the agent card pins 1.0, the request uses a 1.0 method name or sends the
a2a-version: 1.x header, and translates between the two. Failures answer the JSON-RPC error envelope with a
matching HTTP status: -32600 invalid request, -32601 unknown method, -32602 bad params, -32000 agent not found
or not set up, -32603 the agent call failed.
Parameters:
| Name | In | Type | Required | Description |
|---|---|---|---|---|
agent_id | path | string | Yes |
Request body (application/json, object):
| Field | Type | Required | Description |
|---|---|---|---|
id | string or integer or null | No | Id |
jsonrpc | "2.0" | Yes | Jsonrpc |
method | string | Yes | Method |
params | object | No | Params |
Example request:
curl -X POST "http://localhost:4000/v1/a2a/agent_id-123/message/send" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"jsonrpc": "2.0",
"method": "message/send",
"params": {
"message": {
"messageId": "msg-1",
"parts": [
{
"kind": "text",
"text": "Summarise the open incidents"
}
],
"role": "user"
}
}
}'
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | The agent's JSON-RPC reply | application/json SpanwaySendMessageResponse |
| 400 | The JSON-RPC request was refused. Most refusals answer the JSON-RPC error envelope with a code: -32600 for a body that is not JSON-RPC 2.0, -32601 for an unknown method and -32602 for bad params. An agent that requires a trace id answers a plain detail instead. | application/json A2AJsonRpcError or ErrorDetail |
| 401 | No valid key or Admin UI session was presented | application/json ProxyError |
| 403 | The key may not call this agent (plain detail), or the agent is a custom agent and the license lacks custom_agents (JSON-RPC envelope) | application/json A2AJsonRpcError or ErrorDetail |
| 404 | No agent with this id or name is visible to the key | application/json A2AJsonRpcError |
| 422 | Validation Error | application/json HTTPValidationError |
| 429 | A rate or concurrency limit was reached, retry after Retry-After seconds | application/json ErrorDetail |
| 500 | The agent has no URL, or the call to the agent failed. The gateway log has the cause | application/json A2AJsonRpcError |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
error | object or null | No | Error |
id | string or integer or null | No | Id |
jsonrpc | string | No | Jsonrpc |
result | object or null | No | Result |
usage | object or null | No | Usage |