> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.rydhm.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.rydhm.ai/_mcp/server.

# Reorder guides

POST https://api.rydhm.ai/v1/agents/{id}/guides/reorder
Content-Type: application/json

Every guide id of the expert once, in the new order.

Sessions: admins.

Needs the experts:write scope. A key without it gets 403 insufficient_scope. Routes not in this reference cannot be called with a key at all (403 not_available_to_api_keys).

Reference: https://docs.rydhm.ai/api-reference/onboarding/reorder-guides

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `id` (string, required) — The expert id.

### Body (application/json)

This endpoint expects an object.

- `ids` (list of string, required)

## Response

### 201

OK

- `list of Guide`

## Errors

### 401 Unauthorized Error

The key is missing, not valid, disabled or expired (error: invalid_api_key, api_key_disabled, api_key_expired).

- `statusCode` (integer, required)
- `message` (string, required)
- `error` (string, optional) — A stable code such as insufficient_scope, expert_not_allowed, rate_limited, plan_limit, payment_required.
- `code` (string, optional) — The stable code on the refusals that carry it here instead of in `error`: stale_edit (409 on an expert save).
- `requestId` (string, optional) — The X-Request-Id of the call, to quote to support.
- `upgradeHint` (ErrorUpgradeHint, optional) — On 402 payment_required and 403 plan_limit: what fixes it.
- `requiredScopes` (list of string, optional) — On 403 insufficient_scope: what the route needs.
- `missingScopes` (list of string, optional)
- `retryAfterSeconds` (integer, optional) — On 429: how long to wait.
- `retryAt` (datetime, optional, nullable)
- `timeZone` (string, optional, nullable)
- `localTime` (string, optional, nullable)
- `state` (string, optional, nullable)
- `exceptionsAllowed` (boolean, optional) — On 400 outside_calling_hours: whether `callingHoursException` may be sent.

### 403 Forbidden Error

The key lacks a scope (insufficient_scope), may not use this expert (expert_not_allowed), or the route is session-only (not_available_to_api_keys).

- `statusCode` (integer, required)
- `message` (string, required)
- `error` (string, optional) — A stable code such as insufficient_scope, expert_not_allowed, rate_limited, plan_limit, payment_required.
- `code` (string, optional) — The stable code on the refusals that carry it here instead of in `error`: stale_edit (409 on an expert save).
- `requestId` (string, optional) — The X-Request-Id of the call, to quote to support.
- `upgradeHint` (ErrorUpgradeHint, optional) — On 402 payment_required and 403 plan_limit: what fixes it.
- `requiredScopes` (list of string, optional) — On 403 insufficient_scope: what the route needs.
- `missingScopes` (list of string, optional)
- `retryAfterSeconds` (integer, optional) — On 429: how long to wait.
- `retryAt` (datetime, optional, nullable)
- `timeZone` (string, optional, nullable)
- `localTime` (string, optional, nullable)
- `state` (string, optional, nullable)
- `exceptionsAllowed` (boolean, optional) — On 400 outside_calling_hours: whether `callingHoursException` may be sent.

### 429 Too Many Requests Error

Rate limited; wait Retry-After seconds.

- `statusCode` (integer, required)
- `message` (string, required)
- `error` (string, optional) — A stable code such as insufficient_scope, expert_not_allowed, rate_limited, plan_limit, payment_required.
- `code` (string, optional) — The stable code on the refusals that carry it here instead of in `error`: stale_edit (409 on an expert save).
- `requestId` (string, optional) — The X-Request-Id of the call, to quote to support.
- `upgradeHint` (ErrorUpgradeHint, optional) — On 402 payment_required and 403 plan_limit: what fixes it.
- `requiredScopes` (list of string, optional) — On 403 insufficient_scope: what the route needs.
- `missingScopes` (list of string, optional)
- `retryAfterSeconds` (integer, optional) — On 429: how long to wait.
- `retryAt` (datetime, optional, nullable)
- `timeZone` (string, optional, nullable)
- `localTime` (string, optional, nullable)
- `state` (string, optional, nullable)
- `exceptionsAllowed` (boolean, optional) — On 400 outside_calling_hours: whether `callingHoursException` may be sent.

## Types

### Guide

- `id` (string, required) — A UUID.
- `agentId` (string, required) — A UUID.
- `name` (string, required)
- `trigger` (map from string to any, required) — When the guide offers itself: \{ type: manual } | \{ type: first\_visit, pattern? } | \{ type: page, pattern } | \{ type: event, name } | \{ type: stuck, seconds, pattern? }. Patterns are path globs (\* in one segment, \*\* across).
- `audience` (map from string to any, required) — Who sees it (every rule present must hold; \{} is everyone): \{ traits?: \[\{ key, op, value? }], plans?: \[..], seen?: \[custom event names], notSeen?: \[..] }. op: eq, neq, in, not\_in, exists, not\_exists, contains, gt, lt.
- `steps` (list of GuideStep, required)
- `isActive` (boolean, required)
- `position` (integer, required)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)
- `nudge` (string, optional, nullable)

### ErrorUpgradeHint

On 402 payment_required and 403 plan_limit: what fixes it.

- `action` (enum, optional)
  - Allowed values: `top_up`, `upgrade`, `contact`
- `planCode` (string, optional) — The smallest plan that allows it, when action is upgrade.
- `href` (string, optional) — Where to go in the app.

### GuideStep

- `id` (string, required) — 1–64 letters, digits, - or _; stable (progress stores it).
- `title` (string, required)
- `instruction` (string, required) — For the coach: what to show and say at this step.
- `completeWhen` (map from string to any, required) — What completes it: \{ type: manual } | \{ type: page, value } | \{ type: click, value } | \{ type: event, value } | \{ type: tool, value }. pattern / target / name are accepted for value.
- `pagePattern` (string, optional) — The page the step happens on (a path glob).
- `target` (string, optional) — A page-map name to show.

## Examples

**Request**

```json
{
  "ids": [
    "string"
  ]
}
```

**Response**

```json
[
  {
    "id": "string",
    "agentId": "string",
    "name": "string",
    "trigger": {},
    "audience": {},
    "steps": [
      {
        "id": "string",
        "title": "string",
        "instruction": "string",
        "completeWhen": {},
        "pagePattern": "string",
        "target": "string"
      }
    ],
    "isActive": true,
    "position": 1,
    "createdAt": "2024-01-15T09:30:00Z",
    "updatedAt": "2024-01-15T09:30:00Z",
    "nudge": "string"
  }
]
```

**SDK Code**

```python
import requests

url = "https://api.rydhm.ai/v1/agents/id/guides/reorder"

payload = { "ids": ["string"] }
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.rydhm.ai/v1/agents/id/guides/reorder';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <apiKey>', 'Content-Type': 'application/json'},
  body: '{"ids":["string"]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```