Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ytabeloved/ordervista/llms.txt

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

The Addresses API lets authenticated users manage the delivery addresses stored against their account in the DIRECCIONES table. Addresses are used when placing an online delivery order (id_tipo_pedido = 1) — the id_direccion from this API is passed in the order body. All four endpoints are scoped to the requesting user via req.user.id_usuario, so users can only read and modify their own addresses. No specific role is required — any valid JWT holder (customer, operator, or admin) may call these endpoints.

GET /api/addresses

Returns all active addresses belonging to the authenticated user. Soft-deleted addresses (activo = false) are excluded from the results. Auth required: Yes — any authenticated role

Response

Array of active DIRECCIONES rows for the current user, ordered by default address first.
[].id_direccion
integer
Unique address identifier (primary key of DIRECCIONES).
[].id_usuario
integer
Owner’s user ID — always matches the authenticated caller.
[].direccion
string
Street address (e.g. "Av. Providencia 1234").
[].comuna
string
Municipality / borough (e.g. "Providencia").
[].ciudad
string
City (e.g. "Santiago").
[].referencia
string | null
Landmark or access note to help the delivery driver (e.g. "Portón azul, timbre 3").
[].principal
boolean
true if this is the user’s default delivery address.
[].activo
boolean
Always true — only active addresses are returned.
curl https://ordervista-backend.onrender.com/api/addresses \
  -H "Authorization: Bearer <token>"

Error responses

Statusmensaje
401Unauthorized — missing or invalid token
500"Error al obtener las direcciones."

POST /api/addresses

Creates a new delivery address for the authenticated user. The new address is linked to the caller’s id_usuario automatically — it does not need to be supplied in the body. The address is created with activo = true. Auth required: Yes — any authenticated role

Request body

direccion
string
required
Street name and number (max 255 characters).
comuna
string
required
Municipality or borough (max 100 characters).
ciudad
string
required
City name (max 100 characters).
referencia
string
Optional landmark or access note for the delivery driver (max 255 characters). Defaults to an empty string if omitted.
principal
boolean
Set to true to mark this address as the user’s default. Defaults to false.

Response

mensaje
string
"Dirección creada correctamente."
id_direccion
integer
The newly created address ID.
curl -X POST https://ordervista-backend.onrender.com/api/addresses \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "direccion": "Av. Providencia 1234",
    "comuna": "Providencia",
    "ciudad": "Santiago",
    "referencia": "Portón azul, timbre 3",
    "principal": true
  }'

Error responses

Statusmensaje
401Unauthorized — missing or invalid token
500"Error al crear la dirección."

PUT /api/addresses/:id

Replaces all fields of an existing address belonging to the authenticated user. All writable fields (direccion, comuna, ciudad, referencia, principal) must be supplied — this is a full replacement, not a partial update. Omitted fields will be set to their zero/default values. The address must belong to the calling user — the model scopes the UPDATE by both id_direccion and id_usuario. Auth required: Yes — any authenticated role

Path parameters

id
integer
required
The numeric ID of the address to update.

Request body

direccion
string
required
Street address (max 255 characters).
comuna
string
required
Municipality or borough (max 100 characters).
ciudad
string
required
City name (max 100 characters).
referencia
string
Landmark or access note for the delivery driver (max 255 characters). Defaults to an empty string if omitted.
principal
boolean
Set to true to make this the default address. Defaults to false if omitted.

Response

mensaje
string
"Dirección actualizada correctamente."
curl -X PUT https://ordervista-backend.onrender.com/api/addresses/7 \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "direccion": "Av. Providencia 1234",
    "comuna": "Providencia",
    "ciudad": "Santiago",
    "referencia": "Nuevo código de portero: 4521",
    "principal": true
  }'

Error responses

Statusmensaje
401Unauthorized — missing or invalid token
500"Error al actualizar la dirección."

DELETE /api/addresses/:id

Soft-deletes an address by setting its activo flag to false in DIRECCIONES. The record is retained in the database for referential integrity with historical orders and will no longer appear in GET /api/addresses results. The address must belong to the authenticated user — the model scopes the UPDATE by both id_direccion and id_usuario. Auth required: Yes — any authenticated role

Path parameters

id
integer
required
The numeric ID of the address to delete.

Response

mensaje
string
"Dirección eliminada correctamente."
curl -X DELETE https://ordervista-backend.onrender.com/api/addresses/7 \
  -H "Authorization: Bearer <token>"

Error responses

Statusmensaje
401Unauthorized — missing or invalid token
500"Error al eliminar la dirección."

Build docs developers (and LLMs) love