Skip to main content
GET
/
api
/
usuarios
/
:id
Get User by ID
curl --request GET \
  --url https://api.example.com/api/usuarios/:id
{
  "id": "<string>",
  "persona_id": 123,
  "role": "<string>",
  "created_at": "<string>",
  "persona": {
    "id": 123,
    "nombres": "<string>",
    "apellidos": "<string>",
    "telefono": "<string>",
    "dni": "<string>",
    "foto_url": "<string>"
  }
}

Overview

Returns detailed information about a specific user, including their associated person data.
Admin OnlyThis endpoint requires authentication and the admin role.

Path Parameters

id
string
required
The Supabase authentication UUID of the user

Response

id
string
The Supabase authentication UUID
persona_id
number
ID of the associated person record (nullable)
role
string
User’s role: admin or asistente
created_at
string
Timestamp when the user was created
persona
object
Associated person data (nullable)

Example Request

cURL
curl -X GET http://localhost:3000/api/usuarios/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"
JavaScript
const response = await fetch(
  'http://localhost:3000/api/usuarios/a1b2c3d4-e5f6-7890-abcd-ef1234567890',
  {
    headers: {
      'Authorization': `Bearer ${adminToken}`
    }
  }
);
const user = await response.json();

Example Response

200 OK
{
  "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "persona_id": 3,
  "role": "admin",
  "created_at": "2024-02-15T14:20:00.000Z",
  "persona": {
    "id": 3,
    "nombres": "Carlos",
    "apellidos": "Rodríguez",
    "telefono": "+9876543210",
    "dni": "87654321",
    "foto_url": null,
    "created_at": "2024-02-15T14:15:00.000Z"
  }
}

Error Responses

{
  "message": "Usuario no encontrado"
}
Source: /home/daytona/workspace/source/src/routes/usuarios.routes.js:143

Build docs developers (and LLMs) love