---
title: "Create schedule"
method: POST
path: "/v1/schedules"
tags: ["Schedules"]
---

# Create schedule

`POST /v1/schedules`

## Request

- Base URL: `https://api.sandbase.ai`
- URL: `https://api.sandbase.ai/v1/schedules`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-Key`

Create a cron Schedule bound to a saved Agent version. Idempotency-Key is required. input must be non-empty. The model credential (model_provider, or your API key when omitted) is stored encrypted and used for scheduled runs.

## Headers

- `Idempotency-Key` string, required

## Request body

- ScheduleCreateRequest
  - `name` string, required
  - `description` string
  - `agent_id` string, required
  - `agent_version` integer: Omit to pin the current Agent version.
  - `input` string, required
  - `model` string
  - `schedule` ScheduleSpec, required
    - `cron` string, required: Five-field cron expression: minute hour day-of-month month day-of-week. Seconds are not supported. An expression with no match in the next 366 days returns 400.
    - `timezone` string: IANA timezone name, such as Asia/Shanghai.
  - `model_provider` ModelProvider: Write-only model credential. Omit it to run with the calling SandBase API key. Never returned.
    - `type` 'sandbase' | 'custom'
    - `base_url` string, uri: Required for custom. HTTPS only, without credentials, query, or fragment. Not allowed for sandbase.
    - `api_key` string: Required for custom. Optional for sandbase, where it defaults to the calling key.

## Response `201`

Schedule created

- RunSourceDefinition
  - `id` string, required: Service (`svc_`) or Schedule (`sch_`) ID.
  - `kind` 'service' | 'schedule', required
  - `name` string, required
  - `description` string, required
  - `agent_id` string, required
  - `agent_version` integer, required: Pinned Agent version.
  - `input` string, required
  - `model` string
  - `status` 'active' | 'paused' | 'archived', required
  - `row_version` integer, required: Schedule row_version also advances after every scheduled tick.
  - `schedule` ScheduleSpec
    - `cron` string, required: Five-field cron expression: minute hour day-of-month month day-of-week. Seconds are not supported. An expression with no match in the next 366 days returns 400.
    - `timezone` string: IANA timezone name, such as Asia/Shanghai.
  - `next_run_at` string, date-time
  - `created_at` string, date-time, required
  - `updated_at` string, date-time, required

## Other responses

- `400`: invalid_request (malformed JSON, unknown fields, failed validation, or an unsupported option)
- `401`: unauthorized: missing, malformed, or conflicting API key headers
- `402`: spending_limit_exceeded: API key spending limit or organization balance exhausted
- `403`: insufficient_scope (scoped key) or org_disabled
- `404`: not_found: the resource does not exist in this organization
- `409`: conflict: stale row_version, lifecycle state, or Idempotency-Key reused with a different body
- `503`: authorization_unavailable, admission_unavailable, executor_unavailable, storage_unavailable, or internal_error

---

[API](https://skmtc.dev/sandbase/apis/sandbase-api.md) · [All operations](https://skmtc.dev/sandbase/apis/sandbase-api/llms.txt) · [OpenAPI document](https://skmtc.dev/sandbase/apis/sandbase-api/revisions/d40df2467ba2?raw)
