Skip to main content
POST /api/challenge-templates Requires authentication.
Authorization
string
required
Bearer token obtained from /api/auth/login or /api/auth/signup. Format: Bearer <token>.
The API enforces a maximum of 10 challenge templates at a time. Creating a new template when 10 already exist returns a 400 error. Delete an existing template first to free up a slot.

Request body

title
string
required
Display name of the challenge. Must not be empty.
description
string
required
Full description of the challenge goal and instructions.
duration_days
number
required
Number of consecutive days the challenge runs. Must not be empty.

Example

curl --request POST \
  --url http://localhost:3000/api/challenge-templates \
  --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' \
  --header 'Content-Type: application/json' \
  --data '{
    "title": "Desafio de 10 Dias",
    "description": "Dez dias para consolidar um novo hábito e sentir a diferença na sua rotina.",
    "duration_days": 10
  }'

Response

201 Created Returns the newly created challenge template object.
id
number
required
Unique numeric identifier assigned to the new template.
title
string
required
Display name of the challenge.
description
string
required
Full description of the challenge goal and instructions.
duration_days
number
required
Number of consecutive days the challenge runs.
created_at
string
required
ISO 8601 timestamp of when the template was created.
updated_at
string
required
ISO 8601 timestamp of the last update to the template.
Example response
{
  "id": 8,
  "title": "Desafio de 10 Dias",
  "description": "Dez dias para consolidar um novo hábito e sentir a diferença na sua rotina.",
  "duration_days": 10,
  "created_at": "2026-03-17T12:00:00.000Z",
  "updated_at": "2026-03-17T12:00:00.000Z"
}

Errors

StatusDescription
400title or duration_days is missing, or the 10-template limit has been reached.
401Missing, invalid, or expired token.

Build docs developers (and LLMs) love