Guardar contacto
POST /api/parties/set-party
Descripción
Crea o actualiza un contacto y todos sus sub-recursos en una sola operación atómica.
Detalles
* Permite dar de alta o modificar un contacto junto con sus direcciones, vehículos, datos de repartidor, receptores de factura y proveedores en una única transacción. * Si se envía sin identificador y el teléfono ya pertenece a otro contacto, se reutiliza ese contacto existente para evitar duplicados. * Falla si el teléfono enviado pertenece a un contacto distinto al que se está editando. * El teléfono es obligatorio cuando se incluyen sub-recursos de repartidor o proveedor.
Permisos requeridos
auth-tenant
Request
| Nombre | Tipo | Requerido | Reglas |
|---|---|---|---|
| partyId | int | No |
min_value:1
|
| phone | string | No |
max:30
|
| name | string | No |
max:150
|
| notes | string | No | — |
| creditType | string | No |
enum:none,fixed,unlimited
|
| creditLimitCents | int | No |
min_value:0
|
| addresses | array | No | — |
| addresses[].id | int | No |
min_value:1
|
| addresses[].label | string | No |
max:50
|
| addresses[].addressLine | string | No |
max:300
|
| addresses[].addressDetail | string | No |
max:300
|
| addresses[].addressReference | string | No |
max:300
|
| addresses[].city | string | No |
max:100
|
| addresses[].state | string | No |
max:100
|
| addresses[].countryCode | string | No |
max:2
|
| addresses[].postalCode | string | No |
max:20
|
| addresses[].latitude | string | No |
decimal
|
| addresses[].longitude | string | No |
decimal
|
| addresses[].notes | string | No | — |
| addresses[].isDefault | bool | No | — |
| vehicles | array | No | — |
| vehicles[].id | int | No |
min_value:1
|
| vehicles[].name | string | No |
max:200
|
| vehicles[].vehicleType | string | No |
enum:bike,motorcycle,car
|
| vehicles[].licensePlate | string | No |
max:20
|
| vehicles[].vehicleBrand | string | No |
max:50
|
| vehicles[].vehicleColor | string | No |
max:30
|
| vehicles[].notes | string | No | — |
| couriers | array | No | — |
| couriers[].id | int | No |
min_value:1
|
| couriers[].name | string | No |
max:150
|
| couriers[].platform | string | No |
max:50
|
| couriers[].compensationModel | string | No |
enum:keeps_fee,owes_fee,salaried
default:owes_fee
|
| couriers[].courierFeeMode | string | No |
enum:same_as_fee,fixed,percent
default:same_as_fee
|
| couriers[].courierFixedFeeCents | int | No |
min_value:0
|
| couriers[].courierFeeBasisPoints | int | No |
min_value:0
max_value:100000
|
| invoiceRecipients | array | No | — |
| invoiceRecipients[].id | int | No |
min_value:1
|
| invoiceRecipients[].name | string | No |
max:200
|
| invoiceRecipients[].documentTypeId | int | Sí |
min_value:1
|
| invoiceRecipients[].documentNumber | string | No |
max:50
|
| invoiceRecipients[].organizationTypeId | int | No |
min_value:1
|
| invoiceRecipients[].taxRegimeId | int | No |
min_value:1
|
| invoiceRecipients[].fiscalAddress | string | No |
max:300
|
| invoiceRecipients[].email | string | No |
max:150
|
| invoiceRecipients[].municipalityId | int | No |
min_value:1
|
| invoiceRecipients[].isDefault | bool | No | — |
| suppliers | array | No | — |
| suppliers[].id | int | No |
min_value:1
|
| suppliers[].name | string | No |
max:150
|
| suppliers[].supplierCode | string | No |
max:50
|
| suppliers[].paymentTermsDays | int | No |
min_value:0
|
| suppliers[].contactPersonName | string | No |
max:150
|
| suppliers[].contactPersonPhone | string | No |
max:30
|
| suppliers[].notes | string | No | — |
Ejemplo de request
curl -X POST https://restofy.pro/api/parties/set-party \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <accessToken>" \
-H "X-Tenant-Key: <tenantKey>"
Los valores son demo: reemplázalos por datos reales del negocio.
Ejemplo de respuesta
Actualizado: 2026-09-08T16:35:34Z
HTTP 200
Request
{
"name": "Repartidor 181169",
"phone": "***",
"couriers": [
{
"name": "Repartidor 181169",
"platform": "Propio"
}
]
}
Response
{
"success": true,
"message": "Operación realizada correctamente",
"data": {
"party": {
"id": 3,
"phone": "***",
"name": "Repartidor 181169",
"notes": null,
"creditType": "none",
"creditLimitCents": null,
"accountId": null,
"addresses": [],
"vehicles": [],
"couriers": [
{
"id": 2,
"partyId": 3,
"name": "Repartidor 181169",
"platform": "Propio"
}
],
"invoiceRecipients": [],
"suppliers": []
}
}
}