# Introduction

> The Mynth HTTP API. Base URL, authentication, response shapes, and every endpoint, generated from the OpenAPI document.

Every endpoint lives under `https://api.mynth.io`, with no version prefix. It
speaks JSON, except `POST /image/upload`, which takes multipart form data. It
authenticates with a bearer token. No SDK is required.

The endpoint pages are generated from the API's OpenAPI document, so every
parameter they list is one the API validates. The document itself is at
[api.mynth.io/openapi.json](https://api.mynth.io/openapi.json).

```bash
curl https://api.mynth.io/image/generate \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"black-forest-labs/flux.2-pro","prompt":"A lighthouse at dusk"}'
```

## Conventions

- **Generation is asynchronous.** A generate call returns a task, not media.
  Poll the task or receive a [webhook](https://mynth.io/docs/concepts/webhooks.md).
  [The task object](https://mynth.io/docs/api-reference/task-object.md) covers every field.
- **Successful bodies are wrapped in `data`.** Errors are not: they carry
  `code` and usually `message` at the top level. See
  [errors](https://mynth.io/docs/api-reference/errors.md).
- **Money is a decimal string in USD**, such as `"0.03"`. Parse it with a
  decimal type, not a float.
- **Ids have prefixes:** `tsk_` tasks, `img_` images, `vid_` videos, `ak_` API
  keys, `wbh_` webhooks, `dst_` destinations.
- **Unknown request fields are dropped**, not rejected. Check the task's
  echoed `request` when a setting seems to have no effect.
- **There are no idempotency keys.** Every create is a new task and a new
  hold. See [what is safe to retry](https://mynth.io/docs/api-reference/errors.md#what-is-safe-to-retry).

## Credentials

**API key**

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

**Public access token**

```bash
curl https://api.mynth.io/tasks/tsk_01KE7XWWEQ4MCGWKBQKJ1G47RP/status \
  -H "Authorization: Bearer pat_eyJhbGciOiJIUzI1NiJ9..."
```

An API key belongs on a server. A public access token comes with a task,
expires after an hour, and can only read that task's status and result, which
is why it is safe in browser code. [Authentication](https://mynth.io/docs/api-reference/authentication.md)
has the rules for both, and the scope each endpoint needs.

## Endpoints

### Image

- `POST /image/generate` [Generate image](https://mynth.io/docs/api-reference/endpoints/image/generate.md)
- `POST /image/generate/estimate` [Estimate cost](https://mynth.io/docs/api-reference/endpoints/image/estimate.md)
- `POST /image/upload` [Upload images](https://mynth.io/docs/api-reference/endpoints/image/upload.md)
- `POST /image/alt` [Generate alt text](https://mynth.io/docs/api-reference/endpoints/image/alt.md)
- `POST /image/review` [Review image](https://mynth.io/docs/api-reference/endpoints/image/review.md)
- `POST /image/rate` [Rate image](https://mynth.io/docs/api-reference/endpoints/image/rate.md)
- `POST /image/remove-background` [Remove background](https://mynth.io/docs/api-reference/endpoints/image/remove-background.md)

### Video

- `POST /video/generate` [Generate video](https://mynth.io/docs/api-reference/endpoints/video/generate.md)
- `POST /video/generate/estimate` [Estimate cost](https://mynth.io/docs/api-reference/endpoints/video/estimate.md)

### Tasks

- `GET /tasks` [List tasks](https://mynth.io/docs/api-reference/endpoints/tasks/list.md)
- `GET /tasks/{id}` [Get task](https://mynth.io/docs/api-reference/endpoints/tasks/get.md)
- `GET /tasks/{id}/status` [Get task status](https://mynth.io/docs/api-reference/endpoints/tasks/status.md)
- `GET /tasks/{id}/result` [Get task result](https://mynth.io/docs/api-reference/endpoints/tasks/result.md)

### Models

- `GET /models` [List models](https://mynth.io/docs/api-reference/endpoints/models/list.md)

### Destinations

- `POST /destinations` [Create destination](https://mynth.io/docs/api-reference/endpoints/destinations/create.md)
- `GET /destinations` [List destinations](https://mynth.io/docs/api-reference/endpoints/destinations/list.md)
- `GET /destinations/{id}` [Get destination](https://mynth.io/docs/api-reference/endpoints/destinations/get.md)
- `PUT /destinations/{id}` [Update destination](https://mynth.io/docs/api-reference/endpoints/destinations/update.md)
- `DELETE /destinations/{id}` [Delete destination](https://mynth.io/docs/api-reference/endpoints/destinations/delete.md)
- `POST /destinations/{id}/test` [Test destination](https://mynth.io/docs/api-reference/endpoints/destinations/test.md)

### Webhooks

- `POST /webhook` [Create webhook](https://mynth.io/docs/api-reference/endpoints/webhooks/create.md)
- `PUT /webhook/{id}` [Update webhook](https://mynth.io/docs/api-reference/endpoints/webhooks/update.md)
- `DELETE /webhook/{id}` [Delete webhook](https://mynth.io/docs/api-reference/endpoints/webhooks/delete.md)

### API keys

- `POST /api-key` [Create API key](https://mynth.io/docs/api-reference/endpoints/api-keys/create.md)
- `GET /api-key` [List API keys](https://mynth.io/docs/api-reference/endpoints/api-keys/list.md)
- `PUT /api-key/{id}` [Update API key](https://mynth.io/docs/api-reference/endpoints/api-keys/update.md)
- `DELETE /api-key/{id}` [Delete API key](https://mynth.io/docs/api-reference/endpoints/api-keys/delete.md)

### Account

- `GET /me` [Get account](https://mynth.io/docs/api-reference/endpoints/account/get.md)
- `GET /balance` [Get balance](https://mynth.io/docs/api-reference/endpoints/account/balance.md)

### System

- `GET /health` [Check health](https://mynth.io/docs/api-reference/endpoints/system/health.md)
