Skip to main content

Base URL

All API requests are made to:
https://api.ub.bitbros.in

Authentication

Every request must include an x-api-key header. urBackend issues two keys per project with different trust levels:
Key prefixWhere to useWrite access
pk_live_…Frontend / mobile clientsReads only — writes require RLS + Bearer token
sk_live_…Server-side only (never expose in client code)Full read/write access
Never expose your sk_live key in frontend or mobile code. Anyone who obtains it has unrestricted write access to your project data.

Common Headers

HeaderRequiredPurpose
x-api-keyYesYour project API key (pk_live_… or sk_live_…)
Authorization: Bearer <jwt>Required for pk_live writes with RLS enabledEnd-user identity for owner-based write checks
x-refresh-tokenMobile/non-browser refresh onlyProvide refresh token when cookies are not available
x-refresh-token-mode: headerPaired with x-refresh-tokenSignals that the refresh token is in a header, not a cookie
Content-Type: application/jsonRequired for all JSON request bodiesBody parsing and validation

Response Format

Every endpoint returns the same envelope:
{
  "success": true,
  "data": {},
  "message": "Human-readable status message"
}
On error, success is false and data is omitted or empty. The message field describes what went wrong.

Endpoint Quick Reference

AreaMethodEndpointDescription
AuthPOST/api/userAuth/signupRegister a new user
AuthPOST/api/userAuth/loginLog in and get a JWT access token
AuthPOST/api/userAuth/refresh-tokenRotate refresh token and issue a new access token
AuthPOST/api/userAuth/logoutRevoke the current refresh session
AuthGET/api/userAuth/meGet the current user’s profile
AuthGET/api/userAuth/public/:usernameGet a public-safe profile by username
AuthGET/api/userAuth/social/:provider/startStart GitHub or Google OAuth flow
AuthPOST/api/userAuth/social/exchangeExchange callback rtCode for a refresh token
AuthPOST/api/userAuth/verify-emailVerify a user’s email with OTP
AuthPOST/api/userAuth/request-password-resetRequest a password reset OTP
AuthPOST/api/userAuth/reset-passwordReset password using OTP
AuthPUT/api/userAuth/update-profileUpdate the current user’s profile
AuthPUT/api/userAuth/change-passwordChange the current user’s password
DataGET/api/data/:collectionNameList all documents in a collection
DataGET/api/data/:collectionName/:idGet a single document by ID
DataPOST/api/data/:collectionNameInsert a new document
DataPUT/api/data/:collectionName/:idFull update of a document by ID
DataPATCH/api/data/:collectionName/:idPartial update of a document by ID
DataDELETE/api/data/:collectionName/:idDelete a document by ID
StoragePOST/api/storage/uploadUpload a file and receive a public CDN URL
StorageDELETE/api/storage/fileDelete a file by its stored path

Status Codes

CodeMeaning
200 OKRequest succeeded
201 CreatedDocument, user, or file created successfully
400 Bad RequestValidation failure or malformed JSON
401 UnauthorizedMissing or invalid API key, or expired JWT
403 ForbiddenResource quota exceeded, RLS policy violation, or owner mismatch
404 Not FoundCollection, document, or file does not exist
413 Payload Too LargeUploaded file exceeds the size limit
500 Server ErrorUnexpected problem on our end

Write Access Matrix

Use this table to determine which key and token combination you need for write operations on non-users collections:
KeyUser TokenRLS EnabledOutcome
pk_liveNoAnyWrite blocked
pk_liveYesNoWrite blocked
pk_liveYesYesAllowed — owner-constrained writes only
sk_liveNot requiredAnyAllowed — server-trusted context
The users collection is managed exclusively through /api/userAuth/*. Direct access via /api/data/users* is blocked for all keys.