Update specific address
PUT/company/address/:id
Updates an existing address identified by its ID. Allows modification of all fields except the ID.
Update Flow:
- Permission validation (admin/editor)
- Verification that the address belongs to the user's company
- If isDefault=true:
- Unsets the current default address
- Sets this address as the new default
- Data update in the database
Updatable Fields:
- name: New descriptive name
- company_name: Legal company name for the address
- phone: Contact phone number
- addressGoogleMaps: Complete geographical data
- isDefault: Primary address flag
Request Example:
PUT /company/address/507f1f77bcf86cd799439011
{
name: Updated Central Office,
company_name: CargoOffer SL,
phone: +34987654321,
addressGoogleMaps: {
formatted_address: Avenida Principal, 456, 28080 Madrid, Spain,
geometry: {
location: {
lat: 40.456789,
lng: -3.654321
}
}
},
isDefault: true
}
Successful Response Example:
{
_id: 507f1f77bcf86cd799439011,
name: Updated Central Office,
company_name: CargoOffer SL,
phone: +34987654321,
street: Avenida Principal, 456,
city: Madrid,
zipcode: 28080,
country: ES,
location: {
type: Point,
coordinates: [-3.654321, 40.456789]
},
isDefault: true,
can_be_deleted: false
}
Common Error Cases:
- 400: Invalid or incomplete input data
- 401: Invalid or missing JWT token
- 403: User lacks sufficient permissions
- 404: Address not found or does not belong to the company
Important Notes:
- Requires valid JWT authentication
- Changes to addressGoogleMaps trigger reverse geocoding
- Updating isDefault=true affects other addresses
Request
Responses
- 200
- 400
- 401
- 403
- 404
Address successfully updated
Invalid input data
Unauthorized (invalid or missing JWT token)
You do not have permissions for this operation.
Address not found