# Pagination, limits and errors

Paging, walking by cursor and syncing, rate limits, errors, safe retries and what happens with several projects.

## Pagination

Lists (`GET /ideas`, `GET /ideas/{id}/comments`, `GET /topics`) take two query parameters:

- `page`: the page number, from 1 (default 1);
- `per_page`: items per page, from 1 to 100 (default 20).

The answer has `meta.pagination` with `page`, `per_page`, `total`, `total_pages` and `has_more`. A page past the last one answers `200` with an empty list.

The query string is strict: an unknown parameter, a repeated one or a value out of range answers `400`, and `error.details` names the parameter. Nothing is ignored or corrected silently.

### Walk every idea

Pages are ordered by their sort, so a vote between two requests can move an idea to a page you already read. To read every idea exactly once, walk `GET /ideas` by cursor, in creation order:

1. Send `cursor=start` (and `per_page` if you want).
2. Send the `meta.cursor.next` of each answer as `cursor` in the next request, with the same filters.
3. Stop when `meta.cursor.has_more` is `false`.

```bash
curl -s "https://feedzzie.com/api/v1/ideas?cursor=start&per_page=100" \
  -H "Authorization: Bearer $FEEDZZIE_API_KEY"
```

A cursor page has `meta.cursor` (`next`, `has_more`, `per_page`) instead of `meta.pagination`, and no total. It does not take `page`, and `sort` only as `oldest`.

### Keep a copy in sync

`updated_since` lists only the ideas created or changed at or after a time: a vote, a new comment, an edit or a status change all count. To keep a copy of your ideas:

1. Walk every idea once, by cursor.
2. On each sync, walk again with `updated_since` set a minute before the `meta.timestamp` of the first page of your previous walk.
3. Match ideas by `id`: an idea can come twice.

Deleted ideas are not listed: a full walk shows which ones are gone.

## Rate limits

Each API key, and your organization as a whole, can make this many requests per minute. A request passes only when both have room, so more keys do not add up to more requests.

| Plan | Requests per minute |
|---|---|
| Free | 60 |
| Starter | 100 |
| Pro | 300 |
| Business | 1,000 |

Answers carry the window:

- `X-RateLimit-Limit`: requests allowed in the window;
- `X-RateLimit-Remaining`: requests left;
- `X-RateLimit-Reset`: when the window resets, in Unix time in milliseconds.

Past the limit, the answer is `429` with `Retry-After`, the seconds to wait. `GET /me` tells you your plan and its limit.

## Errors

Errors have the same shape everywhere:

```json
{
  "error": {
    "code": "INSUFFICIENT_SCOPE",
    "message": "Admin scope required to change idea status",
    "details": [{ "field": "scope", "message": "Requires an API key with the admin scope", "expected": "admin" }]
  },
  "meta": { "request_id": "…", "timestamp": "…" }
}
```

| Status | `error.code` | Meaning |
|---|---|---|
| `400` | `VALIDATION_ERROR` | A body, query or path value is not valid; `details` names the field |
| `401` | `UNAUTHORIZED` | The key is missing, wrong, expired or revoked |
| `403` | `WRONG_KEY_TYPE` | A public key (`fz_pub_`): the REST API takes only secret keys |
| `403` | `INSUFFICIENT_SCOPE` | The key needs a wider scope, named in `details[0].expected` |
| `403` | `PLAN_LIMIT_REACHED` | The write would go past your plan's limit (`details[0].field` and `details[0].limit`) |
| `403` | `FORBIDDEN` | Editing a comment another key or a person wrote |
| `404` | `NOT_FOUND` | The resource, or the path, does not exist |
| `405` | `METHOD_NOT_ALLOWED` | The path exists, but not with this method; `Allow` lists the methods |
| `409` | `CONFLICT` | The idea's state does not allow the change (it awaits moderation, or it is merged into another idea), or the same `Idempotency-Key` is still being processed |
| `410` | `GONE` | The idea an `Idempotency-Key` created was deleted |
| `422` | `IDEMPOTENCY_KEY_REUSED` | The `Idempotency-Key` was already used with another body |
| `429` | `RATE_LIMITED` | Too many requests: wait `Retry-After` seconds |
| `500` | `INTERNAL_ERROR` | Something failed on our side |
| `503` | `SERVICE_UNAVAILABLE` | A read failed on our side: retry after `Retry-After` |

Every answer, errors included, carries an `X-Request-Id` header equal to `meta.request_id`. Include it when you [contact support](https://docs.feedzzie.com/help/).

## Safe retries

`POST /ideas` and `POST /ideas/{id}/comments` accept an `Idempotency-Key` header: a UUID you generate once per create and send with every attempt of it. If a request fails on the way, send it again with the same key: it creates nothing new and answers `200` with what the first one created. The same key with a different body answers `422`.

Votes are safe to retry without a header: your organization votes an idea at most once through the API, and removing a vote that is not there answers `204`.

## Ideas awaiting moderation

Lists return only approved ideas. An idea awaiting moderation or rejected exists only for an `admin` key, which lists it with `include_pending=true`; any other key gets `404` for it.

## Several projects

A secret key reaches your whole organization. Today, API v1 works like this with several projects:

- `GET /ideas` lists the ideas of **every** project, and an idea does not say which project it belongs to.
- `POST /ideas` always creates the idea in your organization's **default project**.
- `GET /topics` lists the topics of the default project, the ones `POST /ideas` accepts as `topic_id`.

With one project, none of this matters. With several, keep in mind that the ideas you create through the API, the [CLI](https://docs.feedzzie.com/cli/cli/) or the [MCP server](https://docs.feedzzie.com/cli/mcp/) go to the default project.
