Scheduling
Schedule posts by local/UTC timestamps or weekly queue slots, manage account schedule settings, handle DST transitions, and cancel or reschedule safely.
Updated
On this page
- Scheduling modes
- Explicit time (at_time): local time, IANA timezone, and UTC
- Next weekly queue slot (next_slot)
- Weekly schedule settings
- Read schedule settings
- Update schedule settings
- Handling NO_AVAILABLE_SLOT
- DST and timezone behavior
- What 202 Accepted means
- Cancelling and rescheduling
- Cancel an unstarted scheduled target
- Reschedule an unstarted target (replaceExisting: true)
- Related docs
Postkub supports three publication modes—publish now, schedule at an explicit timestamp (with verified local time, IANA timezone, and UTC instant), and reserve an account's next weekly queue slot. All schedule fire times are computed in each target account's IANA timezone and stored in UTC.
Scheduling requires both post:publish and post:schedule on your API key. Reading an account's weekly slots requires account:read, and updating slots or timezone requires account:schedule (see Authentication & Scopes).
Note
The REST API is available now. Equivalent postkub CLI examples below reflect the @postkub/cli preview client, which is not yet published to npm.
Scheduling modes
| Mode | Endpoint | When to use it |
|---|---|---|
Explicit time (at_time) | POST /api/v1/posts/{id}/schedule with targets[] | Exact local time + IANA timezone + resolved UTC instant per target account |
Next queue slot (next_slot) | POST /api/v1/posts/{id}/schedule with schedule: { nextSlot: true } | Automatically reserve each account's earliest open weekly queue slot |
Publish immediately (now) | POST /api/v1/posts/{id}/publish | Queue immediate publication (see Your First Post) |
Explicit time (at_time): local time, IANA timezone, and UTC
When scheduling for an exact instant, pass targets with all three time fields per account:
localTime: wall-clock timestamp with no offset (YYYY-MM-DDTHH:mm:ssor with.sss).timezone: IANA timezone identifier matching the account's current timezone (for example,Asia/Bangkok,America/New_York, orUTC). Fixed numeric offsets such as+07:00are rejected (422 INVALID_SCHEDULE).fireAtUtc: exact resolved UTC instant withZ(YYYY-MM-DDTHH:mm:ss.sssZ), strictly in the future at acceptance.
Sending both the local wall-clock time and its resolved UTC instant prevents silent drift if an account's timezone changed or if your client and server disagree across a daylight-saving boundary.
- Regional timezone example (
Asia/Bangkok):localTime: "2026-12-10T09:00:00",timezone: "Asia/Bangkok",fireAtUtc: "2026-12-10T02:00:00.000Z". - UTC account example (
UTC): when the target account's timezone isUTC,localTimeandfireAtUtcshare the same clock time (localTime: "2026-12-10T09:00:00",timezone: "UTC",fireAtUtc: "2026-12-10T09:00:00.000Z").
curl -sS -X POST https://postkub.com/api/v1/posts/post_example123/schedule \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 11111111-1111-4111-8111-111111111111" \
-d '{
"expectedRevision": 1,
"targets": [
{
"socialAccountId": "acc_example01",
"localTime": "2026-12-10T09:00:00",
"timezone": "Asia/Bangkok",
"fireAtUtc": "2026-12-10T02:00:00.000Z"
},
{
"socialAccountId": "acc_example02",
"localTime": "2026-12-10T09:00:00",
"timezone": "UTC",
"fireAtUtc": "2026-12-10T09:00:00.000Z"
}
]
}'
Equivalent CLI command using a JSON input file (preview):
postkub posts schedule \
--id post_example123 \
--expected-revision 1 \
--input schedule.json \
--output json
Explicit-time validation rejects mismatches immediately without accepting any target:
| HTTP | Error code | Meaning |
|---|---|---|
422 | INVALID_SCHEDULE | Malformed timestamp or non-IANA timezone (for example, +07:00) |
422 | SCHEDULE_TIMEZONE_CHANGED | Submitted timezone does not match the account's current timezone |
422 | SCHEDULE_RESOLUTION_MISMATCH | Submitted fireAtUtc does not match localTime resolved in timezone |
422 | SCHEDULE_IN_PAST | fireAtUtc is in the past at acceptance time |
Next weekly queue slot (next_slot)
To let Postkub pick the earliest unoccupied future slot from each selected account's weekly schedule, pass schedule: { "nextSlot": true }. Omit socialAccountIds to schedule every saved target on the post, or pass a specific subset:
curl -sS -X POST https://postkub.com/api/v1/posts/post_example123/schedule \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 22222222-2222-4222-8222-222222222222" \
-d '{
"expectedRevision": 1,
"socialAccountIds": ["acc_example01"],
"schedule": { "nextSlot": true }
}'
Equivalent CLI command (preview):
postkub posts schedule \
--id post_example123 \
--expected-revision 1 \
--next-slot \
--account-id acc_example01 \
--output json
In REST requests, you can also include "prioritize": true inside schedule ({ "nextSlot": true, "prioritize": true }) to place the post ahead of the earliest currently occupied future slot when one exists before the next open slot.
Queue-slot reservation is transactional per target account across a 366-day search horizon. If two concurrent requests race for the same slot, the second fails safely with retryable 409 SLOT_RESERVATION_CONFLICT. Always read the actual reserved fireAtUtc and resolvedLocalTime from the 202 receipt rather than relying on an earlier preview.
Weekly schedule settings
Each social account maintains its own IANA timezone and list of weekly queue slots (empty by default on newly connected accounts). Weekly slots apply only to next_slot scheduling—they never restrict now or at_time schedules.
Read schedule settings
curl -sS https://postkub.com/api/v1/accounts/acc_example01/schedule-settings \
-H "Authorization: Bearer <API_KEY>"
Equivalent CLI command (preview):
postkub accounts schedule get --account-id acc_example01 --output json
Example response (200 OK):
{
"accountId": "acc_example01",
"timezone": "Asia/Bangkok",
"revision": 1,
"slots": [
{ "weekday": 1, "localTime": "09:00" },
{ "weekday": 3, "localTime": "14:00" },
{ "weekday": 5, "localTime": "09:00" }
],
"updatedAt": "2026-12-03T08:00:00.000Z"
}
Update schedule settings
Call PATCH /api/v1/accounts/{id}/schedule-settings with an Idempotency-Key UUID, expectedRevision, and at least one of timezone or slots:
weekday: ISO weekday integer from1(Monday) to7(Sunday).localTime: 24-hourHH:MMstring (for example,"09:00"or"18:30").slots: up to 100 unique{ weekday, localTime }entries per account; pass"slots": []to clear all weekly slots.timezone: valid IANA timezone identifier (up to 128 characters, no numeric offsets).
curl -sS -X PATCH https://postkub.com/api/v1/accounts/acc_example01/schedule-settings \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 33333333-3333-4333-8333-333333333333" \
-d '{
"expectedRevision": 1,
"timezone": "Asia/Bangkok",
"slots": [
{ "weekday": 1, "localTime": "09:00" },
{ "weekday": 3, "localTime": "14:00" },
{ "weekday": 5, "localTime": "09:00" }
]
}'
Equivalent CLI command using repeatable --slot flags (<1..7|mon..sun>:<HH:MM>, or --clear-slots; preview):
postkub accounts schedule update \
--account-id acc_example01 \
--expected-revision 1 \
--timezone Asia/Bangkok \
--slot mon:09:00 \
--slot wed:14:00 \
--slot fri:09:00 \
--output json
Response (200 OK):
{
"requestId": "33333333-3333-4333-8333-333333333333",
"scheduleSettings": {
"accountId": "acc_example01",
"timezone": "Asia/Bangkok",
"revision": 2,
"slots": [
{ "weekday": 1, "localTime": "09:00" },
{ "weekday": 3, "localTime": "14:00" },
{ "weekday": 5, "localTime": "09:00" }
],
"updatedAt": "2026-12-03T09:10:00.000Z"
}
}
Missing expectedRevision returns 428 REVISION_REQUIRED, and a stale revision returns 409 REVISION_CONFLICT with details.currentRevision.
Handling NO_AVAILABLE_SLOT
If you call POST /api/v1/posts/{id}/schedule with schedule: { "nextSlot": true } and any selected account either has no weekly slots configured or has every slot occupied for the next 366 days, Postkub rejects the entire request atomically with HTTP 422 NO_AVAILABLE_SLOT:
{
"error": {
"code": "NO_AVAILABLE_SLOT",
"message": "No available weekly schedule slot for selected account",
"details": {
"socialAccountId": "acc_example01"
},
"retryable": false
},
"requestId": "22222222-2222-4222-8222-222222222222"
}
No target is accepted when NO_AVAILABLE_SLOT is returned. To recover, add weekly slots via PATCH /api/v1/accounts/{id}/schedule-settings, cancel an unneeded queued publication to free a slot, or schedule with an explicit targets[] timestamp instead.
DST and timezone behavior
Postkub stores timestamps in UTC and resolves every local schedule in the target account's IANA timezone—never in server local time.
- Spring-forward gap (non-existent local time): If a local time falls inside a skipped clock hour (for example,
02:30when clocks jump from02:00to03:00), Postkub shifts the time forward by the gap duration (03:30) using compatible disambiguation. The202receipt returns both your submittedlocalTimeand the shiftedresolvedLocalTimealongsidefireAtUtc. - Fall-back overlap (ambiguous local time): If a local time occurs twice when clocks move back, Postkub selects the first (earlier, daylight-saving) occurrence.
- Settings edits never rewrite queued work: Changing an account's
timezoneor weeklyslotsaffects future schedule requests only. Already-accepted publications retain their immutablefireAtUtc. - Overdue work never silently moves to a later slot: If a queued publication passes its 15-minute lateness window (
fireAtUtc + 15 minutes), Postkub holds it for review rather than silently shifting it to the next slot.
What 202 Accepted means
POST /api/v1/posts/{id}/schedule returns HTTP 202 Accepted once Postkub validates your scope, revision, platform text/media rules, fair-use queue limits, and schedule timing, and commits the immutable publication intent (plus any queue-slot reservation) to PostgreSQL.
202confirms durable acceptance by Postkub—not remote publication on the social network.- Fair-use and capacity caps enforced at acceptance return HTTP
429(ACCOUNT_QUEUE_LIMIT_EXCEEDED,PLATFORM_DAILY_LIMIT_EXCEEDED, orPUBLICATION_CAPACITY_EXCEEDED); see Rate Limits. - Poll
GET /api/v1/posts/{id}(returned instatusUrl) or subscribe to Webhooks to track execution atfireAtUtc.
Cancelling and rescheduling
Cancel an unstarted scheduled target
Call POST /api/v1/posts/{id}/cancel with the post's expectedRevision and socialAccountIds.
- If the target has not started provider execution, Postkub returns
200 OK(status: "cancelled") and immediately releases its daily capacity and weekly slot reservation. - If provider I/O already started, Postkub returns
202 AcceptedwithcancellationRequested: trueand reconciles the outcome. - If the target is already
published, Postkub returns409 ALREADY_PUBLISHED.
Reschedule an unstarted target (replaceExisting: true)
To move an already-scheduled, unstarted target to a new time (or publish it immediately), call POST /api/v1/posts/{id}/schedule (or /publish) with "replaceExisting": true and the post's current expectedRevision:
curl -sS -X POST https://postkub.com/api/v1/posts/post_example123/schedule \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 44444444-4444-4444-8444-444444444444" \
-d '{
"expectedRevision": 1,
"replaceExisting": true,
"targets": [
{
"socialAccountId": "acc_example01",
"localTime": "2026-12-11T10:30:00",
"timezone": "Asia/Bangkok",
"fireAtUtc": "2026-12-11T03:30:00.000Z"
}
]
}'
In one atomic transaction, Postkub cancels the old unstarted publication, releases its old capacity and queue-slot reservation, increments post.revision by 1, and accepts the new schedule.
- Calling
/scheduleor/publishon an already-accepted target withoutreplaceExisting: truereturns409 PUBLICATION_ALREADY_ACCEPTED. - Passing
replaceExisting: truewhen no accepted work exists on the selected targets returns409 REPLACEMENT_REQUIRES_ACCEPTED_WORK. - Attempting to replace work that already started or published returns
409 RECONCILIATION_REQUIRED.
Note
PATCH /api/v1/posts/{id} only edits posts in status: "draft". To change the copy or media of a scheduled post, cancel its scheduled targets and create a new draft with the updated content.
Related docs
- Your First Post — end-to-end draft, publish, schedule, cancel, and retry walkthrough.
- API Reference: Publications — complete request/response schemas for
/publish,/schedule,/cancel, and/retry. - API Reference: Discovery — schema for account schedule settings and capabilities.
- Idempotency & Request Recovery, Errors, and Rate Limits.
