# Query tasks & retrieve results

Poll with the same API key. Querying status never creates another generation.

## Retrieve a task

Replace TASK_ID with a returned UUID. Poll every five seconds or more. Use a bounded polling window, then save the ID and resume later for a long video.

```
curl --fail-with-body 'https://gikyapi.com/v1/tasks/TASK_ID' -H 'Authorization: Bearer YOUR_API_KEY'
```

## Task states

Use status rather than assuming a fixed generation time.

| Status | Meaning | What your application should do |
| --- | --- | --- |
| queued | Recorded, waiting for processing | Continue polling |
| submitting | Submission in progress | Continue polling; do not resubmit |
| running | Task accepted and being tracked | Continue polling |
| succeeded | Output URLs available | Read outputs and save files |
| failed | Task failed or cancelled before submission | Inspect usage/refund and error_code |
| needs_review | Outcome uncertain; reconciliation required | Stop automatic resubmission; keep task ID |

## Successful response

outputs is an array of HTTPS strings. There is no promised percentage progress, fixed completion time, or file-expiry timestamp in this response.

```
{
  "id": "00000000-0000-4000-8000-000000000001",
  "status": "succeeded",
  "outputs": [
    "https://media.example/result.png"
  ],
  "error_code": null,
  "created_at": "2026-11-02T00:00:00Z",
  "updated_at": "2026-11-02T00:01:00Z"
}
```

## List and paginate

GET /v1/tasks?limit=20 returns data and next_cursor. limit ranges from 1 to 100. Pass next_cursor as before on the next call. Only the current key’s tasks are listed.

```
curl 'https://gikyapi.com/v1/tasks?limit=20' -H 'Authorization: Bearer YOUR_API_KEY'
```

## Cancel before submission

POST /v1/tasks/{id}/cancel with JSON {}. This only cancels a task that has not been submitted. HTTP 409 means cancellation is no longer available. Cancellation returns status failed with error_code cancelled_before_submit; it does not stop a running upstream generation.
