Skip to main content
POST
/
auth
/
register
Register
curl --request POST \
  --url https://api.example.com/auth/register \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "email": "<string>",
  "password": "<string>"
}
'
{
  "access_token": "<string>",
  "token_type": "<string>",
  "user": {
    "id": 123,
    "name": "<string>",
    "email": "<string>"
  }
}
Register a new user account and receive an access token for immediate authentication.

Endpoint

POST /auth/register

Request Body

name
string
required
The user’s full name. Must be between 1 and 100 characters.Example: "John Doe"
email
string
required
The user’s email address. Must be a valid email format and unique. Maximum 255 characters.Example: "[email protected]"
password
string
required
The user’s password. Must meet the following requirements:
  • At least 8 characters long
  • Contains at least one uppercase letter
  • Contains at least one lowercase letter
  • Contains at least one number
Example: "SecurePass123"

Response

access_token
string
JWT access token for authentication. Include this in the Authorization header for subsequent requests.Example: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huLmRvZUBleGFtcGxlLmNvbSIsImV4cCI6MTcwOTU1MTIwMH0.abc123"
token_type
string
The type of token. Always returns "bearer".
user
object
The created user object.

Example Request

cURL
curl -X POST "https://api.smarteat.ai/auth/register" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "[email protected]",
    "password": "SecurePass123"
  }'
JavaScript
const response = await fetch('https://api.smarteat.ai/auth/register', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'John Doe',
    email: '[email protected]',
    password: 'SecurePass123'
  })
});

const data = await response.json();
console.log(data.access_token);
Python
import requests

response = requests.post(
    'https://api.smarteat.ai/auth/register',
    json={
        'name': 'John Doe',
        'email': '[email protected]',
        'password': 'SecurePass123'
    }
)

data = response.json()
print(data['access_token'])

Example Response

201 Created
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJqb2huLmRvZUBleGFtcGxlLmNvbSIsImV4cCI6MTcwOTU1MTIwMH0.abc123def456",
  "token_type": "bearer",
  "user": {
    "id": 1,
    "name": "John Doe",
    "email": "[email protected]"
  }
}

Error Responses

400 Bad Request - Email Already Registered
{
  "detail": "Email already registered"
}
422 Unprocessable Entity - Invalid Password
{
  "detail": [
    {
      "type": "value_error",
      "loc": ["body", "password"],
      "msg": "Value error, Password must be at least 8 characters long",
      "input": "short"
    }
  ]
}
422 Unprocessable Entity - Password Missing Uppercase
{
  "detail": [
    {
      "type": "value_error",
      "loc": ["body", "password"],
      "msg": "Value error, Password must contain at least one uppercase letter",
      "input": "lowercase123"
    }
  ]
}
422 Unprocessable Entity - Password Missing Number
{
  "detail": [
    {
      "type": "value_error",
      "loc": ["body", "password"],
      "msg": "Value error, Password must contain at least one number",
      "input": "PasswordOnly"
    }
  ]
}
422 Unprocessable Entity - Invalid Email
{
  "detail": [
    {
      "type": "value_error",
      "loc": ["body", "email"],
      "msg": "value is not a valid email address",
      "input": "not-an-email"
    }
  ]
}
500 Internal Server Error
{
  "detail": "Error creating user"
}

Password Requirements

Passwords must meet all of the following requirements:
  • Minimum 8 characters
  • At least one uppercase letter (A-Z)
  • At least one lowercase letter (a-z)
  • At least one number (0-9)

Notes

  • Email addresses are automatically converted to lowercase and trimmed
  • Each email can only be registered once
  • Upon successful registration, the user is automatically logged in (access token is returned)
  • The password is securely hashed using bcrypt before storage
  • Store the returned access token securely for subsequent API requests

Build docs developers (and LLMs) love