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:

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

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 parameterDescription
emailEmail 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 fieldTypeDescription
priceIDstringStripe price ID
returnURLstringWhere 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 parameterDefaultDescription
page1Page number
perPage12Entities per page

Returns 200 with {"entities": [...], "page": 1, "perPage": 12, "totalItems": 0, "totalPages": 0}.

POST /api/collections/{collectionId}/entities/new

Create an entity.

Body fieldTypeDescription
namestringEntity name, 1 to 256 characters
propertiesobjectProperty 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 typeValue
Numbernumber
Toggle, checkboxboolean
Address, address with country{"street", "city", "postalCode", "province", "country"}
Phone number{"number", "extension"}
Any other typestring

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 fieldTypeDescription
amountnumberHow many to use, default 1
idempotencyKeystringOptional. 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 fieldTypeDescription
userIdstringThe user's uid
amountnumberHow many, for release and grant
idempotencyKeystringOptional. 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.

Mail

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 fieldDescription
emailAddress to send the reset email to
resetLinkPage of your platform that handles the reset
localeLanguage code of the email, such as en

Returns 200 with {"message": "Password reset email sent!"}.

POST /api/mail/send-email-verification

Body fieldDescription
emailAddress to verify
verifyLinkPage of your platform that handles verification
localeLanguage 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 fieldDescription
emailAddress of an existing account
signInLinkPage of your platform that completes sign-in
localeLanguage 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.