> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onecortex.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 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](/call/a2a) for tasks, contexts, pauses and the error codes.




## OpenAPI

````yaml /openapi.yaml post /v1/agents/{agentId}/a2a
openapi: 3.1.0
info:
  title: Onecortex API
  version: '1'
  description: >-
    Call a deployed agent over invoke, AG-UI or A2A, and read its public A2A
    Agent Card. This is the whole public API.
servers:
  - url: https://api.onecortex.io
security:
  - apiKey: []
paths:
  /v1/agents/{agentId}/a2a:
    post:
      summary: Call an agent over A2A
      description: >
        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](/call/a2a) for tasks, contexts, pauses and the error codes.
      operationId: callAgentA2a
      parameters:
        - $ref: '#/components/parameters/AgentId'
        - name: A2A-Version
          in: header
          required: false
          description: '`1.0`, or leave it out for 0.3.'
          schema:
            type: string
            example: '1.0'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JsonRpcRequest'
            example:
              jsonrpc: '2.0'
              id: 1
              method: SendMessage
              params:
                message:
                  messageId: m1
                  role: ROLE_USER
                  parts:
                    - text: hello
      responses:
        '200':
          description: A JSON-RPC response, or for a streaming method a stream of them.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonRpcResponse'
              example:
                jsonrpc: '2.0'
                id: 1
                result:
                  task:
                    id: tsk_01K0000000000000000000000
                    contextId: 01K0000000000000000000000
                    status:
                      state: TASK_STATE_COMPLETED
                      timestamp: '2026-09-29T13:14:53.344Z'
                    artifacts:
                      - artifactId: reply
                        name: reply
                        parts:
                          - text: 'You said: hello'
            text/event-stream:
              schema:
                type: string
                description: >
                  One `data:` frame per JSON-RPC response, each holding one of
                  `task`, `statusUpdate`, `artifactUpdate` in its `result`.


                  ```text

                  data:
                  {"jsonrpc":"2.0","id":1,"result":{"task":{"id":"tsk_01K...","contextId":"01K...","status":{"state":"TASK_STATE_WORKING"}}}}


                  data:
                  {"jsonrpc":"2.0","id":1,"result":{"artifactUpdate":{"taskId":"tsk_01K...","contextId":"01K...","artifact":{"artifactId":"reply","name":"reply","parts":[{"text":"You
                  said: hello"}]}}}}


                  data:
                  {"jsonrpc":"2.0","id":1,"result":{"statusUpdate":{"taskId":"tsk_01K...","contextId":"01K...","status":{"state":"TASK_STATE_COMPLETED"}}}}

                  ```
        '401':
          description: The API key is missing, unknown, revoked or expired.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonRpcResponse'
              example:
                jsonrpc: '2.0'
                id: null
                error:
                  code: -32600
                  message: A valid Onecortex API key is required.
        '404':
          description: >-
            No such agent in your organization, or the key is scoped to another
            agent.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonRpcResponse'
              example:
                jsonrpc: '2.0'
                id: null
                error:
                  code: -32600
                  message: That agent does not exist.
        '429':
          description: Over a rate limit. Wait for `Retry-After`, then retry.
          headers:
            Retry-After:
              description: Whole seconds to wait.
              schema:
                type: integer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/JsonRpcResponse'
      x-codeSamples:
        - lang: python
          label: Python
          source: >
            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"])
        - lang: typescript
          label: TypeScript
          source: >
            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)
        - lang: bash
          label: curl
          source: |
            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"}]}}}'
components:
  parameters:
    AgentId:
      name: agentId
      in: path
      required: true
      description: The agent's ID, from its page in the dashboard.
      schema:
        type: string
        example: agt_01K0000000000000000000000
  schemas:
    JsonRpcRequest:
      type: object
      required:
        - jsonrpc
        - method
      properties:
        jsonrpc:
          const: '2.0'
        id:
          oneOf:
            - type: string
            - type: integer
        method:
          type: string
          example: SendMessage
        params:
          type: object
          additionalProperties: true
    JsonRpcResponse:
      type: object
      required:
        - jsonrpc
      properties:
        jsonrpc:
          const: '2.0'
        id:
          oneOf:
            - type: string
            - type: integer
            - type: 'null'
        result:
          type: object
          additionalProperties: true
          description: For SendMessage on 1.0, an object holding `task`.
        error:
          type: object
          properties:
            code:
              type: integer
              description: >-
                -32001 task not found, -32002 not cancelable, -32004
                unsupported, -32005 content type not supported, -32009 version
                not supported, -32600, -32601, -32602, -32603.
            message:
              type: string
  headers:
    RequestId:
      description: The request's ID, `req_...`. Quote it to support.
      schema:
        type: string
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: An Onecortex API key, `oc_live_...`, from API keys in the dashboard.

````