Skip to main content

POST /api/userAuth/signup

Creates a new user account and returns an access token. Any extra fields defined in your users collection schema are accepted and validated automatically.
Your project must have a users collection with at least an email (String, required, unique) and a password (String, required) field before this endpoint will work.

Required Header

x-api-key: your pk_live_… key.

Request Body

email
string
required
The user’s email address. Must be unique within the project.
password
string
required
The user’s password. Stored as a bcrypt hash — the raw value is never persisted.
name
string
The user’s display name.
...custom fields
any
Any additional fields your users collection schema defines (e.g., username, avatar, preferences). urBackend validates them against your schema automatically.

Response Fields

success
boolean
true when the user was created successfully.
data
object
message
string
Human-readable status message.

Code Examples

const res = await fetch('https://api.ub.bitbros.in/api/userAuth/signup', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'pk_live_YOUR_KEY'
  },
  body: JSON.stringify({
    email: 'alice@example.com',
    password: 'securePassword123',
    name: 'Alice',
    username: 'alice_dev',
    preferences: { theme: 'dark', notifications: true }
  })
});

const { success, data, message } = await res.json();
const { user, accessToken } = data;

Success Response

{
  "success": true,
  "data": {
    "user": {
      "_id": "64fd1234abcd5678ef901234",
      "email": "alice@example.com",
      "name": "Alice",
      "username": "alice_dev"
    },
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  },
  "message": "User registered successfully"
}

Errors

StatusCause
400 Bad RequestMissing required fields or schema validation failure
409 ConflictAn account with that email address already exists