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

# Status Task API: Poll Generation Results by Task ID

> Poll an APIXO Generation API task by model and task ID to read its state, failure details, billing, and final result URLs

Query the status and results of a generation task.

## Endpoint

```
GET https://api.apixo.ai/api/v1/statusTask/{model}?taskId={taskId}
```

## Parameters

**model** `string` *required*

Model ID used when the task was submitted (e.g., `nano-banana`, `flux-2`).

**taskId** `string` *required*

Task ID returned from the [Generate Task](https://apixo.ai/docs/api-reference/generate-task.md) endpoint.

## Headers

**Authorization** `string` *required*

Bearer token for API authentication. Format: `Bearer YOUR_API_KEY`

## Response

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://cdn.apixo.ai/output/abc123.jpg\"]}",
    "costTime": 12500,
    "createTime": 1704067200000,
    "completeTime": 1704067212500
  }
}
```

### Task States

| State | Description |
| - | - |
| `pending` | Task received, waiting to be processed |
| `processing` | Task is being processed by the AI model |
| `success` | Generation completed successfully |
| `failed` | Generation failed (see error details) |

### Response Fields

**taskId** `string`

Unique task identifier.

**state** `string`

Current task state: `pending`, `processing`, `success`, or `failed`.

**resultJson** `string`

JSON string containing `resultUrls` array. Only present when `state` is `success`. Parse with `JSON.parse()`.

**costTime** `integer`

Processing time in milliseconds. Only present on completion.

**createTime** `integer`

Task creation timestamp (Unix milliseconds).

**completeTime** `integer`

Task completion timestamp (Unix milliseconds). Only present on completion.

**failCode** `string`

Error code. Only present when `state` is `failed`.

**failMsg** `string`

Human-readable error message. Only present when `state` is `failed`.

**billing** `object`

Optional final billing snapshot. Present only for models that publish settled billing details in successful terminal responses.

**billing.settlementState** `string`

Settlement status for the billing snapshot. For final settled data, the value is `final`.

**billing.unit** `string`

Unit used by duration-based billing fields, such as `second`.

## State-Specific Responses

### Pending / Processing

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "processing",
    "createTime": 1704067200000
  }
}
```

### Success

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://cdn.apixo.ai/output/abc123.jpg\"]}",
    "costTime": 12500,
    "createTime": 1704067200000,
    "completeTime": 1704067212500
  }
}
```

**Parsing resultJson:**

```javascript theme={null}
const result = JSON.parse(data.resultJson);
const urls = result.resultUrls; // Array of generated content URLs
```

### Failed

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_abc123xyz789",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content violates usage policy",
    "createTime": 1704067200000,
    "completeTime": 1704067205000
  }
}
```

> [!NOTE]
>
> HTTP `200` with `state: "failed"` means the API request succeeded but the task itself failed. Check `failCode` and `failMsg` for the reason. See [Errors](https://apixo.ai/docs/api-reference/errors.md) for all failure codes.

## Result URLs

The `resultUrls` array contains direct links to generated content:

```json theme={null}
{
  "resultUrls": [
    "https://cdn.apixo.ai/output/abc123.jpg",
    "https://cdn.apixo.ai/output/abc124.jpg"
  ]
}
```

> [!WARNING]
>
> Result URLs expire after 24 hours. Download and store important outputs promptly.

## Examples

> [tab] cURL
>
> ```bash theme={null}
> curl "https://api.apixo.ai/api/v1/statusTask/nano-banana?taskId=task_abc123" \
>   -H "Authorization: Bearer YOUR_API_KEY"
> ```

> [tab] JavaScript
>
> ```javascript theme={null}
> const response = await fetch(
>   'https://api.apixo.ai/api/v1/statusTask/nano-banana?taskId=task_abc123',
>   {
>     headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
>   }
> );
> const { data } = await response.json();
>
> if (data.state === 'success') {
>   const urls = JSON.parse(data.resultJson).resultUrls;
>   console.log('Generated:', urls);
> }
> ```

> [tab] Python
>
> ```python theme={null}
> import json
>
> response = requests.get(
>     'https://api.apixo.ai/api/v1/statusTask/nano-banana',
>     params={'taskId': 'task_abc123'},
>     headers={'Authorization': 'Bearer YOUR_API_KEY'},
> )
>
> data = response.json()['data']
>
> if data['state'] == 'success':
>     urls = json.loads(data['resultJson'])['resultUrls']
>     print(f'Generated: {urls}')
> ```

## Polling Example

> [tab] JavaScript
>
> ```javascript theme={null}
> async function waitForResult(model, taskId, apiKey) {
>   const maxAttempts = 60;
>   const pollInterval = 3000; // 3 seconds
>
>   for (let i = 0; i < maxAttempts; i++) {
>     const response = await fetch(
>       `https://api.apixo.ai/api/v1/statusTask/${model}?taskId=${taskId}`,
>       { headers: { 'Authorization': `Bearer ${apiKey}` } }
>     );
>
>     const { data } = await response.json();
>
>     switch (data.state) {
>       case 'success':
>         return JSON.parse(data.resultJson).resultUrls;
>       case 'failed':
>         throw new Error(`${data.failCode}: ${data.failMsg}`);
>       default:
>         await new Promise(r => setTimeout(r, pollInterval));
>     }
>   }
>
>   throw new Error('Timeout waiting for result');
> }
> ```

> [tab] Python
>
> ```python theme={null}
> import time
> import json
>
> def wait_for_result(model: str, task_id: str, api_key: str) -> list[str]:
>     max_attempts = 60
>     poll_interval = 3  # seconds
>
>     for _ in range(max_attempts):
>         response = requests.get(
>             f'https://api.apixo.ai/api/v1/statusTask/{model}',
>             params={'taskId': task_id},
>             headers={'Authorization': f'Bearer {api_key}'},
>         )
>
>         data = response.json()['data']
>
>         if data['state'] == 'success':
>             return json.loads(data['resultJson'])['resultUrls']
>         elif data['state'] == 'failed':
>             raise Exception(f"{data['failCode']}: {data['failMsg']}")
>
>         time.sleep(poll_interval)
>
>     raise Exception('Timeout waiting for result')
> ```

## Error Responses

| Code | Description |
| - | - |
| `401` | Invalid or missing API key |
| `404` | Task not found |
| `429` | Rate limit exceeded |

See [Errors](https://apixo.ai/docs/api-reference/errors.md) for detailed error handling.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.