# Create scheduled task

`POST https://api.endless.app/scheduled-tasks`

Source: https://endless.app/docs/api/scheduled-tasks/create

Creates a scheduled task 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)
- `name` (string, required)
- `prompt` (string, required)
- `model` (string, required)
- `chat_model_id` (string (uuid))
- `media_model` (string)
- `media_intent` ("image" | "video")
- `cadence` (object, required)
- `time` (string, required)
- `timezone` (string, required)
- `visibility` ("private" | "workspace")
- `workspace_role` ("viewer" | "editor")
- `grants` (array<object>)
  - `user_id` (string, required)
  - `role` ("viewer" | "editor", required)
- `disabled_connector_ids` (array<string (uuid)>)
- `disabled_skill_ids` (array<string (uuid)>)
- `email_enabled` (boolean)
- `email_recipient_ids` (array<string>)
- `email_recipient_emails` (array<string (email)>)

## Responses

### 200 OK

Content type: `application/json` — object

- `scheduled_task` (object, required)
  - `id` (string (uuid), required)
  - `organization_id` (string, required)
  - `created_by_id` (string, required)
  - `name` (string, required)
  - `prompt` (string, required)
  - `model` (string, required)
  - `chat_model_id` (string (uuid) | null, required)
  - `media_model` (string | null, required)
  - `media_model_id` (string (uuid) | null, required)
  - `media_intent` ("image" | "video" | null, required)
  - `cadence` (object | any)
  - `time` (string, required)
  - `timezone` (string, required)
  - `status` ("active" | "paused", required)
  - `visibility` ("private" | "workspace", required)
  - `workspace_role` ("viewer" | "editor" | "owner", required)
  - `email_enabled` (boolean, required)
  - `next_run_at` (string (date-time) | null, required)
  - `last_run_at` (string (date-time) | null, required)
  - `mod_schedule_id` (string | null, required)
  - `deleted_at` (string (date-time) | null, required)
  - `deleted_by_id` (string | null, required)
  - `created_at` (string (date-time), required)
  - `updated_at` (string (date-time), required)
  - `last_run_status` ("in_progress" | "success" | "error" | "cancelled" | null, required)
  - `running_runs` (integer, required)
  - `disabled_connector_ids` (array<string>, required)
  - `disabled_skill_ids` (array<string>, required)
  - `email_recipient_ids` (array<string>, required)
  - `email_recipient_emails` (array<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.
