> ## Documentation Index
> Fetch the complete documentation index at: https://hs-df36fa00.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Task — POST /v1/agents/:agent_id/tasks/:task_id/get

> Retrieve the current status of an A2A task from the agent endpoint. Useful for polling long-running tasks after invoke or invoke-async.

Retrieves the current state of an A2A task directly from the agent's endpoint via the ServiceNet gateway. Use this to poll a long-running task that was started by a previous [invoke](/api/agents/invoke) or [invoke-async](/api/agents/invoke-async) call.

The gateway proxies an A2A `tasks/get` JSON-RPC call to the agent endpoint and returns the response wrapped in the standard `InvokeAgentResponse` envelope.

## Request

```bash theme={null}
curl -X POST http://your-node:8042/v1/agents/stripe-agent/tasks/task-abc-001/get \
  -H 'content-type: application/json' \
  -d '{
    "history_length": 10,
    "auth_token": "secret-token"
  }'
```

### Path parameters

<ParamField path="agent_id" type="string" required>
  The unique identifier of the agent that owns the task.
</ParamField>

<ParamField path="task_id" type="string" required>
  The A2A task identifier returned by the agent during the original invocation.
</ParamField>

### Body parameters

<ParamField body="history_length" type="integer">
  Number of historical message turns to include in the response. Defaults to `10` if omitted.
</ParamField>

<ParamField body="auth_token" type="string">
  Bearer token or API key to forward to the agent endpoint for authentication.
</ParamField>

<ParamField body="auth_context_id" type="string (UUID)">
  Reference to a stored auth context. The gateway decrypts and forwards the credential on your behalf.
</ParamField>

## Response

Returns an `InvokeAgentResponse` reflecting the current task state.

<ResponseField name="agent_id" type="string">
  The agent that owns the task.
</ResponseField>

<ResponseField name="status" type="string">
  Task execution status as reported by the agent (e.g. `"running"`, `"completed"`, `"failed"`).
</ResponseField>

<ResponseField name="receipt_id" type="string (UUID)">
  Execution receipt identifier. Omitted if not yet persisted.
</ResponseField>

<ResponseField name="task_id" type="string">
  The A2A task identifier echoed from the path parameter.
</ResponseField>

<ResponseField name="context_id" type="string">
  A2A context identifier, if the agent returned one.
</ResponseField>

<ResponseField name="message" type="string">
  Human-readable status message from the agent, if provided.
</ResponseField>

<ResponseField name="output" type="object">
  Structured output from the agent. Populated once the task completes.
</ResponseField>

<ResponseField name="settlement" type="object">
  Normalized settlement information, if applicable.
</ResponseField>

<ResponseField name="payment_receipt" type="object">
  Payment receipt from the settlement rail, if a payment occurred.
</ResponseField>

<ResponseField name="raw" type="object">
  The raw A2A JSON-RPC response returned by the agent endpoint.
</ResponseField>

## Status codes

| Code              | Meaning                                                           |
| ----------------- | ----------------------------------------------------------------- |
| `200 OK`          | Task state retrieved successfully.                                |
| `403 Forbidden`   | The agent is blocked or the provider is revoked.                  |
| `404 Not Found`   | No published agent with the given `agent_id` exists on this node. |
| `502 Bad Gateway` | The gateway could not reach the agent endpoint.                   |

## Example response

```json theme={null}
{
  "agent_id": "stripe-agent",
  "status": "completed",
  "receipt_id": "f1e2d3c4-0000-0000-0000-000000000001",
  "task_id": "task-abc-001",
  "context_id": "ctx-abc-001",
  "output": {
    "payment_link": "https://buy.stripe.com/test_abc123"
  },
  "raw": {
    "jsonrpc": "2.0",
    "id": 1,
    "result": {
      "id": "task-abc-001",
      "status": { "state": "completed" },
      "history": [
        { "role": "user", "parts": [{ "text": "Create a payment link for 15 AUD" }] },
        { "role": "agent", "parts": [{ "text": "Here is your payment link." }] }
      ]
    }
  }
}
```
