Skip to main content
GET
/
api
/
clients
/
{id}
Get Client
curl --request GET \
  --url https://api.example.com/api/clients/{id}
{
  "user_id": "<string>",
  "email": "<string>",
  "name": "<string>",
  "surname": "<string>",
  "phone": "<string>",
  "address": "<string>",
  "city": "<string>",
  "country": "<string>",
  "postal_code": "<string>",
  "gender": "<string>",
  "birth_date": "<string>",
  "role": "<string>",
  "status": "<string>",
  "avatar": "<string>",
  "document_type": "<string>",
  "document_number": "<string>",
  "created_at": "<string>",
  "updated_at": "<string>",
  "consents": [
    {
      "consent_id": "<string>",
      "user_id": "<string>",
      "document_url": "<string>",
      "signed_date": "<string>",
      "status": "<string>",
      "notes": "<string>",
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ],
  "questionnaires": [
    {
      "questionnaire_id": "<string>",
      "user_id": "<string>",
      "title": "<string>",
      "data": {},
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ],
  "revokes": [
    {
      "revoke_id": "<string>",
      "user_id": "<string>",
      "reason": "<string>",
      "date_revoked": "<string>",
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ],
  "client_bookings": [
    {
      "booking_id": "<string>",
      "client_id": "<string>",
      "staff_id": "<string>",
      "item_type": "<string>",
      "item_id": "<string>",
      "status": "<string>",
      "booking_date": "<string>",
      "start_time": "<string>",
      "end_time": "<string>",
      "duration": 123,
      "notes": "<string>",
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ],
  "debts": [
    {
      "debt_id": "<string>",
      "user_id": "<string>",
      "cart_id": "<string>",
      "amount": 123,
      "remaining": 123,
      "status": "<string>",
      "due_date": "<string>",
      "notes": "<string>",
      "created_at": "<string>",
      "updated_at": "<string>"
    }
  ]
}

Overview

Fetches complete details for a single client by their user ID. The response includes the client’s profile information along with related data such as consents, questionnaires, revokes, recent bookings, and pending debts.

Authentication

This endpoint requires authentication. Include a valid session token in your request.

Path Parameters

id
string
required
The unique identifier (UUID) of the client to retrieve.

Response

Returns a detailed client object with related records. The password field is excluded from the response for security.
user_id
string
required
Unique identifier for the client (UUID format, max 100 characters)
email
string
required
Client’s email address (max 50 characters)
name
string
required
Client’s first name (max 50 characters)
surname
string
required
Client’s last name (max 50 characters)
phone
string
required
Client’s phone number (max 20 characters)
address
string
required
Street address (max 255 characters)
city
string
required
City name (max 50 characters)
country
string
required
Country name (max 50 characters)
postal_code
string
required
Postal/ZIP code (max 20 characters)
gender
string
required
Gender identifier (max 10 characters)
birth_date
string
required
Date of birth in ISO 8601 date format
role
string
required
User role - always USER for clients (enum: ADMIN, USER)
status
string
required
Account status (enum: ON, OFF)
avatar
string
required
URL to client’s avatar image (max 255 characters)
document_type
string
required
Type of identification document (enum: DNI, PASSPORT, NIE)
document_number
string
required
Identification document number (max 20 characters)
created_at
string
required
Timestamp when the client was created (ISO 8601 format)
updated_at
string
required
Timestamp when the client was last updated (ISO 8601 format)
consents
array
required
Array of consent documents signed by the client
Unique identifier for the consent
user_id
string
Reference to the client’s user_id
document_url
string
URL to the signed consent document (max 255 characters)
signed_date
string
Date when the consent was signed
status
string
Consent status (default: “active”, max 20 characters)
notes
string
Additional notes about the consent
created_at
string
Timestamp when the consent was created
updated_at
string
Timestamp when the consent was last updated
questionnaires
array
required
Array of questionnaires completed by the client
questionnaire_id
string
Unique identifier for the questionnaire
user_id
string
Reference to the client’s user_id
title
string
Title of the questionnaire (max 150 characters)
data
object
JSON object containing the questionnaire form data
created_at
string
Timestamp when the questionnaire was created
updated_at
string
Timestamp when the questionnaire was last updated
revokes
array
required
Array of consent revocations by the client
revoke_id
string
Unique identifier for the revocation
user_id
string
Reference to the client’s user_id
reason
string
Reason for the revocation
date_revoked
string
Date when the consent was revoked
created_at
string
Timestamp when the revocation was created
updated_at
string
Timestamp when the revocation was last updated
client_bookings
array
required
Array of the client’s 5 most recent bookings, ordered by booking date (descending)
booking_id
string
Unique identifier for the booking
client_id
string
Reference to the client’s user_id
staff_id
string
ID of the staff member assigned to the booking
item_type
string
Type of item booked (“service” or “pack”, max 50 characters)
item_id
string
ID of the booked service or pack
status
string
Booking status: “pending”, “confirmed”, “completed”, “cancelled”, or “no_show” (max 20 characters)
booking_date
string
Date of the booking
start_time
string
Start time in HH:mm format (max 10 characters)
end_time
string
End time in HH:mm format (max 10 characters)
duration
number
Duration in minutes
notes
string
Additional notes about the booking
created_at
string
Timestamp when the booking was created
updated_at
string
Timestamp when the booking was last updated
debts
array
required
Array of pending debts for the client
debt_id
string
Unique identifier for the debt
user_id
string
Reference to the client’s user_id
cart_id
string
ID of the associated cart/sale
amount
number
Original debt amount
remaining
number
Remaining amount to be paid
status
string
Debt status: “pending”, “partial”, or “paid” (max 20 characters)
due_date
string
Due date for payment
notes
string
Additional notes about the debt
created_at
string
Timestamp when the debt was created
updated_at
string
Timestamp when the debt was last updated

Example Request

cURL
curl --request GET \
  --url 'https://your-domain.com/api/clients/550e8400-e29b-41d4-a716-446655440000' \
  --header 'Cookie: your-session-token'

Example Response

{
  "user_id": "550e8400-e29b-41d4-a716-446655440000",
  "email": "[email protected]",
  "name": "Maria",
  "surname": "Garcia",
  "phone": "+34612345678",
  "address": "Calle Mayor 123",
  "city": "Madrid",
  "country": "Spain",
  "postal_code": "28013",
  "gender": "female",
  "birth_date": "1990-05-15",
  "role": "USER",
  "status": "ON",
  "avatar": "",
  "document_type": "DNI",
  "document_number": "12345678A",
  "created_at": "2024-01-15T10:30:00.000Z",
  "updated_at": "2024-03-01T14:20:00.000Z",
  "consents": [
    {
      "consent_id": "consent-uuid-1",
      "user_id": "550e8400-e29b-41d4-a716-446655440000",
      "document_url": "https://storage.example.com/consents/doc1.pdf",
      "signed_date": "2024-01-15T10:35:00.000Z",
      "status": "active",
      "notes": null,
      "created_at": "2024-01-15T10:35:00.000Z",
      "updated_at": "2024-01-15T10:35:00.000Z"
    }
  ],
  "questionnaires": [
    {
      "questionnaire_id": "quest-uuid-1",
      "user_id": "550e8400-e29b-41d4-a716-446655440000",
      "title": "Skin Care Assessment",
      "data": {
        "skinType": "combination",
        "allergies": ["none"],
        "previousTreatments": true
      },
      "created_at": "2024-01-15T10:40:00.000Z",
      "updated_at": "2024-01-15T10:40:00.000Z"
    }
  ],
  "revokes": [],
  "client_bookings": [
    {
      "booking_id": "booking-uuid-1",
      "client_id": "550e8400-e29b-41d4-a716-446655440000",
      "staff_id": "staff-uuid-1",
      "item_type": "service",
      "item_id": "service-uuid-1",
      "status": "confirmed",
      "booking_date": "2024-03-10T00:00:00.000Z",
      "start_time": "10:00",
      "end_time": "11:30",
      "duration": 90,
      "notes": "First facial treatment",
      "created_at": "2024-03-03T09:00:00.000Z",
      "updated_at": "2024-03-03T09:00:00.000Z"
    }
  ],
  "debts": [
    {
      "debt_id": "debt-uuid-1",
      "user_id": "550e8400-e29b-41d4-a716-446655440000",
      "cart_id": "cart-uuid-1",
      "amount": 150.00,
      "remaining": 75.00,
      "status": "pending",
      "due_date": "2024-03-15T00:00:00.000Z",
      "notes": "Payment plan: 50% upfront, 50% on completion",
      "created_at": "2024-02-15T11:00:00.000Z",
      "updated_at": "2024-02-20T10:00:00.000Z"
    }
  ]
}

Error Responses

400 Bad Request - Missing ID

{
  "statusCode": 400,
  "statusMessage": "ID requerido"
}

404 Not Found - Client Not Found

Returned when no client exists with the specified ID or when the user is not a client (role is not USER).
{
  "statusCode": 404,
  "statusMessage": "Cliente no encontrado"
}

500 Internal Server Error

{
  "statusCode": 500,
  "statusMessage": "Error al obtener el cliente"
}

Implementation Details

  • The query verifies that the user has role: 'USER' to ensure only clients are returned
  • The password field is always excluded from responses
  • Only the 5 most recent bookings are included, sorted by booking date (descending)
  • Only pending debts (status: 'pending') are included in the response
  • All related data (consents, questionnaires, revokes, bookings, debts) are eagerly loaded
  • Related records use cascade deletion at the database level
  • Consents: Documents signed by the client for data processing and treatments
  • Questionnaires: Health and preference forms completed by the client
  • Revokes: Records of consent withdrawals
  • Bookings: Appointments scheduled by the client (limited to 5 most recent)
  • Debts: Outstanding payment obligations (filtered to pending only)

Source Reference

Implemented in server/api/clients/[id].get.ts

Build docs developers (and LLMs) love