Appearance
Autenticação — /v1/auth
já usados no restante da aplicação para códigos de verificação/recuperação.
| Método | Rota | Auth |
|---|---|---|
| POST | /v1/auth/register | Público |
| POST | /v1/auth/login | Público |
| POST | /v1/auth/forgot-password | Público |
| POST | /v1/auth/reset-password | Público |
| POST | /v1/auth/verify-email | Público |
| GET | /v1/auth/me | 🔒 Autenticado |
| POST | /v1/auth/logout | 🔒 Autenticado |
| POST | /v1/auth/refresh | 🔒 Autenticado |
| POST | /v1/auth/send-verification-code | 🔒 Autenticado |
POST /v1/auth/register
Cria um usuário e já retorna um token de acesso (login automático). Dispara um e-mail com um código de verificação de 6 dígitos.
Body
| Campo | Tipo | Obrigatório | Regras |
|---|---|---|---|
name | string | sim | máx. 255 |
email | string | sim | e-mail válido, único em users |
password | string | sim | mín. 8, deve bater com password_confirmation |
password_confirmation | string | sim (implícito por confirmed) | igual a password |
phone | string | não | máx. 20 |
Resposta 201 (chave: data)
json
{
"code": 201,
"success": true,
"data": {
"access_token": "eyJ0eXAi...",
"token_type": "bearer",
"expires_in": 3600,
"user": {
"id": 1,
"name": "...",
"email": "...",
"phone": "...",
"email_verified_at": null
}
},
"message": "Cadastro realizado com sucesso."
}TypeScript
ts
type RegisterBody = {
name: string;
email: string;
password: string;
password_confirmation: string;
phone?: string;
};
type AuthTokenData = {
access_token: string;
token_type: "bearer";
expires_in: number;
user: {
id: number;
name: string;
email: string;
phone: string | null;
email_verified_at: string | null;
};
};
await apiFetch<ApiSuccess<AuthTokenData>>("POST", "/auth/register", {
body: registerBody,
});curl
bash
curl -X POST https://api.fastgivr.com.br/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"name":"Ana","email":"ana@example.com","password":"segredo123","password_confirmation":"segredo123"}'POST /v1/auth/login
Body
| Campo | Tipo | Obrigatório |
|---|---|---|
email | string | sim |
password | string | sim |
Resposta 200 (chave: data) — mesmo formato de register (sem message). Erro 401 se credenciais inválidas: { "success": false, "message": "Credenciais inválidas." }.
TypeScript
ts
type LoginBody = { email: string; password: string };
await apiFetch<ApiSuccess<AuthTokenData>>("POST", "/auth/login", {
body: loginBody,
});curl
bash
curl -X POST https://api.fastgivr.com.br/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"ana@example.com","password":"segredo123"}'GET /v1/auth/me 🔒
Retorna o usuário autenticado com as organizações às quais pertence carregadas (organizations).
Resposta 200 (chave: user)
json
{
"code": 200,
"success": true,
"user": {
"id": 1,
"name": "...",
"email": "...",
"organizations": [
{ "id": 1, "uuid": "...", "name": "...", "status": "ACTIVE" }
]
}
}TypeScript
ts
type MeData = {
id: number;
name: string;
email: string;
organizations: { id: number; uuid: string; name: string; status: string }[];
};
await apiFetch<ApiSuccess<MeData, "user">>("GET", "/auth/me", { token });curl
bash
curl https://api.fastgivr.com.br/v1/auth/me -H "Authorization: Bearer $TOKEN"POST /v1/auth/logout 🔒
Sem body. Invalida o token JWT atual. Resposta 200 só com message.
bash
curl -X POST https://api.fastgivr.com.br/v1/auth/logout -H "Authorization: Bearer $TOKEN"POST /v1/auth/refresh 🔒
Sem body. Envie o token atual em Authorization: Bearer. Retorna um novo token, mesmo formato de login/register (chave: data).
bash
curl -X POST https://api.fastgivr.com.br/v1/auth/refresh -H "Authorization: Bearer $TOKEN"POST /v1/auth/forgot-password
Um código de 6 dígitos é enviado por e-mail . Expira em 1 hora.
Body
| Campo | Tipo | Obrigatório | Regras |
|---|---|---|---|
email | string | sim | precisa existir em users |
Resposta 200: só message.
⚠️ Compartilha o mesmo código de recuperação com o fluxo de
verify-emailabaixo e com os fluxos legados de recuperação de senha. Pedir um novo código em qualquer um desses fluxos invalida um código pendente de outro para o mesmo e-mail — no front, não deixe o usuário disparar "recuperar senha" e "verificar e-mail" em paralelo para o mesmo e-mail.
TypeScript
ts
type ForgotPasswordBody = { email: string };
await apiFetch("POST", "/auth/forgot-password", { body: forgotBody });curl
bash
curl -X POST https://api.fastgivr.com.br/v1/auth/forgot-password \
-H "Content-Type: application/json" \
-d '{"email":"ana@example.com"}'POST /v1/auth/reset-password
Body
| Campo | Tipo | Obrigatório | Regras |
|---|---|---|---|
email | string | sim | precisa existir em users |
code | string | sim | exatamente 6 caracteres |
password | string | sim | mín. 8, confirmed |
password_confirmation | string | sim | igual a password |
Resposta 200: só message. Erro 422 se código inválido/expirado: "Código de recuperação inválido ou expirado.".
TypeScript
ts
type ResetPasswordBody = {
email: string;
code: string;
password: string;
password_confirmation: string;
};
await apiFetch("POST", "/auth/reset-password", { body: resetBody });POST /v1/auth/send-verification-code 🔒
Sem body (usa o e-mail do usuário autenticado). Gera e envia um novo código de 6 dígitos . Resposta 200 só com message.
bash
curl -X POST https://api.fastgivr.com.br/v1/auth/send-verification-code -H "Authorization: Bearer $TOKEN"POST /v1/auth/verify-email
Body
| Campo | Tipo | Obrigatório | Regras |
|---|---|---|---|
email | string | sim | precisa existir em users |
code | string | sim | exatamente 6 caracteres |
Marca o e-mail como verificado e envia um e-mail de confirmação. Resposta 200: só message. Erro 422 se código inválido/expirado: "Código de verificação inválido ou expirado.".
TypeScript
ts
type VerifyEmailBody = { email: string; code: string };
await apiFetch("POST", "/auth/verify-email", { body: verifyBody });