Skip to main content
POST
/
auth
/
create-admin
Create Admin
curl --request POST \
  --url https://api.example.com/auth/create-admin \
  --header 'Content-Type: application/json' \
  --data '
{
  "email": "<string>",
  "password": "<string>"
}
'
{
  "message": "<string>",
  "user": {
    "id": "<string>",
    "email": "<string>",
    "role": "<string>"
  }
}
Creates a new user account with the ‘admin’ role. This endpoint requires admin authentication.
This endpoint requires admin privileges. Only authenticated users with the ‘admin’ role can create admin accounts.

Authentication

This endpoint requires a valid JWT access token with admin role.
Authorization: Bearer {access_token}

Request Body

email
string
required
Admin user’s email address. Must be a valid email format.
password
string
required
Admin user’s password. Must be at least 6 characters long.

Response

message
string
Success message indicating admin user creation status.
user
object
The created admin user object.

Example

curl -X POST https://api.yourapp.com/auth/create-admin \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
  -d '{
    "email": "[email protected]",
    "password": "securepassword123"
  }'

Response Examples

{
  "message": "Admin user created successfully",
  "user": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "email": "[email protected]",
    "role": "admin"
  }
}

Notes

  • This endpoint requires admin authentication. Only users with the ‘admin’ role can access this endpoint.
  • The admin user’s email is automatically confirmed upon creation.
  • All users created through this endpoint are assigned the ‘admin’ role.
  • The password must meet minimum security requirements (at least 6 characters).
  • Duplicate email addresses are not allowed.
  • Missing or invalid authorization tokens will result in a 401 Unauthorized response.
  • Valid tokens without admin role will result in a 403 Forbidden response.

Build docs developers (and LLMs) love