REST API
HTTP REST API for browser code, mobile apps, and third-party integrations. Served under /admin/api/ by a single Next.js catch-all route handler.
The REST API exposes the same operations as the Direct API over HTTP. Every collection, single, user, role, permission, media file, email template, API key, and more is reachable through standard HTTP methods. Use it whenever your code does not run in a trusted Node.js context — browser apps, mobile clients, third-party services.
Setup
A scaffolded project already has this route. It is a single Next.js catch-all that delegates to Nextly, and its dynamic handlers cover collections, singles, auth, dashboard, schema, email, RBAC, media, API keys, and the rest of the surface. Adding Nextly to an existing app, create it at admin/api/[[...params]]/route.ts in your app directory: src/app/ as below, or the root app/ in a project without src/ (Next.js ignores src/app when a root app exists), where the config import is one ../ shorter:
import { createDynamicHandlers } from "nextly/runtime";
import nextlyConfig from "../../../../../nextly.config";
const handlers = createDynamicHandlers({ config: nextlyConfig });
export const { GET, POST, PUT, PATCH, DELETE, OPTIONS } = handlers;The health endpoint and media-streaming endpoint can be exported at their own routes if you want to opt out of catch-all coverage. Put them in the same app directory as the catch-all: app/api/health/route.ts in a project with a root app/.
export { GET, HEAD } from "nextly/api/health";Every endpoint below is served under /admin/api/, except the health route at /api/health. Keep the handler at /admin/api: the admin panel calls it there, and the session cookies are scoped to /admin, so a browser session never reaches a handler mounted anywhere else. An API key works on any mount, but the paths on this page assume the scaffold's. The global rateLimit applies to every one of them, counting each by who is asking: a signed-in session, an API key, or the client's address.
Authentication
Two authentication mechanisms are supported.
Cookie auth (browser sessions)
When a user logs in through /admin/api/auth/login (or completes the /admin/setup wizard), the runtime sets two HTTP-only cookies:
nextly_session— short-lived JWT used for every authenticated request, scoped to/admin.nextly_refresh— long-lived token, scoped to/admin/api/authso that only the auth endpoints receive it:/admin/api/auth/refreshrotates it and/admin/api/auth/logoutdeletes its row.
Browsers send these automatically. There is no header for you to set; just call fetch with credentials: "include" if your frontend lives on a different origin.
API key (server-to-server)
Send the API key as a Bearer token:
curl https://example.com/admin/api/collections/posts/entries \
-H "Authorization: Bearer nx_live_<id>_<secret>"A key is nx_live_, a 24-character id, an underscore and a 43-character secret. The id lets the server bound failed key lookups per key without looking the key up, so other people's invalid keys cannot lock yours out. Keys made before ids (nx_live_ and 43 characters) keep working.
API keys are managed via POST /admin/api/api-keys (admin UI). There is no X-API-Key header — Authorization: Bearer <key> is the only supported form.
Response envelopes
All responses follow the canonical Phase 4 shapes documented in packages/nextly/src/api/response-shapes.ts. Content-Type is always application/json for success responses and application/problem+json for errors. Every response carries an X-Request-Id header you can quote when filing bugs.
List
Paginated reads return { items, meta }:
{
"items": [
/* T[] */
],
"meta": {
"total": 42,
"page": 1,
"limit": 10,
"totalPages": 5,
"hasNext": true,
"hasPrev": false
}
}Read
Single-document reads return the bare document:
{
"id": "abc-123",
"title": "Hello world",
"status": "published",
"createdAt": "2026-01-15T10:30:00.000Z",
"updatedAt": "2026-01-15T10:30:00.000Z"
}Mutation
Create / update / delete-by-id return { message, item }:
{
"message": "Posts updated.",
"item": {
"id": "abc-123",
"title": "Hello world",
"status": "published"
}
}Action
Non-CRUD writes (login, forgot-password, verify-email, ...) return { message, ...result } — a server-authored toast plus any operation-specific fields:
{
"message": "Logged in.",
"user": { "id": "user-1", "email": "[email protected]" },
"token": "eyJ..."
}Bulk
Bulk-by-id and bulk-upload responses return { message, items, errors }. The HTTP status is always 200 unless the request itself is malformed; per-item failures are first-class data in errors:
{
"message": "Bulk delete completed.",
"items": [{ "id": "post-1" }, { "id": "post-2" }],
"errors": [
{ "id": "post-3", "code": "NOT_FOUND", "message": "Resource not found." }
]
}Errors
Failures emit application/problem+json with status from NextlyError.statusCode and a single envelope:
{
"error": {
"code": "NOT_FOUND",
"message": "Resource not found.",
"requestId": "req_nlwxzwtnlvqsu3lc"
}
}When the failure is a validation error, error.data carries field-level details:
{
"error": {
"code": "VALIDATION_ERROR",
"message": "Validation failed.",
"requestId": "req_xxx",
"data": {
"errors": [
{
"path": "email",
"code": "INVALID_EMAIL",
"message": "Email is invalid."
}
]
}
}
}When an error carries error.data.retryAfterSeconds the runtime also sets Retry-After from it: rate-limited responses (RATE_LIMITED, 429) and a busy database (DATABASE_BUSY, 503).
| Status | Common codes | When |
|---|---|---|
400 | VALIDATION_ERROR | Body or query failed validation. |
400 | WORKFLOW_STEP_NOT_SUBMIT | A submit for review, made through a plugin such as MCP, naming a step that is not a submit (data.step). |
400 | VALIDATION_ERROR (WORKFLOW_STEP_REQUIRED) | A submit for review naming no step, where more than one submit step leaves the stages its parts stand in: name the step. |
400 | VALIDATION_ERROR (FIELD_REMOVED) | An entry write that waited while a Schema Builder save removed a field it sets; nothing was written. data.errors names the field: load the entry again and save without it. |
400 | VALIDATION_ERROR (FIELD_CHANGED) | An entry write that waited while a Schema Builder save changed how a field it sets is stored; nothing was written. data.errors names the field: load the entry again and save. |
401 | AUTH_REQUIRED, AUTH_INVALID_CREDENTIALS | Missing or bad credentials. |
403 | FORBIDDEN | Authenticated but lacks permission. |
403 | EMAIL_NOT_VERIFIED | Login with the correct password for an address not yet verified. |
403 | API_KEY_ROLE_ABOVE_CREATOR | Creating an API key (or its summary) with a role that allows more than you can. |
403 | ACTION_NOT_AVAILABLE | A plugin's action asked of an entry its rule does not hold for, or outside its collections. |
404 | NOT_FOUND | Resource does not exist. |
409 | STALE_VERSION | The document changed since the _rev you sent. See Versions and conflicts. |
409 | COLLECTION_BEING_CHANGED | A collection delete, or a Schema Builder save deleting a field's values or links, held the collection past 30 seconds or changed its definition in each of the write's tries. Nothing was written. Safe to try again. |
409 | CONFLICT, DUPLICATE | A state that refuses the request, a duplicate email, etc. |
409 | WORKFLOW_NO_SUBMIT_STEP | A submit for review naming no step, for a part whose stage no submit step leaves (data.part, data.stage). |
409 | NEXTLY_MIGRATION_HISTORY_REFUSED | A Schema Builder save refused by the migration history checks nextly migrate runs first; nothing was written. The message names what to settle. |
409 | NEXTLY_SCHEMA_CONVERSION_UNCONFIRMED | A Schema Builder save that would also convert columns an earlier Nextly version made, without confirming them; nothing was written. The message names each conversion. |
428 | VERSION_REQUIRED | An update sent neither the _rev from your last read nor "_overwrite": true. See Versions and conflicts. |
413 | PAYLOAD_TOO_LARGE | Upload bigger than configured cap. |
415 | UNSUPPORTED_MEDIA_TYPE | Wrong Content-Type. |
422 | INVALID_INPUT | Semantic validation failed. |
429 | RATE_LIMITED | Per-IP or per-key rate limit. Retry-After is set. |
500 | INTERNAL_ERROR, DATABASE_ERROR | Server-side failure. |
500 | NEXTLY_MIGRATION_PARTIALLY_APPLIED | A Schema Builder save that stopped after part of it applied (MySQL runs a save's files one by one). The message says what stayed and what to do next; data may name each change (changes) or the refusal that stopped it (refused: code, and errors for a changed count). |
503 | SERVICE_UNAVAILABLE | Health probe / dependency outage. |
503 | DATABASE_BUSY | The request waited pool.connectionTimeoutMs for a database connection and none was free, or a SQLite file stayed locked, or a Schema Builder save held the entry's collection on SQLite, past busyTimeout (in a transaction already open, at once). The statement or transaction that waited did not run; anything the request committed before it stays committed. Retry-After is set. |
Versions and conflicts
Every entry and Single carries a version, returned as _rev. Send it back with an update, and
the update is applied only if nobody has saved the document since you read it. Otherwise it is
refused, so a save never silently replaces someone else's.
The version, _rev
_rev is on every read of an entry or a Single (by id, in a list, in any language) and on the
answer to every create and update. Treat it as opaque: send back exactly what you read, and don't
parse or compare it. Keep it with your copy of the document until you write, however long that
is, and replace it with the one each save answers. Reads never change it, every save does, and
two saves in the same second get different versions.
It covers the fields every language shares and, for a read in one language, that language: a
read in Spanish gives something like 7.es:3, and a read of every language (locale=all) names
each one. It is not a version number in the document's history.
Sending it back
Put _rev in the update's body, beside the values you change:
curl -X PATCH "http://localhost:3000/admin/api/collections/posts/entries/abc-123" \
-H "Authorization: Bearer $NEXTLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"Hello again","_rev":"7"}'The answer carries the new _rev, which the next save sends. Code that reads a document once and
then saves it several times takes _rev from each save's answer.
Every update must say which version it changes. One that sends neither _rev nor
"_overwrite": true (see Choosing to overwrite) is refused, and nothing
is written:
{
"error": {
"code": "VERSION_REQUIRED",
"message": "This update must say which version of the document it changes. Send back the `_rev` from your last read of it, or set `_overwrite: true` to replace whatever is stored.",
"data": { "versionKey": "_rev", "overwriteKey": "_overwrite" }
}
}The status is 428. Creates, deletes and autosave send neither.
A save in one language is judged on that language and on the shared fields, never on another
language's translations. A version read in every language is accepted for a save of one of them.
A _rev that isn't in the form a read returns, or that names no version of the language you save,
is a 400 VALIDATION_ERROR. One in that form but above the document's current version is answered
as a conflict, 409 STALE_VERSION.
When the document changed
A save from an out-of-date version is refused with 409 STALE_VERSION, and nothing is written:
no history, no hook after the change, no webhook. The document lock stays as it was.
{
"error": {
"code": "STALE_VERSION",
"message": "This document changed since the version you gave. Its current version is 8.",
"requestId": "req_nlwxzwtnlvqsu3lc",
"data": {
"currentVersion": "8",
"changedBy": { "kind": "person", "name": "Ana Ruiz" },
"changedAt": "2026-11-04T10:42:00.000Z",
"historyVersion": { "version": 12, "locale": null }
}
}
}currentVersionis always there, spelled for the languages your save is judged on.changedByandchangedAtare there only when you may read the document in those languages, as a read of it would decide, read rules included. Anonymous visitors never get them.kindisperson,apiKey,release,agent,principalorsystem.- A person is named by the name on their account, never by email, and
nameisnullonce the account is gone. - A plugin-defined person (
principal) is given byprincipalKind, such asmember, never by name. - A document not saved since its versions began has no recorded changer, so neither field is there.
historyVersionis there when the document keeps history and you may read it: the newest recorded version of what you saved, to compare with.
To go on, read the document again, apply your change to what you get, and save with the new
_rev, or overwrite. Nextly never retries a STALE_VERSION for you.
Choosing to overwrite
Send "_overwrite": true with the values, beside the _rev you read, and the update is applied
whatever the document's current version. Code that never read the document sends _overwrite
alone:
curl -X PATCH "http://localhost:3000/admin/api/collections/posts/entries/abc-123" \
-H "Authorization: Bearer $NEXTLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"Hello again","_rev":"7","_overwrite":true}'It needs no permission beyond the update itself. Every overwrite is recorded in the document's
history, whether or not it keeps versions: when the _rev was out of date the history names whose
changes it replaced ("Overwrote changes by Ana"), and otherwise it says the save was an overwrite.
_overwrite is never stored, and any value other than true or false is a
400 VALIDATION_ERROR.
Which writes are judged
| Write | How it is judged |
|---|---|
PATCH an entry or a Single | On the shared fields and the language it saves. |
Publish or unpublish every language (.../publish-all, .../unpublish-all), and an update with locale=* | On every language. The _rev must come from a read of every language; one that doesn't name each is a 400. |
Restore a version (.../versions/<n>/restore) | In the version's language. The answer carries the new _rev. |
Take a working draft live (.../versions/working-draft/take-live) | On the shared fields and the language of the pending change, once there is one. |
Discard a working draft (DELETE .../versions/working-draft) | Before anything is removed. _rev and _overwrite go in the query string: ?locale=en&_rev=7. |
Bulk update by ids (.../entries/bulk-update) | Each id on its own, through "revs": { "<id>": "<_rev>" }. An out-of-date id comes back in errors with STALE_VERSION, and the others are applied. A revs that leaves out an id is a 428 VERSION_REQUIRED. To write them whatever they hold, send "_overwrite": true in data instead; revs and _overwrite together are a 400. |
Bulk update by query (PATCH on .../entries with a where) | Not by version: a _rev or revs there is a 400, since one version can't speak for every document the query matches. It needs "_overwrite": true in data. |
| Create, delete, a release's scheduled run, an autosave | Not judged. |
Every write above the last row needs _rev (or revs) or _overwrite: true, and one that sends
neither is a 428 VERSION_REQUIRED.
An entry's paths sit under /admin/api/collections/<slug>/entries/<id>, and a Single's under
/admin/api/singles/<slug>.
The document lock doesn't change any of this
The document lock tells editors in the admin who is working on a document, and
refuses no write. A save that sends the current _rev succeeds while someone else holds the
document, and one that sends an out-of-date _rev is refused even while you hold it.
Endpoint inventory
The catch-all dispatches every URL under /admin/api/ to one of these endpoint groups; the health route is its own route at /api/health. Auth column shows whether a session cookie or API key is required.
| Method | Path | Description | Auth |
|---|---|---|---|
GET / HEAD | /api/health | Liveness + DB probe. | Public |
GET | /admin/api/auth/setup-status | Whether the setup wizard has run, whether it needs a setup token, and whether the app takes sign-ups (allowRegistration). | Public |
POST | /admin/api/auth/setup | Run the first-boot setup wizard (creates super admin). | Public, one-shot |
GET | /admin/api/auth/session | Current session info from the cookie. | Cookie |
GET | /admin/api/auth/csrf | CSRF token (when applicable). | Public |
GET | /admin/api/auth/ui | Login page UI: provider buttons, challenge views, slots. | Public |
GET | /admin/api/auth/pending | Which second factor an interrupted sign-in left outstanding; 204 when none is, or its attempt budget is spent. | Public |
POST | /admin/api/auth/login | Email + password login. Sets cookies. | Public |
POST | /admin/api/auth/challenge/resolve | Answer a second factor with the pending token. Sets cookies. | Pending token |
POST | /admin/api/auth/set-initial-password | Replace an administrator-set password at first sign-in. Sets cookies. | Pending token |
POST | /admin/api/auth/logout | Delete the session's refresh token and clear cookies. | Cookie |
POST | /admin/api/auth/refresh | Rotate the access token. | Cookie |
POST | /admin/api/auth/register | Public registration. | Public |
POST | /admin/api/auth/forgot-password | Send password-reset email. | Public |
POST | /admin/api/auth/reset-password | Consume reset token and set new password. | Public |
POST | /admin/api/auth/accept-invite | Consume invite token and set a password. | Public |
POST | /admin/api/auth/verify-email | Consume email-verification token. | Public |
POST | /admin/api/auth/verify-email/resend | Resend the verification email. | Public |
PATCH | /admin/api/auth/change-password | Change current user's password. | Cookie |
GET | /admin/api/me | Current user profile. | Cookie / Bearer |
PATCH | /admin/api/me | Update current user profile: name, image, interfaceLanguage. | Cookie / Bearer |
GET | /admin/api/me/permissions | Resolved permissions for current user. | Cookie / Bearer |
GET | /admin/api/users | List users. | read-users |
POST | /admin/api/users | Create user. | create-users |
GET | /admin/api/users/{id} | Get user. | read-users |
PATCH | /admin/api/users/{id} | Update user. | update-users |
DELETE | /admin/api/users/{id} | Delete user. Erases their email delivery records (Email); an email the provider already accepted may still be delivered. | delete-users |
PATCH | /admin/api/users/{id}/password | Set password hash directly. | update-users |
GET | /admin/api/users/{id}/roles | List user roles. | read-roles |
POST | /admin/api/users/{id}/roles | Assign role to user. | update-users |
DELETE | /admin/api/users/{id}/roles/{roleId} | Unassign role. | update-users |
GET | /admin/api/roles | List roles. | read-roles |
POST | /admin/api/roles | Create role. | create-roles |
GET | /admin/api/roles/{id} | Get role. | read-roles |
PATCH | /admin/api/roles/{id} | Update role. | update-roles |
DELETE | /admin/api/roles/{id} | Delete role. | delete-roles |
GET | /admin/api/roles/{id}/permissions | List role permissions. | read-roles or read-permissions |
POST | /admin/api/roles/{id}/permissions | Add permission to role. | update-roles |
PATCH | /admin/api/roles/{id}/permissions | Replace all role permissions. | update-roles |
DELETE | /admin/api/roles/{id}/permissions/{permissionId} | Remove permission from role. | update-roles |
GET | /admin/api/roles/{id}/children | List child roles (inheritance). | read-roles |
POST | /admin/api/roles/{id}/children | Add child role. | update-roles |
DELETE | /admin/api/roles/{id}/children/{childId} | Remove child role. | update-roles |
GET | /admin/api/roles/{id}/parents | List ancestor roles. | read-roles |
GET | /admin/api/permissions | List permissions. | read-permissions (or read-roles) |
POST | /admin/api/permissions | Create permission. | create-permissions |
GET | /admin/api/permissions/{id} | Get permission. | read-permissions (or read-roles) |
PATCH | /admin/api/permissions/{id} | Update permission. | update-permissions |
DELETE | /admin/api/permissions/{id} | Delete permission. | delete-permissions |
GET | /admin/api/collections | List collection definitions. | Authenticated |
POST | /admin/api/collections | Create collection (Schema Builder). | create-settings, update-settings and delete-settings |
GET | /admin/api/collections/{slug} | Get collection definition. | read-{slug} |
PATCH | /admin/api/collections/{slug} | Update collection definition. | create-settings, update-settings and delete-settings |
DELETE | /admin/api/collections/{slug} | Delete collection. | create-settings, update-settings and delete-settings |
GET | /admin/api/collections/schema/{slug} | Get enriched schema (with component fields). | read-{slug} |
POST | /admin/api/collections/schema/{slug}/preview | Dry-run schema diff. | create-settings, update-settings and delete-settings |
POST | /admin/api/collections/schema/{slug}/apply | Apply confirmed schema changes. | create-settings, update-settings and delete-settings |
GET | /admin/api/collections/{slug}/entries | List entries. | read-{slug} |
POST | /admin/api/collections/{slug}/entries | Create entry. | create-{slug} |
GET | /admin/api/collections/{slug}/entries/{id} | Get entry by ID. | read-{slug} |
PATCH | /admin/api/collections/{slug}/entries/{id} | Update entry. | update-{slug} |
DELETE | /admin/api/collections/{slug}/entries/{id} | Delete entry. | delete-{slug} |
GET | /admin/api/collections/{slug}/entries/count | Count entries matching a query. | read-{slug} |
POST | /admin/api/collections/{slug}/entries/{id}/duplicate | Duplicate entry. | create-{slug} |
POST | /admin/api/collections/{slug}/entries/bulk-delete | Bulk delete by IDs. | delete-{slug} |
POST | /admin/api/collections/{slug}/entries/bulk-update | Bulk update by IDs. | update-{slug} |
PATCH | /admin/api/collections/{slug}/entries | Bulk update by query. | update-{slug} |
GET | /admin/api/singles | List singles. | Authenticated |
POST | /admin/api/singles | Create single (Schema Builder). | create-settings, update-settings and delete-settings |
GET | /admin/api/singles/{slug} | Get single content. | read-{slug} |
PATCH | /admin/api/singles/{slug} | Update single content. | update-{slug} |
DELETE | /admin/api/singles/{slug} | Delete UI-created single. | create-settings, update-settings and delete-settings |
GET | /admin/api/singles/{slug}/schema | Get single schema. | read-{slug} |
PATCH | /admin/api/singles/{slug}/schema | Update single schema (Schema Builder). | create-settings, update-settings and delete-settings |
POST | /admin/api/singles/schema/{slug}/preview | Dry-run single schema diff. | create-settings, update-settings and delete-settings |
POST | /admin/api/singles/schema/{slug}/apply | Apply single schema changes. | create-settings, update-settings and delete-settings |
GET | /admin/api/document-lock | Who is editing an entry or a Single. See Document locks. | Read access to that document |
POST | /admin/api/document-lock | Claim a document, take it over, or ask for edit access. | The same access an update of that document needs |
PATCH | /admin/api/document-lock | Renew a claim. | The same access an update of that document needs |
DELETE | /admin/api/document-lock | Give up a claim. | update-{slug} |
GET | /admin/api/field-groups | List field group definitions. | Authenticated |
POST | /admin/api/field-groups | Create field group. | create-settings |
GET | /admin/api/field-groups/{slug} | Get field group. | Authenticated |
PATCH | /admin/api/field-groups/{slug} | Update field group. | update-settings |
DELETE | /admin/api/field-groups/{slug} | Delete field group. | delete-settings |
POST | /admin/api/field-groups/schema/{slug}/preview | Dry-run field group schema diff. | create-settings |
POST | /admin/api/field-groups/schema/{slug}/apply | Apply field group schema changes. | update-settings |
GET | /admin/api/email-providers | List providers. | read-email-providers |
POST | /admin/api/email-providers | Create provider. | create-email-providers |
GET | /admin/api/email-providers/{id} | Get provider. | read-email-providers |
PATCH | /admin/api/email-providers/{id} | Update provider. | update-email-providers |
DELETE | /admin/api/email-providers/{id} | Delete provider. | delete-email-providers |
PATCH | /admin/api/email-providers/{id}/default | Set default provider. | update-email-providers |
POST | /admin/api/email-providers/{id}/test | Send a test email. | read-email-providers |
GET | /admin/api/email-templates | List templates. | read-email-templates |
POST | /admin/api/email-templates | Create template. | create-email-templates |
GET | /admin/api/email-templates/layout | Get shared header/footer. | read-email-templates |
PATCH | /admin/api/email-templates/layout | Update shared header/footer. | update-email-templates |
GET | /admin/api/email-templates/{id} | Get template. | read-email-templates |
PATCH | /admin/api/email-templates/{id} | Update template. | update-email-templates |
DELETE | /admin/api/email-templates/{id} | Delete template. | delete-email-templates |
POST | /admin/api/email-templates/{id}/preview | Render template with sample data. | read-email-templates |
PATCH | /admin/api/email-templates/{id}/send-test | Send the saved template to the signed-in user's own address. | update-email-templates |
GET | /admin/api/user-fields | List user field definitions. | read-settings |
POST | /admin/api/user-fields | Create user field. | create-settings |
PATCH | /admin/api/user-fields/reorder | Reorder user fields. | update-settings |
GET | /admin/api/user-fields/{id} | Get user field. | read-settings |
PATCH | /admin/api/user-fields/{id} | Update user field. | update-settings |
DELETE | /admin/api/user-fields/{id} | Delete user field. | delete-settings |
GET | /admin/api/api-keys | List every API key, to anyone who may read keys. | Cookie, or an API key with read-api-keys or update-api-keys |
POST | /admin/api/api-keys | Create API key. | Cookie (session-only) |
GET | /admin/api/api-keys/abilities?tokenType=…&roleId=… | Experimental. What a key you create now, of this type (and role, for role-based), would be able to do: { items: [{ slug, action, resource }], meta }. Refused as creating that key would be. | Cookie (session-only) |
GET | /admin/api/api-keys/{id} | Get API key metadata. | Cookie, or an API key with read-api-keys or update-api-keys |
PATCH | /admin/api/api-keys/{id} | Update any key's name/description. | Cookie (session-only) |
DELETE | /admin/api/api-keys/{id} | Revoke any API key. | Cookie (session-only) |
GET | /admin/api/dashboard/stats | Admin dashboard stats. | Cookie |
GET | /admin/api/dashboard/recent-entries | Recent activity. | Cookie |
GET | /admin/api/dashboard/activity | Activity feed. | Cookie |
GET | /admin/api/dashboard/content | Every collection and Single you may read, one row each: entries, drafts, last edit and who made it. | Cookie |
GET | /admin/api/schema/journal | Schema migration journal (super-admin only). | Cookie + super admin |
GET / PATCH | /admin/api/general-settings | Project-wide settings. | read-settings to read, update-settings to change |
GET | /admin/api/translations | One language's translation worklist across every localized collection: ?locale=es&state=missing&limit=50. See Languages. | Signed in; which rows come back is each collection's read rule |
GET | /admin/api/workflows/review-state | Experimental. A document's review state, part by part: ?collection=…&id=… or ?single=…. See Workflows. | Cookie / API key |
POST | /admin/api/workflows/steps | Experimental. Take one step on one document's parts. | Cookie / API key |
POST | /admin/api/workflows/steps/bulk | Experimental. Take one step on several documents, each refusal named. | Cookie / API key |
POST | /admin/api/workflows/assignments | Experimental. Assign parts, all or nothing. | Cookie / API key |
POST | /admin/api/workflows/assignments/bulk | Experimental. Assign parts on several documents, each refusal named. | Cookie / API key |
GET | /admin/api/workflows/waiting?page=…&limit=…&before=… | Experimental. What waits for the caller, a page at a time. | Cookie / API key |
GET | /admin/api/workflows | Experimental. The registered workflows and what each is attached to. | read-settings or update-settings |
GET | /admin/api/workflows/{slug}/settings | Experimental. A workflow's settings. | read-settings or update-settings |
PATCH | /admin/api/workflows/{slug}/settings | Experimental. Change a workflow's settings; changing grants also needs update-roles. | update-settings |
The slug-based permissions use the pattern {action}-{slug} so a posts collection requires read-posts, create-posts, etc.
A plugin may serve its own endpoints, and they are not listed here. /admin/api/forms, /admin/api/forms/{slug} and /admin/api/forms/{slug}/submit are served by @nextlyhq/plugin-form-builder at those exact addresses, and answer only when it is installed. They were once built in, which never worked without the plugin either: the collections they read are declared by it.
Per-section detail
The endpoint inventory above is the complete list. The sections below cover the request/response specifics for the groups with non-trivial body shapes.
Health
curl -i http://localhost:3000/api/healthHTTP/1.1 200 OK
content-type: application/json
cache-control: public, max-age=60, stale-while-revalidate=30
x-request-id: req_xxx
{
"ok": true,
"version": "0.0.142",
"uptime": 123,
"timestamp": "2026-05-05T09:00:00.000Z",
"database": { "ok": true, "dialect": "postgresql", "latency": 4 }
}When the database probe fails the runtime emits the canonical error envelope at status 503:
{
"error": {
"code": "SERVICE_UNAVAILABLE",
"message": "Service unavailable. Please try again later.",
"requestId": "req_xxx"
}
}HEAD /api/health returns the same status, headers, and X-Request-Id with no body — useful for monitors that only need the status code.
Auth
# Login
curl -i -X POST http://localhost:3000/admin/api/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"secure-password"}'A successful login responds 200 with the action envelope { message, user, accessToken, refreshToken, expiresAt } and sets the nextly_session and nextly_refresh cookies on the response. The REST routes authenticate a session by those cookies: browsers send them automatically, and an API client keeps them, as curl does with a cookie jar (-c and -b). An Authorization: Bearer header carries an API key, not the login's accessToken.
# Register
curl -X POST http://localhost:3000/admin/api/auth/register \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","password":"secure-password","name":"New User"}'# Forgot password
curl -X POST http://localhost:3000/admin/api/auth/forgot-password \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]"}'The forgot-password endpoint always returns 200 to avoid leaking which addresses exist. The reset email contains the token; consume it with POST /admin/api/auth/reset-password.
# Reset password
curl -X POST http://localhost:3000/admin/api/auth/reset-password \
-H "Content-Type: application/json" \
-d '{"token":"<token-from-email>","password":"new-secure-password"}'# Change password (authenticated)
curl -X PATCH http://localhost:3000/admin/api/auth/change-password \
-H "Content-Type: application/json" \
-b "nextly_session=..." \
-d '{"currentPassword":"old","newPassword":"new-secure"}'# Verify email
curl -X POST http://localhost:3000/admin/api/auth/verify-email \
-H "Content-Type: application/json" \
-d '{"token":"<token-from-email>"}'The setup wizard is a one-shot path that runs only when no super admin exists:
curl http://localhost:3000/admin/api/auth/setup-status
# {"isSetup":false,"requiresInitialUser":true,"requiresSetupToken":false,"allowRegistration":false}
curl -X POST http://localhost:3000/admin/api/auth/setup \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","name":"Admin","password":"strong-password"}'Re-running setup after the first super admin exists returns a 409.
Collection entries
List:
curl "http://localhost:3000/admin/api/collections/posts/entries?limit=10&page=1&sort=-createdAt&where[status][equals]=published"{
"items": [{ "id": "abc-123", "title": "Hello world", "status": "published" }],
"meta": {
"total": 42,
"page": 1,
"limit": 10,
"totalPages": 5,
"hasNext": true,
"hasPrev": false
}
}Get by ID:
curl "http://localhost:3000/admin/api/collections/posts/entries/abc-123?depth=2"{
"id": "abc-123",
"title": "Hello world",
"author": { "id": "user-1", "name": "John Doe" },
"createdAt": "2026-01-15T10:30:00.000Z",
"updatedAt": "2026-01-15T10:30:00.000Z"
}Create:
curl -X POST "http://localhost:3000/admin/api/collections/posts/entries" \
-H "Authorization: Bearer nx_live_..." \
-H "Content-Type: application/json" \
-d '{"title":"New Post","content":"Hello!","status":"draft"}'{
"message": "Posts created.",
"item": { "id": "...", "title": "New Post", "status": "draft" }
}Update (PATCH a single field set; everything not in the body is left alone), with the _rev
your last read returned (see Versions and conflicts):
curl -X PATCH "http://localhost:3000/admin/api/collections/posts/entries/abc-123" \
-H "Authorization: Bearer nx_live_..." \
-H "Content-Type: application/json" \
-d '{"status":"published","_rev":"7"}'Delete:
curl -X DELETE "http://localhost:3000/admin/api/collections/posts/entries/abc-123" \
-H "Authorization: Bearer nx_live_..."Count:
curl "http://localhost:3000/admin/api/collections/posts/entries/count?where[status][equals]=published"
# {"total": 42}Duplicate:
curl -X POST "http://localhost:3000/admin/api/collections/posts/entries/abc-123/duplicate" \
-H "Authorization: Bearer nx_live_..."Bulk delete (status 200, partial success in body):
curl -X POST "http://localhost:3000/admin/api/collections/posts/entries/bulk-delete" \
-H "Authorization: Bearer nx_live_..." \
-H "Content-Type: application/json" \
-d '{"ids":["post-1","post-2","post-3"]}'{
"message": "Bulk delete completed.",
"items": [{ "id": "post-1" }, { "id": "post-2" }],
"errors": [
{ "id": "post-3", "code": "NOT_FOUND", "message": "Resource not found." }
]
}Bulk update by IDs:
curl -X POST "http://localhost:3000/admin/api/collections/posts/entries/bulk-update" \
-H "Authorization: Bearer nx_live_..." \
-H "Content-Type: application/json" \
-d '{"ids":["post-1","post-2"],"data":{"status":"archived"},"revs":{"post-1":"7","post-2":"3"}}'Bulk update by query (PATCH on the collection root with a where clause in the body):
curl -X PATCH "http://localhost:3000/admin/api/collections/posts/entries" \
-H "Authorization: Bearer nx_live_..." \
-H "Content-Type: application/json" \
-d '{"where":{"status":{"equals":"draft"}},"data":{"status":"archived","_overwrite":true}}'Schema changes that replace a field
A schema change sent to PATCH /admin/api/collections/{slug} or PATCH /admin/api/singles/{slug}/schema that removes one field and adds another of the same type is never taken for a rename by guesswork. The request says which it is, in renames, by field name:
{
"fields": [{ "name": "headline", "type": "text" }],
"renames": [{ "from": "heading", "to": "headline", "choice": "rename" }]
}"rename"keeps the field's values under its new name."drop_and_add"drops the old field and its values and adds the new one empty.
A change that makes such a pair without answering it is refused before anything is written, with FIELD_RENAME_UNANSWERED, naming both fields. A rename is one field at a time: a "rename" answer for two fields replaced at once is refused with FIELD_RENAME_NOT_OFFERED, a change answering "rename" for two pairs with FIELD_RENAME_ONE_AT_A_TIME, and a shared field can't be renamed into a translated one in the same change, translation turned on in it included (FIELD_RENAME_JOINS_TRANSLATION). "drop_and_add" is refused for two fields stored in one place, one column or one many-to-many junction table both name (FIELD_RENAME_SAME_COLUMN).
A field group's rows are kept when its field is removed, or dropped with "drop_and_add": they remain until the field group or the entity is deleted.
Singles
List metadata for every registered single:
curl http://localhost:3000/admin/api/singlesGet the actual content:
curl http://localhost:3000/admin/api/singles/site-settingsUpdate content:
curl -X PATCH http://localhost:3000/admin/api/singles/site-settings \
-H "Authorization: Bearer nx_live_..." \
-H "Content-Type: application/json" \
-d '{"siteName":"My New Site","maintenanceMode":false,"_rev":"4"}'Document locks
The admin claims an entry or a Single while someone has it open, so that a colleague who opens it is told who is editing (see Editing with others). The claim is advisory: no write is refused because someone else holds the document, through this API or any other. Saves are kept from replacing each other by the document's version instead (see Versions and conflicts).
A document is named by three values: scopeKind (collection or single), slug (the
collection's or Single's slug) and entryId (the entry's id, or the id a Single's content read
returns). They go in the query string of a GET, and in the JSON body of every other request. A
missing or unusable value is a 400 VALIDATION_ERROR whose error.data.errors[] entry has the
code invalid_document_ref.
Who is editing:
curl "http://localhost:3000/admin/api/document-lock?scopeKind=collection&slug=posts&entryId=abc-123" \
-H "Authorization: Bearer $NEXTLY_API_KEY"{
"holder": {
"ownerId": "user-1",
"ownerLabel": "Ana Silva",
"expiresInSeconds": 132
}
}holder is null when nobody holds the document. The answer is sent private, no-store,
because it names a colleague.
Claim it:
curl -X POST "http://localhost:3000/admin/api/document-lock" \
-H "Authorization: Bearer $NEXTLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"scopeKind":"collection","slug":"posts","entryId":"abc-123"}'{
"message": "Document claimed.",
"item": {
"status": "acquired",
"holder": {
"ownerId": "user-1",
"ownerLabel": "Ana Silva's API key",
"expiresInSeconds": 150
},
"claimToken": "…"
}
}When someone else holds it, the claim is still answered 200, not refused:
{
"message": "Document is being edited by someone else.",
"item": {
"status": "held",
"holder": {
"ownerId": "user-2",
"ownerLabel": "Ben Okafor",
"expiresInSeconds": 97
},
"waiting": false
}
}"Someone else is editing" is an answer to show, not an error, so a held document never comes
back as 409. The claim token is given only to the caller whose claim succeeded.
ownerLabel is what the admin calls the holder. A person is named by their
name, or by their email when they have no name. An API key is named as a key, by the name of the
person who made it ("Ana Silva's API key"), or as "An API key" when that person has no name. A
claim with nothing to name it by reads "Someone". A claim taken before Nextly named its holders
has ownerLabel: null until it is released or lapses, so read it as possibly null; the admin
shows it as "Someone". ownerId is the user's id, which for an API key is the id of the person
who made it.
Three options ride on the claim:
"takeover": truetakes the document from its holder. The holder's next renewal finds the claim gone. Taking over from someone else is recorded in the document's history; if that record cannot be written, the takeover is refused and the holder keeps the document."requestAccess": truemarks that someone is waiting. It moves nothing: the holder is told on their next renewal, without being told who asked, andwaitingistrueon both sides until the request lapses. The document passes on only when the holder leaves or their claim lapses."reclaimToken": "<token>"takes back a claim whose renewals went unanswered, for example after the connection dropped. It is granted only when nobody holds a live claim or the live claim is the one named, and it returns a new token. Unlike a plain claim it never takes the document from the same person's other tab or key. A value that is not a token is refused with a400.
Renew it, with the token the claim returned:
curl -X PATCH "http://localhost:3000/admin/api/document-lock" \
-H "Authorization: Bearer $NEXTLY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"scopeKind":"collection","slug":"posts","entryId":"abc-123","claimToken":"…"}'The item is { "status": "renewed", "holder": …, "waiting": false }, or { "status": "lost" }
when the claim lapsed or was taken over. A lost claim carries holder when someone else now holds
the document.
Told of a change. A claim or a renewal may also send _rev, the version the caller's copy of
the document started from. When the document has changed since, an answer that holds it
(acquired or renewed) carries changed, with the same fields as a refused save's
publicData, under the same rules: currentVersion always, and who changed it, when, and the
matching history version only for a caller who may read the document (see
Versions and conflicts). A copy read in one language is judged on the
shared fields and that language. A held or lost answer never carries changed, and a claim
without _rev is answered as before. A malformed _rev is a 400 VALIDATION_ERROR, refused
before anything is claimed. One in the form a read returns is only compared, never refused: a
version no read gave, such as one above the current version, is claimed and answered with
changed like any other copy that differs. The admin sends its copy's _rev, so an editor hears
of a colleague's change within one renewal, before saving, and an editor taking a document back
learns it changed while they were away.
Give it up with DELETE and the same body. The item is { "released": true }, and releasing a
claim already lost is not an error. A renewal or release without claimToken is a
400 VALIDATION_ERROR.
Who may call.
- Reading who holds a document needs read access to that document. Under a read rule that allows only some entries, that means one the rule matches (see Permissions).
- Claiming, renewing and taking over are judged exactly as an update of that document: the
update-{slug}permission, and the collection's or Single's own update rule for that document. An API key needs both its grant and the rule. - Giving up a claim needs
update-{slug}, and the claim token proves it is the same claim. - The claimant is always taken from the session or API key, never from the body.
- A refusal is
403 FORBIDDEN, and it does not say whether the document exists.
Timings. The admin renews its claim every 15 seconds. A claim that is not renewed lapses 150 seconds after its last renewal, timed by the database's clock, and every read ignores a lapsed claim at once.
The admin gives its claim up as soon as the editor closes, including when the tab is closed or
reloaded or the browser leaves the admin. A claim is left to lapse only when the admin cannot say
it is done: after a crash, a lost connection, or a computer that went to sleep. A script that
claims a document should release it with DELETE when it is done, so nobody waits out the lapse.
One holder per person. A claim by the person who already holds the document is granted,
unless it names a reclaimToken that is not the live claim's, and moves the claim to the new caller. One person in two tabs holds the document once,
and so do a person and an API key they made, because both claim as that person. The admin tells
the tab the claim moved from that the document was opened in another tab, even when it was the
key that claimed it. Moving a claim between one person's tabs and keys is not a takeover, and
history records nothing.
Cleaning up. Lapsed claims are deleted by the document-lock:sweep job, which runs whenever
the scheduled jobs run does. Nothing depends on it for
correctness: it only keeps the table from growing.
Email send
There is no REST route for sending email: a route that let any signed-in caller or API key pick the recipient would let anyone with access send as the site. Send from server code with nextly.email.send() or nextly.email.sendWithTemplate() (see Direct API → Email), or add a route of your own that checks who may send, and to whom, before it calls them.
The admin's test send, PATCH /admin/api/email-templates/{id}/send-test, sends the saved template only to the signed-in user's own address. It takes variables in the body and ignores any recipient, and it refuses API keys.
Media
The media collection is just a normal collection (/admin/api/collections/media/entries) with extra plumbing for binary uploads. The POST /admin/api/collections/media/entries endpoint accepts multipart/form-data with the file under file and any other fields alongside.
An uploaded image is stored as the original and one thumbnail, the whole image fitted inside 480 by 480; no other size is made. See Images and thumbnails.
API keys
Creating, changing and revoking keys (POST, PATCH and DELETE under /admin/api/api-keys), and the abilities summary, are session-only. They do not accept Bearer authentication, so an attacker with a stolen key cannot mint new keys with it. Manage keys from the admin UI or via cookie-authenticated requests. Listing and reading keys (GET /admin/api/api-keys and GET /admin/api/api-keys/{id}) also accept an API key that holds read-api-keys or update-api-keys.
curl http://localhost:3000/admin/api/api-keys -b "nextly_session=..."POST /admin/api/api-keys returns the new key value once at creation; it is hashed on the server and never displayed again.
Anyone who may read keys (read-api-keys, or update-api-keys) lists and reads every key, not only their own. After creation a key shows only its prefix, so none can be copied from the list.
Each key in the list and in GET /admin/api/api-keys/{id} carries its owner ({ id, name, email }) and its lastUsedAt, which a request made with the key advances. owner is null in two cases:
- The account is gone.
- The caller may not read users. A person always sees themselves on their own keys, and sees everyone's owners only with
read-users. An API key sees owners only if it holdsread-users.
These responses are private to the caller (Cache-Control: private, no-store).
The permission reaches every key, the caller's or anyone else's. update-api-keys renames any key, and delete-api-keys (or update-api-keys) revokes any key. Creating a key is only ever for yourself.
GET /admin/api/api-keys/abilities is experimental: its shape may change while the key form that uses it does. It answers from the same resolution a key's own requests use, so the summary is the permissions the key gets. A collection's or Single's access rule written in code can still refuse a request those permissions allow, and may depend on the entry, so it is not reflected here. A read-only or full-access key follows its creator's permissions, so its answer changes as theirs do.
Workflows (experimental)
These routes read and move review state for collections and Singles that have a workflow attached. The routes and their shapes may change while the review screens that use them are finished.
Naming the document. Each route names its document as { collection, id } or { single }: in the query for a read, in the body for a write. One route serves collections and Singles alike.
Read access. A caller who may not read the document is answered 404 NOT_FOUND, exactly as if it did not exist, even where they hold a step's permission. Parts in a language the caller may not read the document in are left out.
Review state
GET /admin/api/workflows/review-state?collection=posts&id=… returns the document's review state as the body itself:
{
"workflow": { "slug": "editorial", "label": "Editorial" },
"parts": [
{
"part": "es",
"stage": "legal",
"stageLabel": "Legal check",
"stageColour": null,
"publishable": false,
"enteredAt": "2026-11-17T09:00:00.000Z",
"enteredBy": "alice",
"assignee": { "kind": "user", "id": "rita" },
"dueAt": null,
"approval": null,
"revision": 3,
"version": "…",
"reviewedVersionNo": 12,
"steps": [
{
"name": "clear",
"label": "Clear",
"kind": "approve",
"to": "cleared",
"mayTake": true,
"primary": true,
"commentRequired": false
},
{
"name": "bounce",
"label": "Bounce",
"kind": "request-changes",
"to": "writing",
"mayTake": true,
"primary": false,
"commentRequired": true
},
{
"name": "park",
"label": "Park",
"kind": "move",
"to": "hold",
"mayTake": false,
"primary": false,
"commentRequired": true
}
],
"waitingFor": { "kind": "user", "id": "rita", "name": "Rita" },
"lastMove": {
"kind": "workflow-submit",
"actor": { "kind": "person", "id": "alice", "name": "Alice" },
"at": "2026-11-17T09:00:00.000Z",
"from": "writing",
"to": "legal",
"comment": "Ready for legal"
}
}
],
"mayPublishWithoutReview": false
}What the fields mean:
part: a language code, ornullfor the shared part. A document that is not translated has only the shared part.stage:nullfor a live part with nothing waiting to go live.stageLabel,stageColour: the stage as Settings shows it: the label and colour saved there, else the code's label andnull.approval:{ versionNo, by, at }where the part holds an approval, elsenull.revisionandversion: what a step sends back as what it saw.reviewedVersionNo: the number of the part's version under review: its newest recorded version, in its language or, for the shared part, in any language. It is what approving the part approves;nullfor a part never saved.steps: the steps out of the part's stage.mayTake: whether the caller may take the step on this part. The server judges it with the same checks the step itself makes of who takes it: the step's permission (or the right to edit or publish, where it names none), a signed-in person for an approval or a request for changes (so an API key's is alwaysfalse), and no self-approval where the step refuses it. A step can still be refused when taken, for what the caller saw being out of date, a missing comment, or fields the approver cannot read. Approvals are made by people: trusted server code may take every other step, and seesmayTake: falsefor an approval or a request for changes.primary:trueon the stage's primary step (its only step out, or the one markedprimary),falseon the others.commentRequired: whether the step is taken only with a comment: always for a request for changes, and for any other step whose definition asks for one.
waitingFor: in order, the part's assignee; else its stage's default reviewer, where they may take the stage's primary step; else the roles that may take it ({ "kind": "roles", "roles": [{ "id", "name" }] }). It isnullin a stage with no step out of it.lastMove: the part's latest workflow event other than an assignment;nullfor a part that never moved.mayPublishWithoutReview: whether the caller may publish the document without review, judged as a publish that asks to is:truefor a person holdingpublish-without-review-<slug>and for trusted server code, never for an API key, whatever it holds.
A document whose collection or Single has no workflow attached answers 200 with { "workflow": null, "parts": [], "mayPublishWithoutReview": false }. The read check runs first, so a missing document, or one the caller may not read, is still 404 NOT_FOUND whether or not a workflow is attached. Taking a step or assigning on such a document is refused with WORKFLOW_NOT_ATTACHED.
Steps
POST /admin/api/workflows/steps takes one step, and answers { message, item }:
{
"document": { "collection": "posts", "id": "…" },
"step": "send",
"parts": ["es"],
"seen": [{ "part": "es", "revision": 3, "version": "…" }],
"comment": "Ready for legal"
}parts: a list, or"all".seen: the revision and version the caller read for each part. A part that moved since is refused with409.- API keys: a key may never approve or request changes, whatever it holds.
- Unknown documents and parts: a document that does not exist is
404 NOT_FOUND. A part the document cannot have (a language the site does not have, or any language on a document that is not translated) is refused withWORKFLOW_UNKNOWN_PART. The same holds for assignments, and for each document of a bulk request.
POST /admin/api/workflows/steps/bulk takes one step across several documents: { step, comment?, documents: [{ document, parts, seen }] }.
- Each document moves on its own if it may. The answer is a bulk envelope: each document moved in
items, and each refusal inerrorsas{ id, code, message },idbeing the document's id. A refused Single is named by its slug alone,{ single, code, message }, so a refusal never tells you its stored id. - An approval over several documents is refused before anything moves (
WORKFLOW_BULK_APPROVAL). An approval is given for the one version a reviewer was shown.
Assignments
POST /admin/api/workflows/assignments assigns parts, all or nothing: { assignments: [{ document, part, revision, assignee: { kind: "user" | "role", id } | null, dueAt? }] }.
- The assignee must be able to take the stage's primary step. Otherwise the request is refused with
WORKFLOW_ASSIGNEE_LACKS_STEP. /assignments/bulktakes the same body, applies each assignment it may, and names each refusal in a bulk envelope.
What waits for you
GET /admin/api/workflows/waiting?page=1&limit=20 lists the parts that wait for the caller, as a list envelope, oldest entry into their stage first. Where a collection's workflow starts in a review stage, a part no step has moved yet waits there too, with no review state: it is listed in each language its reader may read, unassigned, as having entered its stage when its document was created. Each item names its document, part and stage (with stageLabel and stageColour, as the review state shows them), its assignee, and:
title: the document's title as the caller reads it. A title a rule withholds from the caller reads"Untitled", never the title itself.waitingFor: whom the part waits for, named as the document's review state names it: a person ({ kind: "user", id, name }) or the roles that may take the step ({ kind: "roles", roles: [{ id, name }] }).
A page's titles and names are each read once for the page, however many items it holds. A part waits for the caller in a stage whose primary step they may take (its permission, and who may take it: an approval is never a key's, nor that of the person who brought the part into a stage that refuses self-approval), when it is:
- assigned to them, or to a role they hold;
- assigned to someone who can't take that step on this part, because they lost it or brought the part into a stage that refuses self-approval: such work waits for everyone who can;
- assigned to no one (
assignee: null), where the stage's default reviewer is them, or the stage has no default reviewer who may take the step on this part.
API keys see work assigned to their roles, not to their owner personally. A key, full-access or scoped to a role, stands for its roles alone.
Only parts the caller may read are listed and counted: a hidden part never takes a place on a page, and total never counts one. A request reads parts oldest first, 1,000 at a time, until it has enough to fill its page and know whether there's a next one, and never more than 20,000 in one request. When it stops before reading everything, total counts what it found and meta.totalCapped is true. That total is a floor, so show it as "N+". hasNext is then true.
Every page that has a next one also carries meta.nextBefore: an opaque position: pass nextBefore back as before to get the next page; this list runs oldest first. Don't parse it or build one: pass back what nextBefore gave. Text that isn't a well-formed position is refused with VALIDATION_ERROR, and so is before beside a page past the first, and a cursor an earlier version of this list gave. Each request reads on from its cursor, within the same 20,000, so a walk by before reaches work behind any number of parts the caller can't see, and a part that joins the list while you walk comes once, at the end. A page read by before describes itself alone: total is its own item count and page is 1. page and limit work as before; the cursor is an addition.
GET /admin/api/workflows/waiting/scope says whether anything can ever wait for the caller's review: { "reviews": true, "stages": 2 }. stages counts the stages whose next step the caller may take, in collections and Singles they may read, judged as the waiting list judges them, with no document read. reviews is true when there is at least one. It answers for the signed-in caller alone (an API key by its own scope), and refuses a caller who isn't signed in with a 401. The admin shows "Waiting for my review" on it.
Settings
GET /admin/api/workflows lists the registered workflows: each one's stages, steps (with whether each is grantable), and the collections and Singles it is attached to.
configPath: the configuration file that registers it, relative to the project root, ornullwhen none was found or it lies outside the root.- Diagram: each step's
permission(its own, or the collection'supdate, orpublishinto a stage that allows publishing) andcommentRequired; each stage'sprimaryStep, whether it is areviewstage, and how it is shown (shownLabelandcolour, saved in Settings, else the code'slabelandnull); and the workflow'sonEdit(to,exemptFields) andafterPublish. stageCounts: how many documents are recorded in each stage, a document with several parts there counted once. A part in a stage the workflow no longer has counts in the first stage; a document that has never moved has no record and is not counted.
GET /admin/api/workflows/{slug}/settings returns:
{
"workflow": "editorial",
"revision": 1,
"defaultReviewers": { "legal": { "kind": "user", "id": "nina" } },
"labels": { "legal": { "label": "Lawyers", "colour": "#aa3300" } },
"emails": { "assigned": true, "approved": false, "changesRequested": true },
"grants": { "clear": ["<roleId>"], "bounce": ["<roleId>"] },
"grantableSteps": {
"clear": {
"permission": "sign-off",
"partialRoles": [{ "id": "<roleId>", "name": "old-desk" }],
"sharesPermissionWith": ["bounce"]
}
},
"defaultReviewerHolds": { "legal": "holds" },
"reviewerRoles": { "legal": ["<roleId>", "<superAdminRoleId>"] }
}defaultReviewerHolds says, for each stage with a default reviewer, whether that person or role still holds the stage's primary step on every attached collection and Single: holds, lacks, deactivated or not-found.
reviewerRoles lists, for each review stage, the roles holding its primary step on every attached collection and Single: those granted it, those inheriting it, and the super-admin role, never the Public role, which stands for visitors. A default reviewer is a role from this list, or a person with one of them; the Public role is refused as one with WORKFLOW_INELIGIBLE_REVIEWER, whatever it holds.
PATCH /admin/api/workflows/{slug}/settings changes them, and answers { message, item } with the settings as they now read. The body names the revision it read, plus any of defaultReviewers, labels, emails and grants.
- Merging: each part is merged into what is stored, and
nullclears a stage's entry. - Stale writes: a stale
revisionis refused with409. - Grants are an exact set. Saving a step leaves exactly the listed roles holding its permission, on every attached collection and Single. A role listed in
partialRoles(holding it on only some of them) that is not named loses it. - Grants need more permission. Changing
grantsalso requiresupdate-roles. - Grantable steps: only steps naming a permission of their own can be granted.
- Shared permissions: steps that share a permission (
sharesPermissionWith) always hold the same roles. Naming them with different roles is refused withWORKFLOW_CONFLICTING_GRANTS. - Default reviewers: a default reviewer must be able to take the stage's primary step on every attached collection and Single, counting the grants in the same request. Otherwise the write is refused with
WORKFLOW_INELIGIBLE_REVIEWER, and nothing is written. - Read-only definition: the definition itself (stages, steps and their rules) lives in code. Naming any of it is refused with
WORKFLOW_DEFINITION_READ_ONLY.
Changes are recorded in the settings history.
Query parameters
These parameters are accepted by every list endpoint that delegates to the collection / single dispatcher.
status
For Draft/Published collections and singles, ?status= controls which lifecycle states a read returns.
| Value | Returns |
|---|---|
| (omitted) | Published only — the safe default. Drafts are never returned unless you ask. |
published | Published only (explicit). |
draft | Drafts only. |
all | Every entry regardless of status. |
?status=all
?status=draftAn unrecognized value (a typo like ?status=pubished) is rejected with 400 VALIDATION_ERROR rather than silently returning everything, so a bad filter can never widen a read. Trusted server-side calls through the Direct API (which bypass access checks) see every status by default; over HTTP the default is always published-only. The admin panel requests ?status=all explicitly so editors still see their drafts.
where
Filter rows using bracket notation:
?where[status][equals]=published
?where[price][greater_than]=100
?where[title][contains]=hello
?where[category][in]=news,featuredOperators (verified against packages/nextly/src/domains/collections/query/query-operators.ts):
| Operator | Description | Query string example |
|---|---|---|
equals | Exact match. | where[status][equals]=published |
not_equals | Not equal. | where[status][not_equals]=draft |
greater_than | > | where[price][greater_than]=100 |
greater_than_equal | >= | where[price][greater_than_equal]=100 |
less_than | < | where[price][less_than]=50 |
less_than_equal | <= | where[price][less_than_equal]=50 |
like | SQL LIKE (case-sensitive). | where[title][like]=%hello% |
contains | Substring, ignoring case on every database, letters outside ASCII included; % and _ are matched as typed. See Direct API operators. | where[title][contains]=hello |
search | Alias for contains. | where[title][search]=hello |
in | Value in comma-separated list. | where[status][in]=draft,published |
not_in | Value not in comma-separated list. | where[status][not_in]=archived |
exists | Field is non-null when true, null when false. | where[image][exists]=true |
A date (createdAt, updatedAt, or a date field of the collection itself) is compared with an ISO 8601 value: an instant with its offset, such as 2026-09-01T09:00:00Z or 2026-09-01T11:00:00+02:00, or a calendar date, such as 2026-09-01, which means the start of that day in UTC. Any other value, including a time with no offset, is refused with a 400 whose error.code is VALIDATION_ERROR, naming the filter in error.data.errors with the code FILTER_INVALID_OPERAND.
?where[createdAt][greater_than_equal]=2026-09-01&where[createdAt][less_than]=2026-10-01Filtering a has-many relationship
A relationship or upload with hasMany: true holds a list of related entries. On such a field the operators match by membership in that list:
| Operator | Keeps | Query string example |
|---|---|---|
in | Entries related to at least one of the ids. | where[tags][in]=<id-1>,<id-2> |
equals | Entries related to that id, whatever else they are related to. | where[tags][equals]=<id> |
not_in | Entries related to none of the ids, including entries with no related entries at all. | where[tags][not_in]=<id> |
not_equals | Entries not related to that id, including entries with no related entries at all. | where[tags][not_equals]=<id> |
exists | Entries whose field is set (true) or not set (false). | where[tags][exists]=true |
An id is matched whole, never as part of another id. contains, search and like are refused on such a field with a 400 whose error.code is VALIDATION_ERROR, naming the filter in error.data.errors with the code FILTER_OPERATOR_NOT_FOR_LIST; use in with the related entry's id instead. To filter by something about the related entries, such as a tag's name, look up their ids first. The same holds for the Direct API's where. A relationship that can point to more than one collection, or one stored as many-to-many, is not covered by this.
For nested AND / OR you can either pass URL-encoded JSON via where=..., or use the index syntax:
?where[and][0][status][equals]=published&where[and][1][category][equals]=newsEntries waiting to publish (experimental)
Two reserved conditions keep a collection's entries by where they stand in publishing rather than by a field. They are what the dashboard's Needs attention card counts with, so a count and the list it links to hold the same entries. Both are experimental: their names and forms may change while that card is finished.
| Condition | Keeps | Query string example |
|---|---|---|
_pendingChange: true | Entries whose draft holds changes not yet published. | where[_pendingChange]=true |
_inRelease: { scheduledBefore } | Entries a scheduled release will publish after now and no later than scheduledBefore, an instant with its zone. | where[_inRelease][scheduledBefore]=2026-10-28T09:00:00Z |
_inRelease: true | The same, with no upper bound. | where[_inRelease]=true |
- An entry is kept once, however many of its languages or releases hold it.
- Only the languages the read is judged for count: the
localeit reads and its fallbacks, or every language withlocale=all. A draft or a release member in another language does not keep the entry. - A release's member that it will unpublish is not counted.
- A release whose time has passed is left out, even while it waits to run.
- Each condition is accepted only at the top level of a filter, beside other conditions there:
{ "_pendingChange": true, "status": { "equals": "draft" } }. Insideandororit is refused withFILTER_MISPLACED_KEY. - Any other value is refused with
FILTER_INVALID_OPERAND:false, an empty object, an extra key, or a time without a zone. _inReleaseneeds the right to read content releases as well as the collection. A caller without it is refused exactly as if the condition did not exist (FILTER_UNKNOWN_FIELD), so the filter says nothing about what releases hold. A bulk update or delete selected by_inReleaseis refused the same way, before any entry is written.
Entries in review (experimental)
On a collection a workflow holds, four more reserved conditions keep entries by where their parts stand in review. Like the ones above, each is accepted only at the top level of a filter, and a collection no workflow holds keeps no entry for any of them (no refusal).
| Condition | Keeps | Query string example |
|---|---|---|
_stage: "<stage>" | Entries with a part in that stage, each part's stage read as a step reads it (a part with no review state stands where its content puts it). | where[_stage]=legal |
_assignedToMe: true | Entries with a part assigned to the reader or to one of their roles. An API key stands for its own roles alone. | where[_assignedToMe]=true |
_waitingForMe: true | Entries with a part waiting for the reader's review, by the waiting list's own read (GET /workflows/waiting). An API key is judged by its own scope. | where[_waitingForMe]=true |
_changedSinceApproved: true | Entries with a part saved again since its last approval (the version the "Since approved" comparison reads; a publish closes the cycle). | where[_changedSinceApproved]=true |
- Only the parts the read may see count: the shared part, and the languages the read is judged for.
_waitingForMereads at most 1,000 waiting parts for one list. Where more wait, the list keeps the documents of those it read and itsmeta.totalCappedistrue: the total is a floor.
Each row's review state (experimental)
?reviewState=true (the Direct API's reviewState: true) gives each row of a collection a workflow holds its review state under _review: { parts: [...] }, each part with its stage, stageLabel, stageColour, publishable, enteredAt, assignee, dueAt, waitingFor, and the revision and version a step names as seen. Each part is placed as GET /workflows/review-state places it, read for the whole page at once, among the parts the read may see. A visitor's rows, and the rows of a collection no workflow holds, carry no _review key.
sort
Field name; prefix with - for descending. Separate several keys with commas; each sorts in turn, and entries still tied come back in id order.
?sort=-createdAt
?sort=title
?sort=-featured,createdAtAn entry with no value for a key sorts after the entries with one, in either direction.
Pagination
?limit=20&page=2Maximum limit is 500 (anything higher is clamped). The response always includes the meta envelope with total, page, limit, totalPages, hasNext, and hasPrev.
On a very large collection, counting every matching entry is the slowest part of a list. Ask for a capped count, and the count stops at 1,000:
?count=capped&limit=25&page=41- 1,000 entries or fewer match:
totalis exact, as without the parameter. - More match:
totalis1000andmeta.totalCappedistrue. Show it as "1000+".
Paging works past the cap either way: hasNext and hasPrev say whether there is a page after and before this one. totalPages counts only the pages known so far, so don't offer a jump to the last page while totalCapped is set. Without count, or with count=exact, the total is always exact. Any other value is refused with a 400.
depth
Relationship population depth. 0 returns only IDs; 1+ populates referenced documents.
?depth=0 # IDs only
?depth=1 # populate direct relationships
?depth=2 # populate one level deeperstored
On a read of one collection entry, ?stored=1 adds _stored: the same entry as a read
with depth=0 in the same locale, fallback-locale, fallback, draft and status
returns it, with every relationship and upload as its stored id. The options that shape
only the populated read (select, translation-status, source-locales, translations
and the rich text formats) do not apply to it. It is the read an editor needs beside a
populated one: a populated read leaves out a related document the caller may not read, or
one that no longer exists, and _stored still names it.
GET /admin/api/collections/posts/entries/abc-123?depth=2&stored=1Both reads are made as the caller, with the same access rules and hooks as two separate
requests. If either fails, the request fails: a refusal (403) or a missing entry (404)
is returned first, from either read.
select
Whitelist of fields to include. Two spellings, both accepted:
?select=id,title,publishedAt # comma-separated
?select={"id":true,"title":true} # JSON object (URL-encode it)The id and the system timestamps come back whether or not they are named.
A select the API cannot read is a 400, rather than a response carrying every
field — a projection that is silently discarded looks exactly like one that was
never asked for. Naming no fields at all is unreadable for the same reason; omit
the parameter to get every field.
richTextFormat
?richTextFormat=html # rendered HTML
?richTextFormat=json # Lexical JSON (default)
?richTextFormat=both # { json, html }richTextStyles
How the HTML that richTextFormat=html or both returns is styled:
?richTextStyles=default # Nextly's look, as inline styles (default)
?richTextStyles=none # classes only, for your own CSSWith none, no element carries a style Nextly adds. Each one has a class in the
nextly-rich-text- namespace, alignment is a class too, and styles an author chose in the
editor (a text colour, a button's colours) are kept. The classes are listed under
Styling rich text HTML. A value other
than these two returns the default look, as an unknown richTextFormat returns JSON.
Languages
On a localized collection or Single (see Localization). How each language falls back, and how access rules are told which languages a request involves, are described there; these are the parameters that choose them.
| Parameter | Values | What it does |
|---|---|---|
locale | A configured language code; all on a read; * on a write | The language a read returns or a write stores. Missing, the default language. A read naming an unknown code reads the default; a write naming one is refused with a 400, rather than storing into the default. all reads the default language and adds _allLocales, as translations=all does. * moves a publication status across every language: its body must be a status patch alone, and any field value is refused with a 400. To write values, name their language. |
fallback-locale | A language code, or none | Where a read takes a value its language lacks. Unset, the language's own fallback chain. none turns fallback off, so an untranslated field reads empty. |
fallback | document | On a read of one document: where it isn't published in the requested language, answer in the first language of its fallback chain that it is published in, and add _locale. A list asked for it is refused with a 400. See Reading in a language. |
source-locales | 1 | Adds _sources: for each translated field, the language its value came from, or null. |
translations | all | Adds _allLocales: each translated field's value in every language, beside the document's own fields in the language read. |
translation-status | 1 | Adds _translations to each document: for every configured language, whether it has content of its own (translated) and, with a draft/published lifecycle, its status. |
where[_translated] | [locale]=<code> and [state]=<state> | Lists only the documents in that state in that language: missing, translated, draft, published or stale. draft and published need Draft/Published enabled; without it they filter nothing and every matching document comes back. A reserved key, not a field filter. |
?locale=es&fallback-locale=none
?locale=es&fallback=document
?locale=en&translations=all&source-locales=1
?locale=all
?translation-status=1
?where[_translated][locale]=es&where[_translated][state]=missingGET /admin/api/translations is the same question across the localized collections: one
language's outstanding work, ?locale=es&state=missing&limit=50, with state taking the values
above. Each collection's read rules decide which of its documents come back.
The answer can be incomplete, and says so in meta. It asks at most 20 collections
(MAX_WORKLIST_COLLECTIONS); the slugs it skipped, and any whose read failed, are listed in
meta.notConsulted. Collections that cannot answer a translation question until their
schema is migrated are listed in meta.unanswerable. Each field is present only when it
has entries. The rows are also cut at limit: meta.total counts every matching document
in the collections asked, so meta.total above the number of rows (or meta.totalPages
above 1) means more work than this answer lists. The endpoint takes no page, and
meta.hasNext is always false, so read these fields, not hasNext, to know whether the
answer is whole; ask with a larger limit, up to 200, to see more.
Pagination
Page-based with the meta envelope. Use meta.hasNext to drive a "Next page" UI; do not assume a fixed totalPages because the underlying count can change between requests.
async function fetchPosts(page = 1) {
const params = new URLSearchParams({
limit: "10",
page: String(page),
sort: "-createdAt",
"where[status][equals]": "published",
depth: "1",
});
const response = await fetch(
`/admin/api/collections/posts/entries?${params}`,
{
credentials: "include",
}
);
const json = await response.json();
return json; // { items, meta }
}Security
The route handler ships with built-in defences:
- Rate limiting on auth write endpoints (per IP) and global per-IP / per-key limits configured in
nextly.config.ts. - CORS controlled by
NEXTLY_ALLOWED_ORIGINSand thesecurityconfig. - Cache headers (
no-store) on every/admin/api/auth/*response to keep tokens out of caches. - Super-admin protection: only a super-admin can give super-admin authority, whether by assigning the role or a role that inherits it, or by making a role inherit one. An API key can't, whoever made it.
- Trusted proxy / forwarded-for filtering when
trustProxyis on.
See Configuration and Authentication for the configurable surface.
Next steps
- Direct API — server-side equivalent with no HTTP overhead.
- Authentication — RBAC, API keys, and cookie configuration.
- Collections — define the content types this API serves.
- Configuration — security, rate-limit, and storage configuration.