Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/despacho-backend/llms.txt

Use this file to discover all available pages before exploring further.

This endpoint registers a new lawyer account in the Despacho system. It accepts an email address and a plaintext password, validates that both fields are present and that the email is not already in use, then hashes the password with bcrypt (10 salt rounds) before persisting the record. Every account created through this endpoint is automatically assigned the Admin role (value: "1"). On success the full Mongoose document — including the auto-generated _id, timestamps, and role array — is returned in the response body.
POST /api/lawyer/user/create
Authentication: None — this is a public endpoint.

Request Body

email
string
required
The lawyer’s email address. Stored in the database as lowercase regardless of the casing supplied in the request. Must be unique across all lawyer accounts.
password
string
required
The account password in plaintext. Hashed with bcrypt (10 salt rounds) before being written to the database — the raw password is never persisted.

Example Request

curl -X POST http://localhost:3000/api/lawyer/user/create \
  -H "Content-Type: application/json" \
  -d '{"email": "abogado@despacho.com", "password": "SecurePass123"}'

Responses

200 — Account Created

The account was created successfully. The full user document is returned under new_user.
{
  "msj": "Cuenta creada correctamente",
  "status": true,
  "new_user": {
    "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
    "email": "abogado@despacho.com",
    "password": "$2b$10$hashed...",
    "role": [{ "name": "Admin", "value": "1" }],
    "token": "",
    "createdAt": "2024-01-15T10:30:00.000Z",
    "updatedAt": "2024-01-15T10:30:00.000Z",
    "__v": 0
  }
}
msj
string
Human-readable confirmation message. Value: "Cuenta creada correctamente".
status
boolean
true when the request succeeded.
new_user
object
The newly created LawyerUser document returned directly from MongoDB.

203 — Email Already Registered

A lawyer account with the supplied email already exists. No new record is created.
{
  "msj": "Este correo ya se encuentra registrado. Por favor intenta con uno diferente",
  "status": false
}

403 — Missing Required Fields

Either email or password (or both) were absent from the request body.
{
  "msj": "Completa todos los campos para continuar",
  "status": false
}

500 — Internal Server Error

An unexpected error occurred — typically a database connection failure or a Mongoose validation error. The raw error object is returned in the response body.
{
  "name": "MongoServerError",
  "message": "..."
}

Error Handling

HTTP StatusCauseHow to resolve
203The email address is already associated with an existing accountUse a different email address or direct the user to the login endpoint
403One or both required body fields (email, password) are missingEnsure both fields are included and non-empty in the request body
500Unexpected server-side or database errorCheck server logs; retry after confirming the database connection is healthy

The role field is set automatically on every new account — it cannot be overridden through this endpoint. All accounts start with the Admin role ({ "name": "Admin", "value": "1" }). A separate SuperAdmin role (value: "2") exists in the system and must be assigned through a privileged operation.

Build docs developers (and LLMs) love