import os, httpx
response = httpx.post(
"https://api.onecortex.io/v1/agents/agt_.../a2a",
headers={"Authorization": f"Bearer {os.environ['ONECORTEX_API_KEY']}", "A2A-Version": "1.0"},
json={
"jsonrpc": "2.0",
"id": 1,
"method": "SendMessage",
"params": {"message": {"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "hello"}]}},
},
timeout=120,
)
task = response.json()["result"]["task"]
print(task["status"]["state"], task["artifacts"][0]["parts"][0]["text"])
const response = await fetch('https://api.onecortex.io/v1/agents/agt_.../a2a', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ONECORTEX_API_KEY}`,
'A2A-Version': '1.0',
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'SendMessage',
params: { message: { messageId: 'm1', role: 'ROLE_USER', parts: [{ text: 'hello' }] } },
}),
})
const { result } = await response.json()
console.log(result.task.status.state, result.task.artifacts[0].parts[0].text)
curl https://api.onecortex.io/v1/agents/agt_.../a2a \
-H "Authorization: Bearer $ONECORTEX_API_KEY" \
-H "A2A-Version: 1.0" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"SendMessage","params":{"message":{"messageId":"m1","role":"ROLE_USER","parts":[{"text":"hello"}]}}}'
{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "A valid Onecortex API key is required."
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "That agent does not exist."
}
}{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}Call an agent over A2A
A2A, for agents calling agents, over JSON-RPC. The A2A-Version header picks the version: 1.0 speaks SendMessage, SendStreamingMessage, GetTask and CancelTask; no header speaks 0.3’s message/send, message/stream, tasks/get and tasks/cancel. Any other version is refused with -32009.
SendMessage waits until the run ends or pauses and returns the task, with the reply as one text artifact. SendStreamingMessage answers a stream of JSON-RPC responses: the task, status and artifact updates, and a final status. A paused run leaves the task in TASK_STATE_INPUT_REQUIRED; reply with a message carrying its taskId.
A refusal of the call itself keeps its HTTP status with a JSON-RPC error body. A method’s own error is a 200 with a JSON-RPC error. See A2A for tasks, contexts, pauses and the error codes.
import os, httpx
response = httpx.post(
"https://api.onecortex.io/v1/agents/agt_.../a2a",
headers={"Authorization": f"Bearer {os.environ['ONECORTEX_API_KEY']}", "A2A-Version": "1.0"},
json={
"jsonrpc": "2.0",
"id": 1,
"method": "SendMessage",
"params": {"message": {"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "hello"}]}},
},
timeout=120,
)
task = response.json()["result"]["task"]
print(task["status"]["state"], task["artifacts"][0]["parts"][0]["text"])
const response = await fetch('https://api.onecortex.io/v1/agents/agt_.../a2a', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.ONECORTEX_API_KEY}`,
'A2A-Version': '1.0',
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'SendMessage',
params: { message: { messageId: 'm1', role: 'ROLE_USER', parts: [{ text: 'hello' }] } },
}),
})
const { result } = await response.json()
console.log(result.task.status.state, result.task.artifacts[0].parts[0].text)
curl https://api.onecortex.io/v1/agents/agt_.../a2a \
-H "Authorization: Bearer $ONECORTEX_API_KEY" \
-H "A2A-Version: 1.0" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"SendMessage","params":{"message":{"messageId":"m1","role":"ROLE_USER","parts":[{"text":"hello"}]}}}'
{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "A valid Onecortex API key is required."
}
}{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32600,
"message": "That agent does not exist."
}
}{
"jsonrpc": "2.0",
"id": "<string>",
"result": {},
"error": {
"code": 123,
"message": "<string>"
}
}Authorizations
An Onecortex API key, oc_live_..., from API keys in the dashboard.
Headers
1.0, or leave it out for 0.3.
"1.0"
Path Parameters
The agent's ID, from its page in the dashboard.
"agt_01K0000000000000000000000"