# Set an account's posting times

Replaces all of the account's weekly posting times. PUT /accounts/{accountId}/queue.

`PUT https://api.tiktornado.com/api/v1/accounts/{accountId}/queue`

Scope: `posts:write`. Needs an `Idempotency-Key` header.

Replaces all of the account's weekly posting times. `POST /posts` with `queue: true` then gives a post the next free one. Send `"slots": []` to clear them all; `timeZone` must still be a valid zone. Posts already scheduled keep their times. The account must be able to post.

**Times are wall-clock times in `timeZone`.** A slot is a weekday and a time of day there, not a UTC moment, so 9:00 stays 9:00 across daylight saving. Monday 9:00 in `America/New_York` is 14:00 UTC in winter and 13:00 UTC in summer.

**Daylight saving nights.** A time the clock skips doesn't happen that day: in New York 2:30 doesn't exist on 8 March 2026, so a Sunday 2:30 slot is skipped that Sunday, not moved. A time the clock passes twice is used once, the first time: Sunday 1:30 on 1 November 2026 is 1:30 daylight time (05:30 UTC) only.

**Which time a queued post gets.** The first slot from now that is:

- free: no live post of the account (scheduled, publishing, published, paused or in drafts) of either kind is anywhere in that minute, including one you scheduled by hand. A cancelled, failed or missed post frees it;
- more than 10 minutes from now, the same lead as any scheduled post;
- not after the account ends;
- within the daily limit for the post's kind: a slot is skipped for videos when one more video there would put more than 15 in some 24 hours, and the same for photos. A slot skipped for videos can still take a photo post.

Only the next 4 weeks are searched. With no times the answer is `queue_empty`, with nothing free in 4 weeks `queue_full`.

## Path parameters

- `accountId` string, required: The account, from `GET /accounts`. Matches `^[A-Za-z0-9]{1,64}$`.

## Header parameters

- `Idempotency-Key` string, required: A unique string you make up for this change, for example a UUID: 1 to 255 visible ASCII characters, no spaces. Send the same key with the same body to retry safely. Missing or malformed: 400 `idempotency_key_required`, before anything runs. Matches `^[\x21-\x7e]{1,255}$`.

## Request body

- `timeZone` string, required: An IANA time zone name, for example `America/New_York` or `Europe/London`. Any letter case is accepted; it is saved and answered in its own spelling (`america/new_york` comes back as `America/New_York`). Offsets such as `+05:00` are refused (`invalid_queue`). 1 to 64 characters.
- `slots` array of objects, required: The posting times, in any order. No time twice, and at most 15 on one day (`invalid_queue`). Empty clears them all. At most 105 items.
  - `day` integer, required: 0 for Monday through 6 for Sunday. 0 to 6.
  - `minute` integer, required: Minutes after midnight, for example 540 for 9:00 and 1080 for 18:00. 0 to 1,439.

## Examples

### Monday and Wednesday at 9:00, Friday at 18:00, New York time

```bash
curl -X PUT 'https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/queue' \
  -H "Authorization: Bearer $TIKTORNADO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "timeZone": "America/New_York",
    "slots": [
      {
        "day": 0,
        "minute": 540
      },
      {
        "day": 2,
        "minute": 540
      },
      {
        "day": 4,
        "minute": 1080
      }
    ]
  }'
```

```js
const response = await fetch("https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/queue", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.TIKTORNADO_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "timeZone": "America/New_York",
    "slots": [
      {
        "day": 0,
        "minute": 540
      },
      {
        "day": 2,
        "minute": 540
      },
      {
        "day": 4,
        "minute": 1080
      }
    ]
  }),
});
const data = await response.json();
```

```python
import os
import uuid

import requests

response = requests.put(
    "https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/queue",
    headers={
        "Authorization": f"Bearer {os.environ['TIKTORNADO_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "timeZone": "America/New_York",
        "slots": [
            {
                "day": 0,
                "minute": 540,
            },
            {
                "day": 2,
                "minute": 540,
            },
            {
                "day": 4,
                "minute": 1080,
            },
        ],
    },
)
data = response.json()
```

### Clear every posting time

```bash
curl -X PUT 'https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/queue' \
  -H "Authorization: Bearer $TIKTORNADO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "timeZone": "Europe/London",
    "slots": []
  }'
```

```js
const response = await fetch("https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/queue", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.TIKTORNADO_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "timeZone": "Europe/London",
    "slots": []
  }),
});
const data = await response.json();
```

```python
import os
import uuid

import requests

response = requests.put(
    "https://api.tiktornado.com/api/v1/accounts/j971x2c4ajrq0w8sd5e8fxz3a57v2k8m/queue",
    headers={
        "Authorization": f"Bearer {os.environ['TIKTORNADO_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "timeZone": "Europe/London",
        "slots": [],
    },
)
data = response.json()
```

## Response 200

The times are saved. The answer is the new set, as `GET` gives it.

- `Idempotent-Replayed`: `true` when this is the stored answer to an earlier request with the same `Idempotency-Key`. Absent otherwise.

- `timeZone` string or null, required: The IANA time zone the times are in, or `null` when the account has no posting times.
- `slots` array of objects, required: The posting times, sorted by day, then time.
  - `day` integer, required: 0 for Monday through 6 for Sunday. 0 to 6.
  - `minute` integer, required: Minutes after midnight, for example 540 for 9:00 and 1080 for 18:00. 0 to 1,439.

```json
{
  "timeZone": "America/New_York",
  "slots": [
    {
      "day": 0,
      "minute": 540
    },
    {
      "day": 2,
      "minute": 540
    },
    {
      "day": 4,
      "minute": 1080
    }
  ]
}
```

```json
{
  "timeZone": null,
  "slots": []
}
```

## Errors

| Status | Reason | Message |
| --- | --- | --- |
| 400 | `invalid_request` | Something here isn't valid. Check it and try again. |
| 400 | `idempotency_key_required` | Send an Idempotency-Key header with every change, so a retry can't make it twice. |
| 400 | `invalid_queue` | These posting times aren't valid. Check them and try again. |
| 400 | `account_not_ready` | This account isn't ready to post yet. Or: This account is under review by TikTok, so new posts can't be scheduled right now. |
| 400 | `invalid_state` | This can't be done right now. Refresh and try again. |
| 401 | `api_key_invalid` | This API key isn't valid. Check it, or create a new one in the app. |
| 403 | `access_locked` | Your subscription isn't active, so this can't be changed right now. Visit Billing to fix it. |
| 403 | `api_scope_missing` | This API key can't do this. Create a key with the access it needs in the app. |
| 404 | `not_found` | We couldn't find this. |
| 409 | `idempotency_in_progress` | A request with this Idempotency-Key is still running. Try again in a moment. |
| 422 | `idempotency_key_reused` | This Idempotency-Key was already used for a different request. Use a new one. |
| 429 | `slow_down` | You're going a bit fast. Wait a moment and try again. |
| 500 | `unknown_error` | Something went wrong on our side. We're on it. |
| 503 | `service_unavailable` | Something went wrong on our side. We're on it. |