---
title: "createSchedule"
---

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

# createSchedule

Path: agenthold API › triggers

`POST /agents/{agentId}/schedules`

URL: `/api/v1/agents/{agentId}/schedules`

Agent admin. The schedule prompts its own session as you.

## Authentication

Requires one of the following:

- `session`, apiKey, in cookie
- `token`, http bearer, header `Authorization`

## Path parameters

- `agentId` (`createSchedule.path.agentId`; string, required)

## Request body

_Required._

- `name` (`createSchedule.name`; string, required)
  - maxLength: `100` · minLength: `1`
- `cron` (`createSchedule.cron`; string, required) — Five fields (minute hour day month weekday) or @hourly, @daily, @weekly.
- `prompt` (`createSchedule.prompt`; string, required)
  - minLength: `1`
- `timezone` (`createSchedule.timezone`; string, optional) — IANA time zone. Default UTC.
- `enabled` (`createSchedule.enabled`; boolean, optional)

## Example request

```json
{
  "name": "string",
  "cron": "string",
  "timezone": "string",
  "prompt": "string",
  "enabled": true
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url '<base-url>/api/v1/agents/<agentId>/schedules' \
  --header 'Content-Type: application/json' \
  --cookie 'agenthold_session=<agenthold_session>' \
  --data '
{
  "name": "string",
  "cron": "string",
  "timezone": "string",
  "prompt": "string",
  "enabled": true
}
'
```

### TypeScript

```typescript
const url = '<base-url>/api/v1/agents/<agentId>/schedules';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    cookie: 'agenthold_session=<agenthold_session>'
  },
  body: JSON.stringify({
    name: 'string',
    cron: 'string',
    timezone: 'string',
    prompt: 'string',
    enabled: true
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "<base-url>/api/v1/agents/<agentId>/schedules"

payload = {
    "name": "string",
    "cron": "string",
    "timezone": "string",
    "prompt": "string",
    "enabled": True
}
headers = {
    "cookie": "agenthold_session=<agenthold_session>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

Created.

#### Example

```json
{
  "name": "string",
  "cron": "string",
  "timezone": "string",
  "prompt": "string",
  "enabled": true,
  "id": "string",
  "agentId": "string",
  "sessionId": "string",
  "createdBy": {
    "id": "string",
    "email": "string",
    "name": "string",
    "avatarUrl": "string"
  },
  "nextRunAt": "2019-08-24T14:15:22Z",
  "lastRunAt": "2019-08-24T14:15:22Z",
  "lastError": "string",
  "createdAt": "2019-08-24T14:15:22Z"
}
```

- `name` (`createSchedule.response.201.name`; string, required)
  - maxLength: `100` · minLength: `1`
- `cron` (`createSchedule.response.201.cron`; string, required) — Five fields (minute hour day month weekday) or @hourly, @daily, @weekly.
- `timezone` (`createSchedule.response.201.timezone`; string, required) — IANA time zone. Default UTC.
- `prompt` (`createSchedule.response.201.prompt`; string, required)
  - minLength: `1`
- `enabled` (`createSchedule.response.201.enabled`; boolean, required)
- `id` (`createSchedule.response.201.id`; string, required)
- `agentId` (`createSchedule.response.201.agentId`; string, required)
- `sessionId` (`createSchedule.response.201.sessionId`; string, required)
- `createdBy` (`createSchedule.response.201.createdBy`; object, required)
  - `id` (`createSchedule.response.201.createdBy.id`; string, required)
  - `email` (`createSchedule.response.201.createdBy.email`; string, required)
  - `name` (`createSchedule.response.201.createdBy.name`; string, required)
  - `avatarUrl` (`createSchedule.response.201.createdBy.avatarUrl`; string, required)
- `nextRunAt` (`createSchedule.response.201.nextRunAt`; string, required)
  - format: `date-time`
- `lastError` (`createSchedule.response.201.lastError`; string, required)
- `createdAt` (`createSchedule.response.201.createdAt`; string, required)
  - format: `date-time`
- `lastRunAt` (`createSchedule.response.201.lastRunAt`; string, optional)
  - format: `date-time`

### 400

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createSchedule.response.400.error`; string, required)

### 403

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createSchedule.response.403.error`; string, required)

### 404

Error.

#### Example

```json
{
  "error": "string"
}
```

- `error` (`createSchedule.response.404.error`; string, required)


Source: https://agenthold.dev/api/create-schedule/index.md
