# Upload an image

`POST /v1/assets`

Requires an API key with the `templates:write` scope. [About keys and scopes](/docs/api/authentication)

Uploads one PNG, JPEG or GIF of at most 2 MB for image blocks, as a multipart file part. The returned `url` is public and stable, so it can go straight into a template.

## Returns

Returns `201 Created` with a `Asset` in `data`. Otherwise returns an error; [Errors](/docs/api/errors) lists every code and which to retry.

- `id` (string, required, uuid)
- `filename` (string, required)
- `url` (string, required, uri) — The public address to use as an image `src`.
- `mimeType` (string, required, one of `image/png`, `image/jpeg`, `image/gif`) — The image format.
- `bytes` (integer, required, min > 0, max 9007199254740991) — File size in bytes.
- `width` (integer, required, min > 0, max 9007199254740991) — Width in px.
- `height` (integer, required, min > 0, max 9007199254740991) — Height in px.
- `createdAt` (string, required, date-time)

## Example

```bash
curl -X POST https://api.kirora.io/v1/assets \
  -H "Authorization: Bearer $KIRORA_API_KEY"
```

Response `201`:

```json
{
  "data": {
    "id": "018f2a4e-6b1c-7d3e-9f40-37386ae05a6b",
    "filename": "filename_example",
    "url": "https://example.com",
    "mimeType": "image/png",
    "bytes": 1,
    "width": 1,
    "height": 1,
    "createdAt": "2030-03-14T09:30:00Z"
  }
}
```
