> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a schedule for a tenant.

> Create a schedule for a tenant.

### Path parameters

<ParamField path="tenant_id" type="string" required>
  Tenant identifier
</ParamField>

### Request body

`object`

<ParamField body="jobType" type="string" required />

<ParamField body="everySeconds" type="integer">
  Interval in seconds (required for interval triggers, ignored for cron)
</ParamField>

<ParamField body="cronExpression" type="string">
  Cron expression (e.g. '0 \*/5 \* \* \* \*' for every 5 minutes)
</ParamField>

<ParamField body="enabled" type="boolean" />

### Response

`object`

<ResponseField name="scheduleId" type="string (uuid)" required />

<ResponseField name="tenantId" type="string" required />

<ResponseField name="jobType" type="string" required />

<ResponseField name="everySeconds" type="integer" required />

<ResponseField name="enabled" type="boolean" required />

<ResponseField name="nextRunAt" type="string (date-time)" required />

<ResponseField name="lastRunAt" type="string (date-time)" />

<ResponseField name="lastError" type="string" />

<ResponseField name="consecutiveFailures" type="integer" required />

<ResponseField name="createdAt" type="string (date-time)" required />

<ResponseField name="updatedAt" type="string (date-time)" required />

<ResponseField name="cronExpression" type="string" />

<ResponseField name="triggerType" type="string" required />

<ResponseField name="maxConsecutiveFailures" type="integer" required />

### Status codes

| Code  | Meaning                 |
| ----- | ----------------------- |
| `201` | Schedule created        |
| `401` | Unauthorized            |
| `422` | Validation error        |
| `424` | Database not configured |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.sync.stateset.com/v1/tenants/{tenant_id}/schedules' \
    --header 'x-stateset-api-key: YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
    "jobType": "string",
    "everySeconds": 250,
    "cronExpression": "string",
    "enabled": true
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "scheduleId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "tenantId": "acme-outdoors",
    "jobType": "string",
    "everySeconds": 250,
    "enabled": true,
    "nextRunAt": "2026-08-31T14:22:05Z",
    "lastRunAt": "2026-08-31T14:22:05Z",
    "lastError": "string",
    "consecutiveFailures": 1,
    "createdAt": "2026-08-31T14:22:05Z",
    "updatedAt": "2026-08-31T14:22:05Z",
    "cronExpression": "string",
    "triggerType": "string",
    "maxConsecutiveFailures": 1
  }
  ```
</ResponseExample>
