Skip to content

Authentication

The Soup API uses Bearer token authentication.

Terminal window
GET /api/v1/auth/setup

Response:

{
"data": {
"is_setup": false
}
}

Only works once, when is_setup is false:

Terminal window
POST /api/v1/auth/setup
Content-Type: application/json
{
"password": "your-secure-password"
}

Response:

{
"data": {
"token": "abc123...",
"user": {
"id": "user_abc123",
"email": "admin@localhost",
"name": "Admin"
}
}
}
Terminal window
POST /api/v1/auth/login
Content-Type: application/json
{
"password": "your-password"
}

Response:

{
"data": {
"token": "abc123...",
"user": {
"id": "user_abc123",
"email": "admin@localhost",
"name": "Admin"
}
}
}

Requires authentication.

Terminal window
POST /api/v1/auth/change-password
Authorization: Bearer <token>
Content-Type: application/json
{
"current_password": "old-password",
"new_password": "new-password"
}

Response: 204 No Content

Terminal window
POST /api/v1/auth/request-code
Content-Type: application/json
{
"email": "user@example.com"
}

Response:

{
"data": {
"message": "Code sent to your email"
}
}
Terminal window
POST /api/v1/auth/verify-code
Content-Type: application/json
{
"email": "user@example.com",
"code": "123456"
}

Response:

{
"data": {
"token": "abc123...",
"user": {
"id": "user_abc123",
"email": "user@example.com",
"name": null
}
}
}

Include the token in the Authorization header:

Terminal window
curl -H "Authorization: Bearer <token>" \
https://api.soup.dev/api/v1/projects
  • Tokens don’t expire by default
  • Tokens are stored as SHA-256 hashes (the raw token is only shown once)
  • Each login creates a new token
  • Old tokens remain valid until explicitly revoked
Terminal window
GET /api/v1/me
Authorization: Bearer <token>

Response:

{
"data": {
"id": "user_abc123",
"email": "user@example.com",
"name": "John Doe"
}
}
{
"error": "invalid token"
}

Status: 401 Unauthorized

{
"error": "unauthorized"
}

Status: 401 Unauthorized