The Addresses API lets authenticated users manage the delivery addresses stored against their account in theDocumentation 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.
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 activeDIRECCIONES rows for the current user, ordered by default address first.
Unique address identifier (primary key of
DIRECCIONES).Owner’s user ID — always matches the authenticated caller.
Street address (e.g.
"Av. Providencia 1234").Municipality / borough (e.g.
"Providencia").City (e.g.
"Santiago").Landmark or access note to help the delivery driver (e.g.
"Portón azul, timbre 3").true if this is the user’s default delivery address.Always
true — only active addresses are returned.Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — 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’sid_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
Street name and number (max 255 characters).
Municipality or borough (max 100 characters).
City name (max 100 characters).
Optional landmark or access note for the delivery driver (max 255 characters). Defaults to an empty string if omitted.
Set to
true to mark this address as the user’s default. Defaults to false.Response
"Dirección creada correctamente."The newly created address ID.
Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — 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
The numeric ID of the address to update.
Request body
Street address (max 255 characters).
Municipality or borough (max 100 characters).
City name (max 100 characters).
Landmark or access note for the delivery driver (max 255 characters). Defaults to an empty string if omitted.
Set to
true to make this the default address. Defaults to false if omitted.Response
"Dirección actualizada correctamente."Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — missing or invalid token |
500 | "Error al actualizar la dirección." |
DELETE /api/addresses/:id
Soft-deletes an address by setting itsactivo 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
The numeric ID of the address to delete.
Response
"Dirección eliminada correctamente."Error responses
| Status | mensaje |
|---|---|
401 | Unauthorized — missing or invalid token |
500 | "Error al eliminar la dirección." |