What is a collection?
A collection is a named container for JSON documents — conceptually equivalent to a MongoDB collection or a database table. Every collection you create in the dashboard gets its own REST endpoint at:Flexible mode vs. schema-enforced mode
When you create a collection, you choose whether to define a schema. Flexible mode (no schema): urBackend stores whatever JSON you send. There is no type validation. This is useful for prototyping or for collections where the shape varies between documents. Schema-enforced mode: You define the fields, their types, and any constraints. The API validates every incoming document against the schema before saving. This prevents bad data and enables features like required fields and unique constraints. You can switch between modes and evolve your schema over time from the dashboard.Supported field types
| Type | Description | Example JSON value |
|---|---|---|
String | Text data | "Hello World" |
Number | Integer or decimal | 19.99 |
Boolean | True or false | true |
Date | ISO date string or valid date value | "2024-03-07" |
Object | Nested JSON structure | { "views": 10, "likes": 4 } |
Array | List of values | ["electronics", "deals"] |
Ref | MongoDB ObjectId referencing another document | "642f9abc1234567890abcdef" |
Type matching rules
The schema engine is strict about types:- A
Stringfield must receive a string —"42"is valid,42is not. - A
Numberfield must receive a number — not a stringified number. - A
Booleanfield must receivetrueorfalse, not"true"or1. - An
Objectfield must receive a JSON object{}. - An
Arrayfield must receive a JSON array[]. - A
Reffield should store a valid MongoDB ObjectId string.
400 validation error.
Defining field constraints
Required fields
Mark a field as required in the dashboard to prevent documents from being saved without it. AnyPOST or PUT request missing a required field returns:
Unique constraints
Mark a field as unique to enforce that no two documents in the collection share the same value for that field. This is enforced at the database level and is useful for fields likeusername or email in custom collections.
Field type examples
String
Number
Boolean
Date
Object
Use theObject type for nested structures. In the dashboard, add sub-fields inside the object field. In the API, send a regular nested JSON object:
Array
Ref
UseRef to store a reference to a document in another collection. Store the target document’s _id as a string:
The users collection
Theusers collection has a fixed schema contract required by the auth system:
email— requiredStringpassword— requiredString
name, avatar, or role) on top of this contract. Define the full schema in the dashboard before enabling authentication to ensure your custom fields are validated correctly.
Always interact with user records through
/api/userAuth/* endpoints, not through the data API. The data API blocks all access to /api/data/users*.