# Import an image from a URL

`POST /v1/assets/import`

- Authentication: required (Bearer token)
- Required scope: `api.assets.manage`

Fetches the image at `url` into the asset library and returns the
`{{asset}}` reference to use in its place — the fix an
`external_image` notice offers. Only public addresses are fetched,
with a 15-second timeout and at most three redirects.

It is an upload whose bytes come from a URL, so the format allowlist,
the 5 MiB limit, the storage quota and `409 edge_cdn_not_provisioned`
are the upload's. Two things differ: the path is chosen for you —
`imported/<name>-<hash8>.<ext>`, named by the stored bytes, so
importing the same image again answers `unchanged: true` with the same
path — and an **SVG is converted to PNG** rather than refused.

**Your template is not changed.** You own its source; replace
`source_url` with `reference` there and push again.

## Request body

Content type: `application/json`

```json
{
  "url": "https://example.com/images/logo.svg"
}
```

## Example request

```bash
curl -X POST 'https://api.sendops.dev/v1/assets/import' \
  -H "Authorization: Bearer $SENDOPS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/images/logo.svg"}'
```

## Responses

### 200 — The stored image. `unchanged` is true when it was already in the library.

Content type: `application/json`

```json
{
  "id": "00000000-0000-0000-0000-000000000000",
  "source_path": "string",
  "url": "string",
  "content_hash": "string",
  "content_type": "string",
  "size_bytes": 0,
  "width": 0,
  "height": 0,
  "created_at": "2026-05-17T20:00:00Z",
  "referenced_by": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "name": "string"
    }
  ],
  "tags": [
    {
      "id": "00000000-0000-0000-0000-000000000000",
      "name": "string",
      "key": "string",
      "color": "string",
      "description": "string",
      "created_at": "2026-05-17T20:00:00Z",
      "updated_at": "2026-05-17T20:00:00Z"
    }
  ],
  "unchanged": true,
  "reference": "string",
  "source_url": "string",
  "converted_from_svg": true
}
```

### 401 — Missing, malformed, or unknown API key

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 402 — The organization's plan does not allow this (`code: plan_limit_exceeded`). `limit_type` names the limit — a usage axis such as `contacts`, `segments` or `active_workflows`, or a feature the plan does not include (`inboxes`, `platform_profile`, `audit_log`, `notification_presets`). `upgrade_url` is the dashboard page that lifts it; `overage_available` says a Business organization can lift it by switching overage on instead. Retrying will not succeed until the plan changes or usage drops below the limit.

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ],
  "limit_type": "string",
  "current": 0,
  "limit": 0,
  "plan_tier": "string",
  "upgrade_tier": "string",
  "upgrade_url": "https://example.com",
  "overage_available": true,
  "purchase_available": true,
  "unit_cents": 0,
  "would_add": 0
}
```

### 403 — Key lacks the required scope or plan limit violated

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 409 — The mutation is rejected by a state rule rather than a bad request. The
`code` is `conflict`.

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 422 — A query parameter, path value or body field failed validation.

The body is a `validation_failed` Problem. When the refusal is about a
reference — a segment key, template slug, topic or attribute name the
organization does not have — it additionally carries `validation_code`,
`field`, `line`/`column`, `missing`, `candidates` and `next_step`, so a
client can correct the call without a second round of guessing. See
`ValidationProblem`.

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ],
  "validation_code": "invalid_syntax",
  "field": "string",
  "line": 0,
  "column": 0,
  "missing": [
    {
      "kind": "segment",
      "key": "string"
    }
  ],
  "candidates": {},
  "next_step": "string"
}
```

### 429 — Per-org rate limit exceeded

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```

### 500 — Unexpected server-side failure. The `code` is `internal_error`. The
`request_id` field can be quoted to SendOps support to investigate.

Content type: `application/problem+json`

```json
{
  "type": "https://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "invalid_key",
  "request_id": "string",
  "retry_after": 0,
  "retention_days": 0,
  "scope": "string",
  "resource": "string",
  "errors": [
    {
      "field": "string",
      "reason": "string"
    }
  ],
  "attribute_id": "00000000-0000-0000-0000-000000000000",
  "content_hash": "string",
  "differs": [
    "string"
  ]
}
```
