Skip to main content

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.

MethodPathSummary
POST/a2a/{agent_id}Send a message to an agent (JSON-RPC)
GET/a2a/{agent_id}/.well-known/agent-card.jsonRead an agent's card
GET/a2a/{agent_id}/.well-known/agent.jsonRead an agent's card (older path)
POST/a2a/{agent_id}/message/sendSend a message to an agent (JSON-RPC)
POST/v1/a2a/{agent_id}/message/sendSend 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.

Docs

Parameters:

NameInTypeRequiredDescription
agent_idpathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
idstring or integer or nullNoId
jsonrpc"2.0"YesJsonrpc
methodstringYesMethod
paramsobjectNoParams

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:

StatusDescriptionBody
200The agent's JSON-RPC replyapplication/json SpanwaySendMessageResponse
400The 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
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The 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
404No agent with this id or name is visible to the keyapplication/json A2AJsonRpcError
422Validation Errorapplication/json HTTPValidationError
429A rate or concurrency limit was reached, retry after Retry-After secondsapplication/json ErrorDetail
500The agent has no URL, or the call to the agent failed. The gateway log has the causeapplication/json A2AJsonRpcError

Response fields (200):

FieldTypeRequiredDescription
errorobject or nullNoError
idstring or integer or nullNoId
jsonrpcstringNoJsonrpc
resultobject or nullNoResult
usageobject or nullNoUsage

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:

NameInTypeRequiredDescription
agent_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/a2a/agent_id-123/.well-known/agent-card.json" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The agent cardapplication/json any
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/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:

NameInTypeRequiredDescription
agent_idpathstringYes

Example request:

curl -X GET "http://localhost:4000/a2a/agent_id-123/.well-known/agent.json" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200The agent cardapplication/json any
401No valid key or Admin UI session was presentedapplication/json ErrorDetail
403The key's role, grants or license do not allow this actionapplication/json ErrorDetail
404No object with that id is visible to the callerapplication/json ErrorDetail
422Validation Errorapplication/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.

Docs

Parameters:

NameInTypeRequiredDescription
agent_idpathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
idstring or integer or nullNoId
jsonrpc"2.0"YesJsonrpc
methodstringYesMethod
paramsobjectNoParams

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:

StatusDescriptionBody
200The agent's JSON-RPC replyapplication/json SpanwaySendMessageResponse
400The 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
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The 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
404No agent with this id or name is visible to the keyapplication/json A2AJsonRpcError
422Validation Errorapplication/json HTTPValidationError
429A rate or concurrency limit was reached, retry after Retry-After secondsapplication/json ErrorDetail
500The agent has no URL, or the call to the agent failed. The gateway log has the causeapplication/json A2AJsonRpcError

Response fields (200):

FieldTypeRequiredDescription
errorobject or nullNoError
idstring or integer or nullNoId
jsonrpcstringNoJsonrpc
resultobject or nullNoResult
usageobject or nullNoUsage

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.

Docs

Parameters:

NameInTypeRequiredDescription
agent_idpathstringYes

Request body (application/json, object):

FieldTypeRequiredDescription
idstring or integer or nullNoId
jsonrpc"2.0"YesJsonrpc
methodstringYesMethod
paramsobjectNoParams

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:

StatusDescriptionBody
200The agent's JSON-RPC replyapplication/json SpanwaySendMessageResponse
400The 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
401No valid key or Admin UI session was presentedapplication/json ProxyError
403The 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
404No agent with this id or name is visible to the keyapplication/json A2AJsonRpcError
422Validation Errorapplication/json HTTPValidationError
429A rate or concurrency limit was reached, retry after Retry-After secondsapplication/json ErrorDetail
500The agent has no URL, or the call to the agent failed. The gateway log has the causeapplication/json A2AJsonRpcError

Response fields (200):

FieldTypeRequiredDescription
errorobject or nullNoError
idstring or integer or nullNoId
jsonrpcstringNoJsonrpc
resultobject or nullNoResult
usageobject or nullNoUsage