> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.mindrift.art/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.mindrift.art/_mcp/server.

# Image Retention

Every completed generation provides a hosted URL on the Mindrift CDN (`cdn.mindrift.art`). By default, generated assets are retained indefinitely. You can control retention by configuring automatic expiration with `ttl` or by deleting images manually via the API.

---

## Default Retention

If you omit `ttl` (or pass `ttl: null`), your images are stored indefinitely and remain accessible at their CDN URL.

---

## Automatic Expiration (`ttl`)

To configure automatic expiration, pass `ttl` (lifetime in seconds) when requesting an image:

* `POST /v1/images/generations` (synchronous)
* `POST /v1/text-to-image/subscribe/{model}` (asynchronous)

| Parameter         | Value                                             |
| :---------------- | :------------------------------------------------ |
| Minimum           | `3600` (1 hour)                                   |
| Maximum           | `2592000` (30 days)                               |
| Omitted or `null` | Retained indefinitely                             |
| Invalid values    | `400 Bad Request` (`invalid_ttl` / `INVALID_TTL`) |

The expiration time is computed from the creation timestamp. API responses include the resulting expiration date as `expires_at` (ISO 8601 timestamp):

```json
{
  "created": 1757930400,
  "data": [
    {
      "id": "ef661acb-a140-4e68-b94f-0de439ed350d",
      "url": "https://cdn.mindrift.art/jobs/.../....webp",
      "revised_prompt": "An astronaut riding a horse on Mars",
      "expires_at": "2026-09-16T10:00:00.000Z"
    }
  ]
}
```

Once expired, the media assets are permanently removed and their CDN URLs become inaccessible. If you use [Webhooks](/docs/core/webhooks), `expires_at` is included in the webhook payload so your services can download or archive files before expiration.

---

## Manual Deletion

You can permanently delete any hosted image at any time using the image deletion endpoint:

```bash
curl -X DELETE https://api.mindrift.art/v1/images/ef661acb-a140-4e68-b94f-0de439ed350d \
  -H "Authorization: Bearer $MINDRIFT_API_KEY"
```

```json
{
  "object": "image",
  "id": "ef661acb-a140-4e68-b94f-0de439ed350d",
  "status": "purged",
  "purged": true,
  "purged_at": "2026-09-15T11:02:11.000Z"
}
```

* **Identifier**: Use the image or task ID returned during generation.
* **Idempotent**: Deleting an already purged image returns `200 OK`.
* **Security**: Requesting non-existent IDs or images belonging to another account returns `404 Not Found`.
* **Immediate**: Media is removed immediately from storage and edge caches.

---

## Post-Deletion Behavior

After an image is deleted (either automatically via `ttl` or manually):

* The CDN URL immediately returns `404 Not Found`.
* The task record remains accessible via `GET /v1/tasks/{task_id}`, with `output.images` emptied, `purged: true`, and `purged_at` populated.
* Generation logs, parameters, and billing records remain preserved for your account history.

---

## Error Handling

If a manual deletion request cannot be completed, the API returns `502 Bad Gateway` (`IMAGE_PURGE_FAILED`). You can safely retry the request.