# List tasks

> Your tasks, newest first, in pages. Each row carries the status and cost but not the request or the result — fetch those from the task itself.

`GET /tasks`

**Auth:** API key or OAuth token

## Query parameters

- `limit` (integer) — How many tasks to return. Default `20`. ≥ 1, ≤ 100.
- `after` (string) — Cursor: return tasks created before this task ID. Example `"tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP"`.

## Response

### 200 — Tasks returned

- `data` (required, object[])
  - `id` (required, string)
  - `type` (required, string) — One of: `"image.generate"`, `"image.rate"`, `"image.alt"`, `"image.review"`, `"image.remove_background"`, `"image.upscale"`, `"video.generate"`.
  - `status` (required, string) — One of: `"pending"`, `"completed"`, `"failed"`.
  - `cost` (required, string | null)
  - `created_at` (required, string) — format: date-time.
  - `updated_at` (required, string) — format: date-time.

```json
{
  "data": [
    {
      "id": "string",
      "type": "image.generate",
      "status": "pending",
      "cost": "string",
      "created_at": "string",
      "updated_at": "string"
    }
  ]
}
```

### 400 — The request was rejected before anything was queued. `error.message` says what to change. A field that failed the schema, or one the endpoint does not take, is also listed in `error.issues`.

- `error` (required, object)
  - `code` (required, string) — `validation_error` for a body that failed validation, `invalid_json` for one that is not JSON. One of: `"validation_error"`, `"invalid_json"`.
  - `message` (required, string) — Every problem, in one sentence each, led by the field it is about.
  - `issues` (object[]) — One entry per field that failed the schema, and one per field the endpoint does not take.
    - `path` (required, (string | integer)[]) — Where the problem is, e.g. `["inputs", 0, "source"]`. Empty for the body as a whole.
    - `message` (required, string)

```json
{
  "error": {
    "code": "validation_error",
    "message": "count: Too big: expected number to be <=20. colour: Unknown field.",
    "issues": [
      {
        "path": [
          "count"
        ],
        "message": "Too big: expected number to be <=20"
      },
      {
        "path": [
          "colour"
        ],
        "message": "Unknown field."
      }
    ]
  }
}
```

## Request samples

### cURL

```bash
curl https://api.mynth.io/tasks?after=tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP \
  -H "Authorization: Bearer $MYNTH_API_KEY"
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/tasks?after=tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
  },
});

const { data } = await response.json();
```

The full schema for this endpoint is in the [OpenAPI document](https://api.mynth.io/openapi.json).
