Skip to main content
GET
/
api
/
usuarios
/
supabase
/
:id
Get User Role by Supabase ID
curl --request GET \
  --url https://api.example.com/api/usuarios/supabase/:id
{
  "role": "<string>"
}

Overview

This endpoint retrieves the role of a user based on their Supabase authentication ID. It’s typically used during login to determine the user’s access level.
This endpoint does not require authentication. It’s designed to be called during the login process before the user has a valid JWT token.

Path Parameters

id
string
required
The Supabase authentication UUID for the user

Response

role
string
The user’s role in the system. Can be either admin or asistente.

Example Request

cURL
curl -X GET http://localhost:3000/api/usuarios/supabase/a1b2c3d4-e5f6-7890-abcd-ef1234567890
JavaScript
const response = await fetch(
  'http://localhost:3000/api/usuarios/supabase/a1b2c3d4-e5f6-7890-abcd-ef1234567890'
);
const data = await response.json();
console.log(data.role); // 'admin' or 'asistente'

Example Response

200 OK
{
  "role": "admin"
}

Error Responses

{
  "message": "Usuario no registrado en el sistema"
}
The user exists in Supabase Auth but has not been registered in the Medical Center API system yet.
{
  "message": "Error interno"
}
An unexpected error occurred while processing the request.

Use Case

This endpoint is typically called immediately after a successful Supabase authentication to:
  1. Verify the user is registered in the system
  2. Determine their role for client-side routing
  3. Configure appropriate UI permissions
Source: /home/daytona/workspace/source/src/routes/usuarios.routes.js:15

Build docs developers (and LLMs) love