# Create destination

> Registers a bucket Mynth can deliver finished media to. The secret is write-only: it is stored encrypted and never returned by any endpoint. `name` is the slug you reference from a task's `destination` field, and it cannot be changed afterwards.

A destination is storage of yours that Mynth writes finished images into, so
`url` on the result points at your own domain. Name it on a generation request
with its `name`, not its id.

The secret is write-only: it is stored in a vault and no endpoint returns it.
`name` cannot be changed later. [Destinations](https://mynth.io/docs/concepts/destinations.md#path-and-url-templates)
covers the path and URL templates, which is where most of the configuration
is.

`POST /destinations`

**Auth:** API key or OAuth token

## Request body

### r2

- `config` (required, object)
  - `path_template` (required, string) — ≤ 2048 characters.
  - `url_template` (string) — URL template used to create an image URL. It must include a `{path}` which is a resolved path to file from `path_template`. Example: path_template -> "/images/{id}" On upload `path` becomes `/images/img_si1EywtFZMvDArkcVSSsN759VFNbHtE_.webp` url_template: "https://my-cdn.my-domain.com/{path}" The `url` in the response will be: "https://my-cdn.my-domain.com/images/img_si1EywtFZMvDArkcVSSsN759VFNbHtE_.webp" Note: The double `//` are automatically removed and replaced with single slash.
- `name` (required, string) — Destination slug. Immutable after creation. Matches /^[a-z0-9-]+$/. ≥ 1 characters, ≤ 64 characters.
- `provider` (required, object)
  - `account_id` (required, string)
  - `bucket` (required, string)
  - `id` (required, "r2")
  - `jurisdiction` (string) — One of: `"default"`, `"eu"`, `"fedramp"`.
- `secret` (required, object)
  - `access_key_id` (required, string)
  - `secret_access_key` (required, string)

### s3

- `config` (required, object)
  - `path_template` (required, string) — ≤ 2048 characters.
  - `url_template` (string) — URL template used to create an image URL. It must include a `{path}` which is a resolved path to file from `path_template`. Example: path_template -> "/images/{id}" On upload `path` becomes `/images/img_si1EywtFZMvDArkcVSSsN759VFNbHtE_.webp` url_template: "https://my-cdn.my-domain.com/{path}" The `url` in the response will be: "https://my-cdn.my-domain.com/images/img_si1EywtFZMvDArkcVSSsN759VFNbHtE_.webp" Note: The double `//` are automatically removed and replaced with single slash.
- `name` (required, string) — Destination slug. Immutable after creation. Matches /^[a-z0-9-]+$/. ≥ 1 characters, ≤ 64 characters.
- `provider` (required, object)
  - `bucket` (required, string)
  - `id` (required, "s3")
  - `region` (required, string)
  - `endpoint` (string)
  - `force_path_style` (boolean)
- `secret` (required, object)
  - `access_key_id` (required, string)
  - `secret_access_key` (required, string)

### bunny

- `config` (required, object)
  - `path_template` (required, string) — ≤ 2048 characters.
  - `url_template` (string) — URL template used to create an image URL. It must include a `{path}` which is a resolved path to file from `path_template`. Example: path_template -> "/images/{id}" On upload `path` becomes `/images/img_si1EywtFZMvDArkcVSSsN759VFNbHtE_.webp` url_template: "https://my-cdn.my-domain.com/{path}" The `url` in the response will be: "https://my-cdn.my-domain.com/images/img_si1EywtFZMvDArkcVSSsN759VFNbHtE_.webp" Note: The double `//` are automatically removed and replaced with single slash.
- `name` (required, string) — Destination slug. Immutable after creation. Matches /^[a-z0-9-]+$/. ≥ 1 characters, ≤ 64 characters.
- `provider` (required, object)
  - `id` (required, "bunny")
  - `storage_zone` (required, string)
  - `region` (string) — One of: `"br"`, `"de"`, `"jh"`, `"la"`, `"ny"`, `"se"`, `"sg"`, `"syd"`, `"uk"`.
- `secret` (required, object)
  - `password` (required, string)

## Response

### 201 — Destination created

- `data` (required, object)
  - `config` (required, json | null)
  - `createdAt` (required, any)
  - `id` (required, string)
  - `name` (required, string)
  - `provider` (required, json | null)
  - `updatedAt` (required, any)

```json
{
  "data": {
    "config": {},
    "id": "string",
    "name": "string",
    "provider": {}
  }
}
```

## Request samples

### cURL

```bash
curl -X POST https://api.mynth.io/destinations \
  -H "Authorization: Bearer $MYNTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "config": {
      "path_template": "string"
    },
    "name": "string",
    "provider": {
      "account_id": "string",
      "bucket": "string",
      "id": "r2"
    },
    "secret": {
      "access_key_id": "string",
      "secret_access_key": "string"
    }
  }'
```

### JavaScript

```ts
const response = await fetch("https://api.mynth.io/destinations", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MYNTH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "config": {
      "path_template": "string"
    },
    "name": "string",
    "provider": {
      "account_id": "string",
      "bucket": "string",
      "id": "r2"
    },
    "secret": {
      "access_key_id": "string",
      "secret_access_key": "string"
    }
  }),
});

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

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