urBackend provides a simplified RESTful interface for MongoDB. There is no need to write SQL or complex aggregation pipelines—just use simple JSON.
All database endpoints follow the pattern:
https://api.ub.bitbros.in/api/data/:collectionName
Replace :collectionName with the name of your collection (e.g., posts, comments, inventory).
Important
The users collection is managed through /api/userAuth/* endpoints.
Direct users access via /api/data/users* is blocked.
Endpoint: POST /api/data/:collectionName
By default, write operations require your secret key.
If you enable RLS for a collection from the dashboard, publishable-key writes are also allowed but must include a valid user token:
x-api-key: pk_live_...Authorization: Bearer <user_jwt>
Under RLS, writes are permitted only for documents owned by the authenticated user (based on configured ownerField).
If the ownerField is missing in a POST payload, urBackend can auto-fill it from the authenticated user id.
RLS read modes:
public-read lets anyone read, while private restricts reads to the owner's documents and requires a valid user token.
await fetch('https://api.ub.bitbros.in/api/data/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'x-api-key': 'YOUR_KEY' },
body: JSON.stringify({
title: "Why BaaS is the future",
body: "Content goes here...",
tags: ["tech", "development"],
meta: { views: 0, likes: 0 }
})
});Endpoint: GET /api/data/:collectionName
curl "https://api.ub.bitbros.in/api/data/posts" ^
-H "x-api-key: pk_live_xxx"Endpoint: GET /api/data/:collectionName/:id
curl "https://api.ub.bitbros.in/api/data/posts/64fd1234abcd5678ef901234" ^
-H "x-api-key: pk_live_xxx"You can refine your GET requests using the following query parameters:
| Parameter | Type | Example | Description |
|---|---|---|---|
populate |
String |
?populate=author,category |
Expand Ref fields into full objects. |
expand |
String |
?expand=author |
Alias for populate. |
sort |
String |
?sort=createdAt:desc |
Sort results by field and order. |
limit |
Number |
?limit=25 |
Number of documents to return (default: 100, max: 100). |
page |
Number |
?page=2 |
1-indexed page number for pagination. |
If you have fields defined as Ref (singular) or Array of Ref in your schema, urBackend can automatically join those documents for you.
By default, urBackend returns raw IDs for references. Use ?populate= to get the full nested object.
# Get posts with full author and category objects
curl "https://api.ub.bitbros.in/api/data/posts?populate=author,category" ^
-H "x-api-key: pk_live_xxx"Tip
This solves the N+1 query problem, allowing you to fetch complex relational data in a single request.
Endpoint: PUT /api/data/:collectionName/:id
urBackend uses $set logic, meaning you only need to send the fields you want to change.
const postId = "YOUR_DOCUMENT_ID";
await fetch(`https://api.ub.bitbros.in/api/data/posts/${postId}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json', 'x-api-key': 'YOUR_KEY' },
body: JSON.stringify({
"meta.views": 105 // Nested updates are supported!
})
});Endpoint: PATCH /api/data/:collectionName/:id
await fetch(`https://api.ub.bitbros.in/api/data/posts/${postId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json', 'x-api-key': 'YOUR_KEY' },
body: JSON.stringify({
title: "Edited title only"
})
});Endpoint: DELETE /api/data/:collectionName/:id
curl -X DELETE "https://api.ub.bitbros.in/api/data/posts/64fd1234abcd5678ef901234" ^
-H "x-api-key: sk_live_xxx"If you define a schema in the dashboard, urBackend will enforce it for every POST and PUT request.
- Object Support: You can define a field as an
Objectand send nested JSON. - Array Support: Define a field as an
Arrayfor lists of data. - References (Ref): Link documents across collections by storing their
_id.
401 Unauthorized: missing/invalid API key or missing/invalid JWT forpk_livewrites under RLS.403 Forbidden: owner mismatch in RLS write checks.400 Bad Request: schema validation failed (wrong type/missing required field).404 Not Found: collection or document id does not exist.