Skip to content

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

TokenDuraçãoUso
access_token24 horasHeader Authorization: Bearer {token}
refresh_token7 diasRenovar 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

json
{
  "name": "Gabriel Mowses",
  "email": "gabriel@exemplo.com",
  "password": "senhaSegura123!"
}

Response 201

json
{
  "user": {
    "id": "01J8X2K3M4N5P6Q7R8S9T0U1V2",
    "name": "Gabriel Mowses",
    "email": "gabriel@exemplo.com",
    "created_at": "2026-04-18T12:00:00Z"
  },
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Exemplo

bash
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

json
{
  "email": "gabriel@exemplo.com",
  "password": "senhaSegura123!"
}

Response 200

json
{
  "user": {
    "id": "01J8X2K3M4N5P6Q7R8S9T0U1V2",
    "name": "Gabriel Mowses",
    "email": "gabriel@exemplo.com"
  },
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Erros

StatusCódigoMotivo
400VALIDATION_ERRORCampos inválidos
401INVALID_CREDENTIALSE-mail ou senha incorretos

Exemplo

bash
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

json
{
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Response 200

json
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}

Erros

StatusCódigoMotivo
401INVALID_TOKENToken inválido ou malformado
401TOKEN_EXPIREDRefresh 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

json
{
  "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

bash
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:

json
{
  "error": "UNAUTHORIZED",
  "message": "Token ausente ou inválido"
}

Se o token estiver expirado:

json
{
  "error": "TOKEN_EXPIRED",
  "message": "Access token expirado. Use o refresh token para renovar."
}

Feito por CloudFace