# Copy an image into the library

Source: https://kirora.io/docs/api/reference/importAsset

`POST /v1/assets/import`

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

Works with integration, agent and partner keys.

A repeat without a key does it again; send `Idempotency-Key` and a retry within 24 hours replays the first response. [About idempotency](https://kirora.io/docs/api/reference/idempotency)

Copies the image at a public address into this workspace, checked as an upload is (PNG, JPEG or GIF, at most 2 MB and 25 megapixels), so an email never depends on another site keeping it: images hosted where your email was made before, a logo from your site, or a video block's thumbnail (a YouTube or Vimeo page's address copies its thumbnail). Only public addresses are reached; anything that is not such an image is a 400.

## Header parameters

- `Kirora-Workspace` (string, optional, pattern `^[A-Za-z0-9._:-]{1,128}$`) — Partner keys only: the child workspace to act in, by the external id the partner gave it. Without it, a partner key acts in its own workspace. Any other key that sends it is refused with 403, and an unknown workspace is 404.
- `Idempotency-Key` (string, optional, 8–255 characters) — Makes a retry safe: a repeat with the same key and body within 24 hours gets the first response again, with `Idempotency-Replay: true`. The same key with another request is 409 `IDEMPOTENCY_KEY_REUSED`; while the first is still running, 409 `IDEMPOTENCY_KEY_IN_USE`; after an `unsafe` first request failed or never returned, 409 `IDEMPOTENCY_KEY_OUTCOME_UNKNOWN`. Use a new key, such as a UUID, for each new request.

## Request body

- `url` (string, required, uri, up to 2,048 characters) — A public PNG, JPEG or GIF of at most 2 MB, such as a logo on your current site; or a YouTube or Vimeo video page, whose thumbnail is copied.
- `name` (string, optional, 1–200 characters) — The name the library shows, up to 200 characters; the file's name when omitted.

## Returns

Returns `201 Created` with an `Asset` in `data`. It can also return `409 Conflict`, `413 Payload Too Large` or `415 Unsupported Media Type`; see the statuses below. Otherwise returns an error; [Errors](https://kirora.io/docs/api/reference/errors) lists every code and which to retry.

- `id` (string, required, uuid)
- `type` (string, required, one of `image`) — The kind of file: `image`. More kinds, such as `video`, may be added: branch on `type` and keep the ones you do not know.
- `name` (string, required) — The name the library shows.
- `filename` (string, required) — The file's name as uploaded or copied.
- `url` (string, required, uri) — The file's public address, such as an image `src`.
- `mimeType` (string, required, one of `image/png`, `image/jpeg`, `image/gif`) — The file's format.
- `sizeBytes` (integer, required, min > 0) — File size in bytes.
- `width` (integer, required, min > 0) — The file's width in px.
- `height` (integer, required, min > 0) — The file's height in px.
- `createdAt` (string, required, date-time)

Statuses:

- `201 Created`: The copied image and its public URL.
- `409 Conflict`: The request conflicts with current state — a duplicate unique value, or a resource whose status does not allow this operation.
- `413 Payload Too Large`: The body is larger than this operation accepts (`PAYLOAD_TOO_LARGE`).
- `415 Unsupported Media Type`: The body is not JSON, or not the upload the operation takes (`UNSUPPORTED_MEDIA_TYPE`).

Headers on `201 Created`:

- `Idempotency-Replay` (string, optional, one of `true`) — `true` when this is the stored response to an earlier request with the same key.

## Example: Copy a logo from where it is hosted now

```bash
curl -X POST https://api.kirora.io/v1/assets/import \
  -H "Authorization: Bearer $KIRORA_API_KEY" \
  -H "Idempotency-Key: importAsset-0001" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://acme-shop.com/images/acme-logo.png",
    "name": "Acme logo"
  }'
```

Response `201`:

```json
{
  "data": {
    "id": "0192f3d2-4d5e-7f60-9b72-8d9e0f1a2b3c",
    "type": "image",
    "name": "Acme logo",
    "filename": "acme-logo.png",
    "url": "https://assets.kirora.io/images/0192f3d2-4d5e-7f60-9b72-8d9e0f1a2b3c.png",
    "mimeType": "image/png",
    "sizeBytes": 18432,
    "width": 600,
    "height": 200,
    "createdAt": "2026-10-01T09:30:00.000Z"
  }
}
```
