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 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.
System-managed fields
urBackend adds theisDeleted (Boolean, default false) and deletedAt (Date, default null) fields to every collection to manage soft deletes. The system strictly manages these fields so you cannot set, modify, or filter by them directly from the client.
Documents with
isDeleted: true are excluded from normal read queries by default. To view them, you must use the include_deleted=true query parameter.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.
Default values
Set a default on any non-requiredString, Number, or Boolean field. When a document is inserted without that field, urBackend stores the default value instead of leaving it unset.
Defaults are available in both the manual collection builder and the AI Collection Creator. In the manual builder, the Default column appears next to each field row and accepts a value that matches the field’s type. In the AI Collection Creator, defaults are proposed automatically for optional fields where they make sense.
Rules:
- Defaults are only supported on
String,Number, andBooleanfields.Date,Ref,Array, andObjectfields cannot have defaults. - Defaults are only allowed on non-required fields. Marking a field as required clears any default that was set.
- The default value’s type must match the field type — a
Numberfield cannot default to a string.
Collections must have at least one field
A collection must be created with at least one field. Requests to create or edit a collection with an empty schema are rejected with400:
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*.