Skip to main content

Register User

Create a new user account with email and password.

Endpoint

POST /auth/register

Request Body

FieldTypeRequiredDescription
emailstringYesUser’s email address
passwordstringYesPassword (min 8 characters)
namestringNoUser’s display name
{
  "email": "[email protected]",
  "password": "securePassword123",
  "name": "John Doe"
}

Response

{
  "success": true,
  "data": {
    "user": {
      "id": "user_abc123",
      "email": "[email protected]",
      "name": "John Doe",
      "createdAt": "2024-01-15T10:30:00Z"
    },
    "token": "eyJhbGciOiJIUzI1NiIs..."
  }
}

Examples

cURL

curl -X POST https://api.cocobase.buzz/auth/register \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "securePassword123",
    "name": "John Doe"
  }'

JavaScript

const response = await fetch("https://api.cocobase.buzz/auth/register", {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    email: "[email protected]",
    password: "securePassword123",
    name: "John Doe",
  }),
});

const result = await response.json();
const { user, token } = result.data;

Python

import requests

response = requests.post(
    "https://api.cocobase.buzz/auth/register",
    headers={
        "Authorization": "Bearer YOUR_API_KEY",
        "Content-Type": "application/json",
    },
    json={
        "email": "[email protected]",
        "password": "securePassword123",
        "name": "John Doe",
    },
)

result = response.json()
user = result["data"]["user"]
token = result["data"]["token"]

Error Responses

Email Already Exists

{
  "success": false,
  "error": {
    "code": "EMAIL_EXISTS",
    "message": "A user with this email already exists"
  }
}

Invalid Email

{
  "success": false,
  "error": {
    "code": "INVALID_EMAIL",
    "message": "Please provide a valid email address"
  }
}

Weak Password

{
  "success": false,
  "error": {
    "code": "WEAK_PASSWORD",
    "message": "Password must be at least 8 characters"
  }
}