# Create generation

`POST https://api.endless.app/generations`

Source: https://endless.app/docs/api/generations/create

Creates a generation and returns the created row.

## Authentication

- `bearerAuth`: HTTP bearer (JWT)

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Endless-Api-Version` | header | string | no | Pin the caller to an API major (`1`). Omit to accept the current version. A major this deployment cannot serve is refused with 400 `unsupported_api_version`. |

## Request body

Required.

Content type: `application/json` — object

- `organization_id` (string, required)
- `output_type` ("image" | "video" | "audio", required)
- `model_id` (string | null)
- `fallback_model_id` (string | null)
- `version_id` (string (uuid) | null)
- `quick_action_id` (string (uuid) | null)
- `parameters` (object)
- `id` (string (uuid))
- `canvas_id` (string (uuid) | null)
- `canvas_position` (object | null)
  - `x` (number, required)
  - `y` (number, required)
- `canvas_size` (object | null)
  - `w` (number, required)
  - `h` (number, required)
- `page_id` (string | null)
- `conversation_id` (string (uuid) | null)
- `message_id` (string (uuid) | null)
- `tool_call_id` (string | null)
- `source_generation_id` (string (uuid) | null)
- `max_credits` (number)
- `dispatch` ("auto" | "inline")

## Responses

### 200 OK

Content type: `application/json` — object

- `generation_id` (string, required)
- `reused` (boolean, required)
- `status` ("running" | "completed" | "failed", required)
- `model` (object, required)
  - `id` (string, required)
  - `name` (string, required)
- `quote` (object, required)
  - `per_output` (number, required)
  - `count` (integer, required)
  - `total` (number, required)
- `credits_charged` (number, required)
- `assets` (array<object>, required)
  - `asset_id` (string, required)
  - `url` (string, required)
  - `type` (string, required)

### Errors

- `400` (Error): The request is malformed, or failed input validation. `message` names the field and the rule it broke; `data.issues` carries them individually.
- `401` (Error): No bearer token, or a token that failed verification.
- `402` (Error): The workspace has no credits left, or the caller is over a spending limit.
- `403` (Error): Authenticated, but the caller's role in this workspace does not carry the permission this operation needs.
- `409` (Error): The request is well-formed, but the resource's current state forbids it — a taken name, a last admin, a limit already reached.
- `429` (Error): The caller has spent its rate-limit window. `Retry-After` says when to come back.
- `500` (Error): The request failed on our side. Safe to retry an idempotent operation with backoff.
