Skip to main content

Register User

Create a new user account with email, password, and name details.

πŸ“ Endpoint

POST /auth/register

πŸ“‹ Request Body

email
string
required
The user’s email address. Must be a valid email format.
password
string
required
The user’s password. Must be at least 8 characters long.
first_name
string
required
The user’s first name.
last_name
string
required
The user’s last name.

πŸ“€ Request Example

curl -X POST https://api.posthoot.com/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "email": "john.doe@example.com",
    "password": "secure_password123",
    "first_name": "John",
    "last_name": "Doe"
  }'
const response = await fetch('https://api.posthoot.com/auth/register', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    email: 'john.doe@example.com',
    password: 'secure_password123',
    first_name: 'John',
    last_name: 'Doe'
  })
});

const data = await response.json();
import requests

response = requests.post(
    'https://api.posthoot.com/auth/register',
    json={
        'email': 'john.doe@example.com',
        'password': 'secure_password123',
        'first_name': 'John',
        'last_name': 'Doe'
    }
)

data = response.json()

πŸ“₯ Response

Success (201 Created)

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": "user_123",
    "email": "john.doe@example.com",
    "first_name": "John",
    "last_name": "Doe",
    "role": "ADMIN",
    "team_id": "team_456",
    "created_at": "2024-01-01T00:00:00Z"
  },
  "team": {
    "id": "team_456",
    "name": "John's Team",
    "created_at": "2024-01-01T00:00:00Z"
  }
}

Error Responses

Email Already Exists (400 Bad Request)

{
  "error": "validation_error",
  "message": "Email already exists",
  "code": "EMAIL_EXISTS"
}

Invalid Email Format (400 Bad Request)

{
  "error": "validation_error",
  "message": "Invalid email format",
  "details": {
    "email": "Invalid email format"
  },
  "code": "VALIDATION_ERROR"
}

Password Too Short (400 Bad Request)

{
  "error": "validation_error",
  "message": "Password must be at least 8 characters",
  "details": {
    "password": "Password must be at least 8 characters"
  },
  "code": "VALIDATION_ERROR"
}

πŸ” What Happens After Registration

  1. Team Creation: A new team is automatically created for the user
  2. Role Assignment: User is assigned the ADMIN role for their team
  3. Default Permissions: User receives default permissions for their role
  4. Token Generation: Access and refresh tokens are generated
  5. Welcome Email: A welcome email is sent to the user

πŸ›‘οΈ Security Features

  • Password Hashing: Passwords are hashed using bcrypt
  • Email Verification: Email format is validated
  • Rate Limiting: Registration is rate-limited to prevent abuse
  • Team Isolation: Each user gets their own team by default

πŸ“‹ Validation Rules

Email

  • Must be a valid email format
  • Must be unique across the system
  • Maximum length: 255 characters

Password

  • Minimum length: 8 characters
  • Should contain a mix of letters, numbers, and symbols
  • Cannot be a common password

Names

  • Minimum length: 2 characters
  • Maximum length: 50 characters
  • Can contain letters, spaces, hyphens, and apostrophes

πŸ”„ Next Steps

After successful registration:
  1. Store tokens securely in your application
  2. Use the access token for API requests
  3. Implement token refresh when the access token expires
  4. Set up team settings in the dashboard