Authentication API
Endpoints for user authentication and session management.
POST
/auth/registerRegister a new user and create an organization.
Request Body:
email *User email address
password *Minimum 8 characters
firstName *User first name
lastName *User last name
organizationNameOptional org name
// Request
{
"email": "user@example.com",
"password": "securepassword123",
"firstName": "John",
"lastName": "Doe",
"organizationName": "Acme Inc"
}
// Response (201 Created)
{
"user": {
"id": "usr_abc123",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
},
"organization": {
"id": "org_xyz789",
"name": "Acme Inc",
"slug": "acme-inc"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}POST
/auth/loginAuthenticate with email/password and receive a JWT token.
Request Body:
email *User email address
password *User password
// Request
{
"email": "user@example.com",
"password": "securepassword123"
}
// Response (200 OK)
{
"user": {
"id": "usr_abc123",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}GET
/auth/meGet current user information using the session token.
Required Headers:
Authorization: Bearer <token>
// Response (200 OK)
{
"user": {
"id": "usr_abc123",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe",
"timezone": "America/New_York",
"avatarUrl": "https://..."
},
"organizations": [
{
"id": "org_xyz789",
"name": "Acme Inc",
"slug": "acme-inc",
"role": "owner"
}
]
}Error Responses
| Code | Error | Description |
|---|---|---|
| 400 | VALIDATION_ERROR | Invalid request body |
| 401 | INVALID_CREDENTIALS | Wrong email or password |
| 409 | EMAIL_EXISTS | Email already registered |