> Documentation index for AI agents: https://docs.pagerduty.com/llms.txt

# Create a schedule

`POST https://api.pagerduty.com/schedules`

Create a new on-call schedule.

A Schedule determines the time periods that users are On-Call.

For more information see the [API Concepts Document](https://docs.pagerduty.com/developer/api-concepts#schedules)

Scoped OAuth requires: `schedules.write`

## Authorization

- **api_key** (apiKey) — `Authorization` header. The API Key with format `Token token=<API_KEY>`

## Query parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `overflow` | boolean |  | Any on-call schedule entries that pass the date range bounds will be truncated at the bounds, unless the parameter `overflow=true` is passed. This parameter defaults to false. For instance, if your schedule is a rotation that changes daily at midnight UTC, and your date range is from `2011-06-01T10:00:00Z` to `2011-06-01T14:00:00Z`: - If you don't pass the `overflow=true` parameter, you will get one schedule entry returned with a start of `2011-06-01T10:00:00Z` and end of `2011-06-01T14:00:00Z`. - If you do pass the `overflow=true` parameter, you will get one schedule entry returned with a start of `2011-06-01T00:00:00Z` and end of `2011-06-02T00:00:00Z`. Default: `false`. |

## Header parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Accept` | string | yes | The `Accept` header is used as a versioning header. Default: `application/vnd.pagerduty+json;version=2`. |

## Request body (`application/json`)

The schedule to be created.

| Field | Type | Required | Description |
|---|---|---|---|
| `schedule` | object | yes |  |
| `schedule.id` | string |  | Read-only. |
| `schedule.summary` | string \| null |  | A short-form, server-generated string that provides succinct, important information about an object suitable for primary labeling of an entity in a client. In many cases, this will be identical to `name`, though it is not intended to be an identifier. Read-only. |
| `schedule.type` | string | yes | The type of object being created. One of: `schedule`. Default: `schedule`. |
| `schedule.self` | string \| null (url) |  | the API show URL at which the object is accessible. Read-only. |
| `schedule.html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. Read-only. |
| `schedule.schedule_layers` | array of object |  | A list of schedule layers. |
| `schedule.schedule_layers[].id` | string |  |  |
| `schedule.schedule_layers[].start` | string (date-time) | yes | The start time of this layer. |
| `schedule.schedule_layers[].end` | string (date-time) |  | The end time of this layer. If `null`, the layer does not end. |
| `schedule.schedule_layers[].users` | array of object | yes | The ordered list of users on this layer. The position of the user on the list determines their order in the layer. |
| `schedule.schedule_layers[].users[].user` | object | yes |  |
| `schedule.schedule_layers[].users[].user.id` | string | yes | Read-only. |
| `schedule.schedule_layers[].users[].user.summary` | string \| null |  | A short-form, server-generated string that provides succinct, important information about an object suitable for primary labeling of an entity in a client. In many cases, this will be identical to `name`, though it is not intended to be an identifier. Read-only. |
| `schedule.schedule_layers[].users[].user.type` | string | yes | One of: `user_reference`. |
| `schedule.schedule_layers[].users[].user.self` | string \| null (url) |  | the API show URL at which the object is accessible. Read-only. |
| `schedule.schedule_layers[].users[].user.html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. Read-only. |
| `schedule.schedule_layers[].restrictions` | array of object |  | An array of restrictions for the layer. A restriction is a limit on which period of the day or week the schedule layer can accept assignments. Restrictions respect the `time_zone` parameter of the request. |
| `schedule.schedule_layers[].restrictions[].type` | string | yes | Specify the types of `restriction`. One of: `daily_restriction`, `weekly_restriction`. |
| `schedule.schedule_layers[].restrictions[].duration_seconds` | integer | yes | The duration of the restriction in seconds. |
| `schedule.schedule_layers[].restrictions[].start_time_of_day` | string (partial-time) | yes | The start time in HH:mm:ss format. |
| `schedule.schedule_layers[].restrictions[].start_day_of_week` | integer |  | Only required for use with a `weekly_restriction` restriction type. The first day of the weekly rotation schedule as [ISO 8601 day](https://en.wikipedia.org/wiki/ISO_week_date) (1 is Monday, etc.) Minimum: 1. Maximum: 7. |
| `schedule.schedule_layers[].rotation_virtual_start` | string (date-time) | yes | The effective start time of the layer. This can be before the start time of the schedule. |
| `schedule.schedule_layers[].rotation_turn_length_seconds` | integer | yes | The duration of each on-call shift in seconds. |
| `schedule.schedule_layers[].name` | string |  | The name of the schedule layer. |
| `schedule.schedule_layers[].rendered_schedule_entries` | array of object |  | This is a list of entries on the computed layer for the current time range. Since or until must be set in order for this field to be populated. Read-only. |
| `schedule.schedule_layers[].rendered_schedule_entries[].user` | object |  | Same fields as `schedule.schedule_layers[].users[].user` above. |
| `schedule.schedule_layers[].rendered_schedule_entries[].start` | string (date-time) | yes | The start time of this entry. Read-only. |
| `schedule.schedule_layers[].rendered_schedule_entries[].end` | string (date-time) | yes | The end time of this entry. If null, the entry does not end. Read-only. |
| `schedule.schedule_layers[].rendered_coverage_percentage` | number |  | The percentage of the time range covered by this layer. Returns null unless since or until are set. Read-only. |
| `schedule.time_zone` | string (activesupport-time-zone) | yes | The time zone of the schedule. |
| `schedule.name` | string |  | The name of the schedule. |
| `schedule.description` | string |  | The description of the schedule. |
| `schedule.final_schedule` | object |  |  |
| `schedule.final_schedule.name` | string | yes | The name of the subschedule. Read-only. One of: `Final Schedule`, `Overrides`. |
| `schedule.final_schedule.rendered_schedule_entries` | array of object |  | This is a list of entries on the computed layer for the current time range. Since or until must be set in order for this field to be populated. Read-only. |
| `schedule.final_schedule.rendered_schedule_entries[].user` | object |  | Same fields as `schedule.schedule_layers[].users[].user` above. |
| `schedule.final_schedule.rendered_schedule_entries[].start` | string (date-time) | yes | The start time of this entry. Read-only. |
| `schedule.final_schedule.rendered_schedule_entries[].end` | string (date-time) | yes | The end time of this entry. If null, the entry does not end. Read-only. |
| `schedule.final_schedule.rendered_coverage_percentage` | number |  | The percentage of the time range covered by this layer. Returns null unless since or until are set. Read-only. |
| `schedule.overrides_subschedule` | object |  | Same fields as `schedule.final_schedule` above. |
| `schedule.escalation_policies` | array of object |  | An array of all of the escalation policies that uses this schedule. Read-only. |
| `schedule.escalation_policies[].id` | string | yes | Read-only. |
| `schedule.escalation_policies[].summary` | string \| null |  | A short-form, server-generated string that provides succinct, important information about an object suitable for primary labeling of an entity in a client. In many cases, this will be identical to `name`, though it is not intended to be an identifier. Read-only. |
| `schedule.escalation_policies[].type` | string | yes | One of: `escalation_policy_reference`. |
| `schedule.escalation_policies[].self` | string \| null (url) |  | the API show URL at which the object is accessible. Read-only. |
| `schedule.escalation_policies[].html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. Read-only. |
| `schedule.users` | array of object |  | An array of all of the users on the schedule. Read-only. |
| `schedule.users[].id` | string | yes | Read-only. |
| `schedule.users[].summary` | string \| null |  | A short-form, server-generated string that provides succinct, important information about an object suitable for primary labeling of an entity in a client. In many cases, this will be identical to `name`, though it is not intended to be an identifier. Read-only. |
| `schedule.users[].type` | string | yes | One of: `user_reference`. |
| `schedule.users[].self` | string \| null (url) |  | the API show URL at which the object is accessible. Read-only. |
| `schedule.users[].html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. Read-only. |
| `schedule.teams` | array of object |  | An array of all of the teams on the schedule. Read-only. |
| `schedule.teams[].id` | string | yes | Read-only. |
| `schedule.teams[].summary` | string \| null |  | A short-form, server-generated string that provides succinct, important information about an object suitable for primary labeling of an entity in a client. In many cases, this will be identical to `name`, though it is not intended to be an identifier. Read-only. |
| `schedule.teams[].type` | string | yes | One of: `team_reference`. |
| `schedule.teams[].self` | string \| null (url) |  | the API show URL at which the object is accessible. Read-only. |
| `schedule.teams[].html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. Read-only. |
| `schedule.next_oncall_for_user` | object |  |  |
| `schedule.next_oncall_for_user.start` | string |  | The start date for the User shift. Read-only. |
| `schedule.next_oncall_for_user.end` | string |  | The end date for the User shift. Read-only. |
| `schedule.next_oncall_for_user.user` | object |  |  |
| `schedule.next_oncall_for_user.user.id` | string | yes | Read-only. |
| `schedule.next_oncall_for_user.user.summary` | string \| null |  | A short-form, server-generated string that provides succinct, important information about an object suitable for primary labeling of an entity in a client. In many cases, this will be identical to `name`, though it is not intended to be an identifier. Read-only. |
| `schedule.next_oncall_for_user.user.type` | string | yes | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. Read-only. |
| `schedule.next_oncall_for_user.user.self` | string \| null (url) |  | the API show URL at which the object is accessible. Read-only. |
| `schedule.next_oncall_for_user.user.html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. Read-only. |

Example: Request Example

```json
{
  "schedule": {
    "name": "Daily Engineering Rotation",
    "type": "schedule",
    "time_zone": "America/New_York",
    "description": "Rotation schedule for engineering",
    "schedule_layers": [
      {
        "name": "Night Shift",
        "start": "2015-11-06T20:00:00-05:00",
        "rotation_virtual_start": "2015-11-06T20:00:00-05:00",
        "rotation_turn_length_seconds": 86400,
        "users": [
          {
            "user": {
              "id": "PXPGF42",
              "type": "user_reference"
            }
          }
        ],
        "restrictions": [
          {
            "type": "daily_restriction",
            "start_time_of_day": "08:00:00",
            "duration_seconds": 32400
          }
        ]
      }
    ]
  }
}
```

## Response 201

The schedule object created.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `schedule` | object | yes | Same fields as `schedule` above. |

Example: Response Example

```json
{
  "schedule": {
    "id": "PI7DH85",
    "type": "schedule",
    "summary": "Daily Engineering Rotation",
    "self": "https://api.pagerduty.com/schedules/PI7DH85",
    "html_url": "https://subdomain.pagerduty.com/schedules/PI7DH85",
    "name": "Daily Engineering Rotation",
    "time_zone": "America/New_York",
    "description": "Rotation schedule for engineering",
    "escalation_policies": [
      {
        "id": "PT20YPA",
        "type": "escalation_policy_reference",
        "summary": "Another Escalation Policy",
        "self": "https://api.pagerduty.com/escalation_policies/PT20YPA",
        "html_url": "https://subdomain.pagerduty.com/escalation_policies/PT20YPA"
      }
    ],
    "users": [
      {
        "id": "PEYSGVF",
        "type": "user_reference",
        "summary": "PagerDuty Admin",
        "self": "https://api.pagerduty.com/users/PEYSGVF",
        "html_url": "https://subdomain.pagerduty.com/users/PEYSGVF"
      }
    ],
    "teams": [],
    "schedule_layers": [
      {
        "name": "Layer 1",
        "rendered_schedule_entries": [],
        "id": "PG68P1M",
        "start": "2015-11-06T20:00:00-05:00",
        "rotation_virtual_start": "2015-11-06T20:00:00-05:00",
        "rotation_turn_length_seconds": 86400,
        "users": [
          {
            "user": {
              "id": "PEYSGVF",
              "type": "user_reference",
              "summary": "PagerDuty Admin",
              "self": "https://api.pagerduty.com/users/PEYSGVF",
              "html_url": "https://subdomain.pagerduty.com/users/PEYSGVF"
            }
          }
        ],
        "restrictions": [
          {
            "type": "daily_restriction",
            "start_time_of_day": "08:00:00",
            "duration_seconds": 32400
          }
        ]
      }
    ],
    "overrides_subschedule": {
      "name": "Overrides",
      "rendered_schedule_entries": []
    },
    "final_schedule": {
      "name": "Final Schedule",
      "rendered_schedule_entries": []
    }
  }
}
```

## Response 400

Caller provided invalid arguments. Please review the response for error details. Retrying with the same arguments will *not* work.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 401

Caller did not supply credentials or did not provide the correct credentials.
If you are using an API key, it may be invalid or your Authorization header may be malformed.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 403

Caller is not authorized to view the requested resource.
While your authentication is valid, the authenticated user or token does not have permission to perform this action.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 429

Too many requests have been made, the rate limit has been reached.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Developer Agreement

Your access to and use of the PagerDuty Developer Services is governed by the [PagerDuty Developer Agreement](https://docs.pagerduty.com/developer/pagerduty-developer-agreement).
