API Endpoints
Reference for the REST API of the platform DevOur generates for your project.
Authentication
When your project has Firebase configured, requests need the signed-in user's Firebase ID token:
Authorization: Bearer <firebase-id-token>
These endpoints don't need a token:
GET /api/users/registeredPOST /api/mail/send-password-resetPOST /api/mail/send-email-verificationPOST /api/mail/send-sign-in-linkPOST /webhook/stripeGET /api/theme/bundleandGET /api/theme/css
The collections, forms, products, access and usage endpoints also take requests without a token. Those come from a signed-out visitor, and permissions decide what they can reach.
A missing token returns 401 with EMPTY_BEARER_TOKEN everywhere else. An
invalid or revoked token returns 401 with UNABLE_VERIFY_TOKEN.
Errors
Most errors use this shape:
{
"status": false,
"error_key": "RESOURCE_NOT_FOUND",
"message": "...",
"code": 404,
"details": {}
}
Endpoints that answer differently say so below.
When a permission doesn't allow something, a signed-out visitor gets 401 and a
signed-in user gets 403, both with ACCESS_DENIED. Running out of a usage
returns 403 with USAGE_LIMIT_REACHED, or USAGE_UNAVAILABLE outside the
dates it's available, and going past its rate limit returns 429 with
RATE_LIMITED. These include the usage's name in details.usage.
Each client can send up to 100 requests per minute, and 5 per minute to
GET /api/users/registered. Past that, the API returns 429 with
details.error set to RATE_LIMIT_EXCEEDED.
Which Endpoints Your Platform Has
- Users, Access, Usage, Mail, Uploads, and Theme endpoints are always included
- Products and the Stripe webhook are included when your project has Stripe keys and at least one product
- Collections endpoints are included when your project has collections
- Forms endpoints are included when your project has forms
Users
A user has these fields: id, createdAt, updatedAt, uid, email,
isVerified, customerID, requirePlan, and role.
GET /api/users
Get the signed-in user, with their subscription status.
Returns 200 with {"user": {...}}. The user also includes hasSubscription,
subscriptionExpired, planID, planStatus (active, cancelling,
trialing, pastDue, ended, or empty without a plan), and usage: the same
list as GET /api/usage. When the signed-in person has no user
record yet, returns 200 with {"error": "NO_USER_FOUND"}.
POST /api/users/create
Create the user record for the signed-in Firebase user, or return the existing one. No body.
Returns 200 with {"user": {...}}.
POST /api/users/validate
Check that the token is valid. No body. Returns 200 with {}.
GET /api/users/registered
Check whether an email address has an account. No token needed.
| Query parameter | Description |
|---|---|
email | Email address to check |
Returns 200 with {"message": "REGISTERED"}, or 200 with
{"error": "NO_USER"} when there's no account.
DELETE /api/users
Delete the signed-in user's account and their Firebase identity. Returns 200
with {}.
GET /api/users/all
List all users. Admins only.
Returns 200 with {"users": [...]}, or 401 with PERMISSION_DENIED for
other users.
POST /api/users/{id}
Save a user. Admins only. Send the user object in the body.
Returns 200 with {"user": {...}}, or 403 with
{"error": "PERMISSION_DENIED"} for other users.
Products
A product has these fields: ID, productID, maxUsage, limits, name,
description, descriptor, features, priceID, currency, interval,
intervalCount, amount, and active.
GET /api/products/all
List your project's products with their Stripe prices.
Returns 200 with {"products": [...], "stripeProducts": [...]}.
GET /api/products/{id}
Get one product. id is the Stripe product ID.
Returns 200 with {"product": {...}}, or 404 with RESOURCE_NOT_FOUND.
POST /api/products/payment-link
Create a Stripe payment link for a price. After checkout, Stripe sends the user
back to returnURL.
| Body field | Type | Description |
|---|---|---|
priceID | string | Stripe price ID |
returnURL | string | Where to send the user afterwards |
Returns 200 with {"paymentLink": "https://..."}.
Collections
An entity has these fields: id, createdAt, updatedAt, name,
collectionId, ownerId, and properties. ownerId is the user who created
it.
Permissions decide who lists, reads, creates,
updates, and deletes a collection's entities, and which ones: all of them, the
ones the user created, or the ones of their account. An entity outside what the
user can reach returns 404 with RESOURCE_NOT_FOUND. Admins reach every
entity. Deleting a user's account also deletes the entities they own in
collections nobody else can see.
Creating an entity counts toward every usage that counts its collection, and is refused when one of them has no room left.
GET /api/collections/{collectionId}/entities
List a collection's entities, a page at a time.
| Query parameter | Default | Description |
|---|---|---|
page | 1 | Page number |
perPage | 12 | Entities per page |
Returns 200 with
{"entities": [...], "page": 1, "perPage": 12, "totalItems": 0, "totalPages": 0}.
POST /api/collections/{collectionId}/entities/new
Create an entity.
| Body field | Type | Description |
|---|---|---|
name | string | Entity name, 1 to 256 characters |
properties | object | Property values |
The entity goes into the collection in the path and is owned by the signed-in
user. Returns 200 with {"entity": {...}, "usage": [...]}, usage being the
user's status for each usage the entity counted toward.
GET /api/collections/{collectionId}/entities/{entityId}
Get one entity. Returns 200 with {"entity": {...}}, or 404 with
RESOURCE_NOT_FOUND.
POST /api/collections/{collectionId}/entities/{entityId}
Update an entity's name and properties. Returns 200 with
{"entity": {...}}, or 404 with RESOURCE_NOT_FOUND.
DELETE /api/collections/{collectionId}/entities/{entityId}
Delete an entity. Returns 200 with {}, or 404 with RESOURCE_NOT_FOUND.
Forms
POST /api/forms/{form-slug}
Submit a form. Each form has its own endpoint, named after the form: its words
in lowercase, joined with -. A form called "Contact Us" is at
POST /api/forms/contact-us.
The body has one key per field, named after the field's label in camelCase, so
"Email Address" becomes emailAddress. Values depend on the field type:
| Field type | Value |
|---|---|
| Number | number |
| Toggle, checkbox | boolean |
| Address, address with country | {"street", "city", "postalCode", "province", "country"} |
| Phone number | {"number", "extension"} |
| Any other type | string |
Returns 201 with {"submission": {...}}. Returns 400 when a required text
field is empty or doesn't match its pattern. Only people a permission lets
submit the form can.
GET /api/forms/{form-slug}/submissions
List a form's submissions, newest first, for people a permission lets view them.
Returns 200 with {"submissions": [...]}.
Access
GET /api/access
What the caller can do, so an app can hide the rest. Works with or without a token.
Returns 200 with
{"access": {"signedIn", "isAdmin", "open", "collections", "forms", "pages"}}.
collections, forms and pages map each id to its actions, such as
{"view": true, "create": false, "edit": false, "delete": false}. open is
true when the caller can do everything, as an admin or on a platform without
sign-in.
Usage
A usage is a permission's usage, identified by the permission's id. Its status
has id, name, used, allowance and remaining (both null without a
limit), warning, over, resetsAt when it resets, and the topUps a
customer can buy.
GET /api/usage
The signed-in user's status for every usage that applies to them. Returns 200
with {"usage": [...]}.
POST /api/usage/{usageId}/consume
Use some of a usage that counts uses reported by your own code, for the signed-in user. Checking and using happen in one step.
| Body field | Type | Description |
|---|---|---|
amount | number | How many to use, default 1 |
idempotencyKey | string | Optional. A retry with the same key isn't counted |
Returns 200 with {"usage": {...}}, or the refusals listed in
Errors.
POST /api/usage/{usageId}/release, /grant and /reset
Give back, add to, or reset a user's usage. Only your own server calls these,
with the X-Usage-Key header set to the USAGE_API_KEY environment variable of
your platform. A wrong or missing key returns 401 with INVALID_USAGE_KEY.
| Body field | Type | Description |
|---|---|---|
userId | string | The user's uid |
amount | number | How many, for release and grant |
idempotencyKey | string | Optional. A retry with the same key isn't counted |
Returns 200 with {"usage": {...}}.
GET /api/usage/{usageId}/history
The last 100 uses, newest first: the signed-in user's own, or any user's with
?userId= and the X-Usage-Key header. Returns 200 with
{"history": [...]}.
POST /api/usage/{usageId}/top-ups/{index}/checkout
Start buying a top-up for the signed-in user. Returns 200 with
{"url": "https://checkout.stripe.com/..."}. Once paid, the top-up is added to
their allowance.
These endpoints send emails through Resend in the requested language. They don't
need a token. Each needs locale, or it returns 400.
POST /api/mail/send-password-reset
| Body field | Description |
|---|---|
email | Address to send the reset email to |
resetLink | Page of your platform that handles the reset |
locale | Language code of the email, such as en |
Returns 200 with {"message": "Password reset email sent!"}.
POST /api/mail/send-email-verification
| Body field | Description |
|---|---|
email | Address to verify |
verifyLink | Page of your platform that handles verification |
locale | Language code of the email |
Returns 200 with {"message": "Verification email sent!"}.
POST /api/mail/send-sign-in-link
Send a passwordless sign-in link.
| Body field | Description |
|---|---|
email | Address of an existing account |
signInLink | Page of your platform that completes sign-in |
locale | Language code of the email |
Returns 200 with {"message": "Sign-in link sent!"}, or 400 with
EMAIL_NOT_FOUND when the address has no account.
Uploads
POST /api/upload-image
Upload an image as multipart/form-data in the image field. Returns 200
with {"url": "/uploads/..."}.
POST /api/upload-file
Upload a file as multipart/form-data in the file field. Returns 200 with
{"url": "/uploads/..."}.
Theme
GET /api/theme/bundle and GET /api/theme/css
Serve the files of your project's theme when it uses a theme from the
marketplace. Your platform loads them itself. They return 404 when the project
uses the default theme.
Webhooks
POST /webhook/stripe
Receives Stripe events. See Webhooks.
Health
GET /health
In the production build, returns 200 with ok.