Skip to main content

POST /api/register

Creates a new user account in Filebright. Upon successful registration, returns an authentication token that can be used for subsequent API requests.
This endpoint does not require authentication. The returned token should be stored securely and included in the Authorization header for protected endpoints.

Request body

name
string
required
Full name of the user. Must be 2-70 characters and contain only letters, spaces, hyphens, and apostrophes.Validation rules:
  • Minimum length: 2 characters
  • Maximum length: 70 characters
  • Pattern: Only letters, spaces, hyphens, and apostrophes allowed
email
string
required
Email address for the account. Must be a valid email format and unique in the system.Validation rules:
  • Must be a valid email format
  • Maximum length: 255 characters
  • Must be unique (not already registered)
password
string
required
Password for the account. Must meet security requirements.Validation rules:
  • Minimum length: 8 characters
  • Maximum length: 128 characters
  • Must contain at least one letter
  • Must contain at least one number
  • Must contain at least one symbol
password_confirmation
string
required
Password confirmation. Must match the password field exactly.

Response

token
string
Authentication token for the newly created user. Use this token in the Authorization header as Bearer {token} for authenticated requests.
token_type
string
The type of token issued. Always returns “Bearer”.
user
object
The newly created user object.
user.id
integer
Unique identifier for the user.
user.name
string
Full name of the user.
user.email
string
Email address of the user.
user.created_at
string
Timestamp when the user account was created (ISO 8601 format).
user.updated_at
string
Timestamp when the user account was last updated (ISO 8601 format).

Error responses

422 Unprocessable Entity - Validation errors occurred. Common causes:
  • Email already registered
  • Password doesn’t meet security requirements
  • Password confirmation doesn’t match
  • Name contains invalid characters
  • Required fields are missing

Example request

curl -X POST https://api.filebright.com/api/register \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "[email protected]",
    "password": "SecurePass123!",
    "password_confirmation": "SecurePass123!"
  }'

Example response

201 Created
{
  "token": "1|AbCdEfGhIjKlMnOpQrStUvWxYz1234567890",
  "token_type": "Bearer",
  "user": {
    "id": 42,
    "name": "John Doe",
    "email": "[email protected]",
    "created_at": "2024-03-15T10:30:00.000000Z",
    "updated_at": "2024-03-15T10:30:00.000000Z"
  }
}
422 Unprocessable Entity
{
  "message": "The email has already been taken.",
  "errors": {
    "email": [
      "The email has already been taken."
    ]
  }
}

Build docs developers (and LLMs) love