Skip to main content
GET /api/user-challenges/active Requires authentication.
Authorization
string
required
Bearer token obtained from /api/auth/login or /api/auth/signup. Format: Bearer <token>.
When the user has no active challenge, the endpoint returns null with a 200 OK status — not a 404. Always check whether the response body is null before accessing its fields.

Example

curl --request GET \
  --url http://localhost:3000/api/user-challenges/active \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'

Response

200 OK Returns the active user challenge object joined with its template, or null if no challenge is currently active.
id
number
required
Unique numeric identifier for this user challenge.
user_id
string
required
UUID of the authenticated user.
template_id
number
required
ID of the challenge template this challenge is based on.
status
string
required
Current status. Always ACTIVE for this endpoint.
start_date
string
required
ISO 8601 timestamp of when the challenge was started.
completed_at
string
Always null for active challenges.
notes
string
Progress notes for the challenge. null if none have been added.
created_at
string
required
ISO 8601 timestamp of when the record was created.
updated_at
string
required
ISO 8601 timestamp of the last update to this record.
template
object
required
The challenge template this challenge is based on.
Example response (active challenge)
{
  "id": 14,
  "user_id": "a3f2c1d0-89b4-4e7a-b6f5-1234567890ab",
  "template_id": 3,
  "status": "ACTIVE",
  "start_date": "2026-03-17T09:00:00.000Z",
  "completed_at": null,
  "notes": "Terceiro dia seguido. Sentindo a diferença!",
  "created_at": "2026-03-17T09:00:00.000Z",
  "updated_at": "2026-03-17T09:00:00.000Z",
  "template": {
    "id": 3,
    "title": "Maratona de 30 Dias",
    "description": "Um mês inteiro de dedicação. Complete suas tarefas todos os dias por 30 dias.",
    "duration_days": 30
  }
}
Example response (no active challenge)
null

Errors

StatusDescription
401Missing, invalid, or expired token.

Build docs developers (and LLMs) love