Autenticação
O CloudTasks usa autenticação baseada em JWT (JSON Web Tokens). Todo acesso autenticado requer um access_token válido no header Authorization.
Tokens
| Token | Duração | Uso |
|---|---|---|
access_token | 24 horas | Header Authorization: Bearer {token} |
refresh_token | 7 dias | Renovar o access_token |
Quando o access_token expirar, use o refresh_token para obter um novo par de tokens sem precisar fazer login novamente.
POST /api/v1/auth/register
Cria uma nova conta de usuário. Cria automaticamente uma organização e workspace padrão.
Body
{
"name": "Gabriel Mowses",
"email": "gabriel@exemplo.com",
"password": "senhaSegura123!"
}Response 201
{
"user": {
"id": "01J8X2K3M4N5P6Q7R8S9T0U1V2",
"name": "Gabriel Mowses",
"email": "gabriel@exemplo.com",
"created_at": "2026-04-18T12:00:00Z"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Exemplo
curl -X POST https://tasks.cloudface.tech/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "Gabriel Mowses",
"email": "gabriel@exemplo.com",
"password": "senhaSegura123!"
}'POST /api/v1/auth/login
Autentica um usuário existente.
Body
{
"email": "gabriel@exemplo.com",
"password": "senhaSegura123!"
}Response 200
{
"user": {
"id": "01J8X2K3M4N5P6Q7R8S9T0U1V2",
"name": "Gabriel Mowses",
"email": "gabriel@exemplo.com"
},
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Erros
| Status | Código | Motivo |
|---|---|---|
| 400 | VALIDATION_ERROR | Campos inválidos |
| 401 | INVALID_CREDENTIALS | E-mail ou senha incorretos |
Exemplo
curl -X POST https://tasks.cloudface.tech/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "gabriel@exemplo.com",
"password": "senhaSegura123!"
}'POST /api/v1/auth/refresh
Renova o access_token usando um refresh_token válido. O refresh_token atual é invalidado e um novo par é retornado.
Body
{
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Response 200
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}Erros
| Status | Código | Motivo |
|---|---|---|
| 401 | INVALID_TOKEN | Token inválido ou malformado |
| 401 | TOKEN_EXPIRED | Refresh token expirado (faça login novamente) |
GET /api/v1/auth/me
Retorna os dados do usuário autenticado.
Headers
Authorization: Bearer {access_token}Response 200
{
"id": "01J8X2K3M4N5P6Q7R8S9T0U1V2",
"name": "Gabriel Mowses",
"email": "gabriel@exemplo.com",
"avatar_url": null,
"created_at": "2026-04-18T12:00:00Z",
"organizations": [
{
"id": "01J8X2K3M4N5P6Q7R8S9T0U1W3",
"name": "Minha Organização",
"slug": "minha-organizacao",
"role": "owner"
}
]
}Exemplo
curl https://tasks.cloudface.tech/api/v1/auth/me \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."Usando o Authorization header
Todas as rotas protegidas exigem o header:
Authorization: Bearer {access_token}Se o token estiver ausente ou inválido, a API retorna 401 Unauthorized:
{
"error": "UNAUTHORIZED",
"message": "Token ausente ou inválido"
}Se o token estiver expirado:
{
"error": "TOKEN_EXPIRED",
"message": "Access token expirado. Use o refresh token para renovar."
}