# Create an on-call rotation — API reference

> Stores the rotation name, members, handoff settings, time zone, and optional client scope.

Source: https://upfour.io/docs/api/oncall-schedules/create-an-on-call-rotation

[Developers](https://upfour.io/docs/api.md)/[On-call rotations](https://upfour.io/docs/api/oncall-schedules.md)

Stores the rotation name, members, handoff settings, time zone, and optional client scope.

POST https://app.upfour.io/v1/oncall-schedules

scope oncall.write stable [Idempotency-Key supported](https://upfour.io/docs/api/idempotency.md) returns 201

## Body

`application/json` required 7 fields

namestring (required)

Unique within the company.

In the app: **Name**

All other fields6 fields

client_iduuid · nullable

handoff_dayinteger

Weekday of the weekly handoff, 0 = Sunday to 6 = Saturday, in the schedule's time zone. Daily rotations ignore it. A value outside 0 to 6 is stored as 1 (Monday).

In the app: **Handoff day**

handoff_timestring

Time of day of the handoff as HH:MM or HH:MM:SS in the schedule's time zone; empty means 09:00:00.

In the app: **Handoff time**

member_idsuuid[]

User IDs of the company members in rotation order. On update they replace the current members.

In the app: **Team members**

rotation_typestring

daily hands off every day at handoff_time, weekly every week on handoff_day at handoff_time. custom currently behaves like weekly; there is no custom shift length yet. Required on PUT; POST defaults to weekly.

dailyweeklycustom

In the app: **Rotation frequency**

timezonestring

IANA time zone name; empty means UTC.

In the app: **Timezone**

## Returns

A successful request returns `201` with application/json.

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | OnCallSchedule | |
| OnCallSchedule · 28 fields FieldTypeDescription `created_at` string (date-time) `handoff_day` integer Weekday of the weekly handoff, 0 = Sunday to 6 = Saturday. `handoff_time` string HH:MM:SS in the schedule's time zone. `id` uuid `members` OnCallMember[]  · nullable Each item · 8 fields FieldTypeDescription `created_at` string (date-time) `id` uuid `schedule_id` uuid `sort_order` integer `user_id` uuid `email` string `first_name` string `last_name` string `name` string `organization_id` uuid `rotation_type` string one of`daily` `weekly` `custom` `timezone` string `updated_at` string (date-time) `client_id` uuid `current_oncall` OnCallMember The person on call right now, an active override first; absent while nobody is. OnCallMember · 8 fields FieldTypeDescription `created_at` string (date-time) `id` uuid `schedule_id` uuid `sort_order` integer `user_id` uuid `email` string `first_name` string `last_name` string | | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 403 | [permission_denied](https://upfour.io/docs/api/errors#code-permission_denied) | The credentials do not permit this action. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousList on-call rotations](https://upfour.io/docs/api/oncall-schedules/list-on-call-rotations.md) [NextGet the current on-call person](https://upfour.io/docs/api/oncall-schedules/get-the-current-on-call-person.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/oncall-schedules" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "handoff_day": 1,
    "handoff_time": "09:00",
    "member_ids": [
      "00000000-0000-4000-8000-000000000001"
    ],
    "name": "Platform on-call",
    "rotation_type": "weekly",
    "timezone": "Europe/Berlin"
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/oncall-schedules", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    handoff_day: 1,
    handoff_time: "09:00",
    member_ids: ["00000000-0000-4000-8000-000000000001"],
    name: "Platform on-call",
    rotation_type: "weekly",
    timezone: "Europe/Berlin",
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/oncall-schedules",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "handoff_day": 1,
        "handoff_time": "09:00",
        "member_ids": ["00000000-0000-4000-8000-000000000001"],
        "name": "Platform on-call",
        "rotation_type": "weekly",
        "timezone": "Europe/Berlin",
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "handoff_day": 1,
  "handoff_time": "09:00",
  "member_ids": [
    "00000000-0000-4000-8000-000000000001"
  ],
  "name": "Platform on-call",
  "rotation_type": "weekly",
  "timezone": "Europe/Berlin"
}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/oncall-schedules", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "handoff_day": 1,
  "handoff_time": "09:00",
  "member_ids": [
    "00000000-0000-4000-8000-000000000001"
  ],
  "name": "Platform on-call",
  "rotation_type": "weekly",
  "timezone": "Europe/Berlin"
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/oncall-schedules");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 201

```json
{
  "data": {
    "created_at": "2026-10-27T09:00:00Z",
    "handoff_day": 1,
    "handoff_time": "09:00:00",
    "id": "00000000-0000-4000-8000-000000000002",
    "members": [
      {
        "created_at": "2026-10-27T09:00:00Z",
        "email": "anna@example.com",
        "id": "00000000-0000-4000-8000-000000000003",
        "schedule_id": "00000000-0000-4000-8000-000000000002",
        "sort_order": 0,
        "user_id": "00000000-0000-4000-8000-000000000001"
      }
    ],
    "name": "Platform on-call",
    "organization_id": "00000000-0000-4000-8000-000000000004",
    "rotation_type": "weekly",
    "timezone": "Europe/Berlin",
    "updated_at": "2026-10-27T09:00:00Z"
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 403

```json
{
  "error": {
    "code": "permission_denied",
    "message": "The credentials do not permit this action.",
    "request_id": "req_…"
  }
}
```
