---
title: "Replace every weekly queue slot"
description: "PubNio API queues.slots.replace: replace every weekly queue slot. Request fields, examples in five clients, errors, and idempotency."
---

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

# Replace every weekly queue slot

Replace every weekly queue slot with [`PUT /api/v1/queues/{queueId}/slots`](https://pubnio.com/api/v1/docs#tag/queues/PUT/api/v1/queues/{queueId}/slots). Requires an API key with the `publish` scope or a signed-in workspace owner.

## Request

Round-trip slot IDs to keep them. An omitted ID creates a slot. A removed slot leaves historical assignments with no slot ID.

| Parameter     | In    | Type | Required |
| ------------- | ----- | ---- | -------- |
| `queueId`     | path  | UUID | Yes      |
| `workspaceId` | query | UUID | Yes      |

| Body field        | Type                    | Required |
| ----------------- | ----------------------- | -------- |
| `expectedVersion` | integer                 | Yes      |
| `slots`           | array of QueueSlotInput | Yes      |

## Response

- HTTP 200: `Queue` with `id`, `workspaceId`, `accountId`, `name`, `timezone`, `status`, `isDefault`, `limits`, `slots`, `version`, `pausedAt`, `archivedAt`, `createdAt`, `updatedAt`.
  - `status`: `active`, `paused`, `archived`

The [OpenAPI document](https://pubnio.com/api/v1/openapi) has each field's type.

## Examples

### TypeScript

```ts
const queue = await workspace.queues.replaceSlots(queueId, {
  expectedVersion: 3,
  slots: [
    { dayOfWeek: 2, time: "12:30" },
    { dayOfWeek: 4, time: "12:30" },
  ],
});
```

### Python

```python
queue = workspace.queues.replace_slots(
    queue_id,
    expected_version=3,
    slots=[
        {"dayOfWeek": 2, "time": "12:30"},
        {"dayOfWeek": 4, "time": "12:30"},
    ],
)
```

### cURL

```sh
curl -X PUT "https://pubnio.com/api/v1/queues/$QUEUE_ID/slots?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expectedVersion":3,"slots":[{"dayOfWeek":2,"time":"12:30"},{"dayOfWeek":4,"time":"12:30"}]}'
```

### CLI

```sh
pnio queues slots "$QUEUE_ID" --version 3 --slot tue@12:30 --slot thu@12:30
```

### MCP execute

```js
async () => {
  const queueId = "<queueId>";
  const response = await codemode.request({
    method: "PUT",
    path: `/api/v1/queues/${queueId}/slots`,
    query: { workspaceId: codemode.workspaceId },
    body: {
      expectedVersion: 3,
      slots: [
        { dayOfWeek: 2, time: "12:30" },
        { dayOfWeek: 4, time: "12:30" },
      ],
    },
  });
  return response.data;
};
```

## Errors

It declares no problem of its own.

It declares the problems [most operations](https://pubnio.com/docs/reference/#shared-problems) declare.

## Idempotency

No key. The required `expectedVersion` makes a stale retry fail instead of applying twice.

## Limits

- Field lengths and ranges are in the [OpenAPI document](https://pubnio.com/api/v1/openapi).

## Related

- [Queues operations](https://pubnio.com/docs/reference/#queues)
- [Publishing](https://pubnio.com/docs/publishing/)

Source: https://pubnio.com/docs/reference/queues-slots-replace/index.mdx
