Skip to main content

Profile Management API

Manage user profiles for both clients and lawyers in upLegal.

Create Profile

Profiles are automatically created during signup, but this endpoint can be used to ensure profile creation or update during edge cases.
Endpoint: POST /api/profiles Authentication: Service role key required (server-side only)

Request Body

userId
string
required
User ID from Supabase Auth
email
string
required
User email address (normalized to lowercase)
role
string
required
User role: client or lawyer
firstName
string
User’s first name
lastName
string
User’s last name
displayName
string
Display name (defaults to firstName + lastName or email prefix)
rut
string
Chilean RUT (for lawyers, must be verified)
pjudVerified
boolean
Whether the lawyer is verified by Poder Judicial

Example Request

{
  "userId": "550e8400-e29b-41d4-a716-446655440000",
  "email": "[email protected]",
  "firstName": "María",
  "lastName": "González",
  "role": "lawyer",
  "rut": "12345678-9",
  "pjudVerified": true
}

Response

success
boolean
Operation success status
profile
object
Created or updated profile data
id
string
Profile ID (same as user_id)
user_id
string
Associated user ID
email
string
User email
first_name
string | null
First name
last_name
string | null
Last name
display_name
string
Display name
role
string
User role (client or lawyer)
rut
string | null
Chilean RUT
pjud_verified
boolean
Poder Judicial verification status
has_used_free_consultation
boolean
Whether user has used their free consultation
created_at
string
ISO 8601 timestamp
updated_at
string
ISO 8601 timestamp

Error Responses

400 - Missing Fields
{
  "error": "Missing required fields: userId, email and role."
}
500 - Database Error
{
  "error": "No se pudo guardar el perfil del usuario."
}

Verify RUT

Endpoint: POST /verify-rut Authentication: Not required (public endpoint) Validates Chilean RUT format and verifier digit.

Request Body

rut
string
required
RUT to validate (format: 12345678-9 or 12.345.678-9)

Example Request

{
  "rut": "12.345.678-9"
}

Response

valid
boolean
Whether the RUT is valid
message
string
Validation result message in Spanish

Example Response

200 - Valid RUT
{
  "valid": true,
  "message": "RUT válido"
}
200 - Invalid RUT
{
  "valid": false,
  "message": "RUT inválido"
}

Verify Lawyer (PJUD)

Endpoint: POST /verify-lawyer Authentication: Not required (public endpoint) Timeout: 15 seconds Verifies a lawyer’s credentials against the Chilean Poder Judicial database and checks for duplicate registrations.

Request Body

rut
string
required
Lawyer’s RUT (format: 12345678-9)
fullName
string
Lawyer’s full name (optional, for additional verification)

Example Request

{
  "rut": "12345678-9",
  "fullName": "María González Pérez"
}

Response - Verified

verified
boolean
Verification status
message
string
Result message in Spanish
details
object
Lawyer information from PJUD
rut
string
Normalized RUT
nombre
string
Lawyer’s full name from PJUD
nombreCompleto
string
Complete name
region
string
Region where the lawyer practices
source
string
Verification source (“Poder Judicial de Chile”)
verifiedAt
string
ISO 8601 verification timestamp

Example Responses

200 - Verified Lawyer
{
  "verified": true,
  "message": "Abogado verificado exitosamente",
  "details": {
    "rut": "123456789",
    "nombre": "María González Pérez",
    "nombreCompleto": "María González Pérez",
    "region": "Metropolitana",
    "source": "Poder Judicial de Chile",
    "verifiedAt": "2026-03-04T10:30:00.000Z"
  }
}
200 - Not Found
{
  "verified": false,
  "message": "No se encontró el abogado en los registros del Poder Judicial",
  "details": {
    "rut": "123456789",
    "nombre": "No proporcionado",
    "reason": "No se encontró en los registros del Poder Judicial"
  }
}
200 - Suspended Lawyer
{
  "verified": false,
  "message": "El abogado se encuentra suspendido (Sanción Ejecutoriada Permanente). No es posible registrarse.",
  "details": {
    "rut": "123456789",
    "nombre": "Juan Pérez",
    "reason": "Abogado suspendido indefinidamente",
    "suspensionType": "Permanente",
    "suspensionDate": "30-12-9999"
  }
}
200 - Duplicate RUT
{
  "verified": false,
  "message": "El RUT 12.345.678-9 ya está registrado por María González en nuestra plataforma.",
  "details": {
    "rut": "123456789",
    "formattedRut": "12.345.678-9",
    "registeredBy": "María González",
    "reason": "RUT duplicado"
  }
}
400 - Invalid Format
{
  "verified": false,
  "message": "Formato de RUT inválido. Use el formato 12345678-9"
}
408 - Timeout
{
  "verified": false,
  "message": "La verificación tardó demasiado. Por favor, inténtalo de nuevo.",
  "error": "timeout"
}

Profile Fields

Client Profile Fields

  • user_id: User ID (UUID)
  • email: Email address
  • first_name: First name
  • last_name: Last name
  • display_name: Display name
  • avatar_url: Profile picture URL
  • phone: Phone number
  • has_used_free_consultation: Free consultation usage flag
  • created_at: Account creation timestamp
  • updated_at: Last update timestamp

Lawyer Profile Fields

All client fields plus:
  • rut: Chilean RUT (required for lawyers)
  • pjud_verified: PJUD verification status
  • specialties: Array of legal specialties
  • bio: Professional bio
  • experience_years: Years of experience
  • hourly_rate_clp: Hourly rate in CLP
  • contact_fee_clp: Contact/consultation fee
  • bar_number: Bar association number
  • university: Law school
  • study_start_year: Year started law school
  • study_end_year: Year completed law school
  • education: Education details (JSON)
  • certifications: Certifications (JSON)
  • languages: Spoken languages array
  • location: Practice location
  • rating: Average rating (0-5)
  • review_count: Number of reviews
  • verified: Platform verification status
  • available_for_hire: Availability flag

RLS Policies

Profiles Table

  • SELECT: Public read access for basic profile info
  • INSERT: Service role only (handled during signup)
  • UPDATE: Users can update their own profile
  • DELETE: Admin only (via service role)

Build docs developers (and LLMs) love