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:
- Unmarks 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 business name for the address
- phone: Contact phone number
- addressGoogleMaps: Complete geographic data
- isDefault: Flag for default address
Example Request:
PUT /company/address/507f1f77bcf86cd799439011
{
name: Updated Headquarters,
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
}
Example Successful Response:
{
_id: 507f1f77bcf86cd799439011,
name: Updated Headquarters,
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: Insufficient user permissions
- 404: Address not found or does not belong to the company
Important Notes:
- Requires valid JWT authentication
- Changes to addressGoogleMaps trigger reverse geocoding
- Phone numbers (phone) must have valid format for Spain, France, or Portugal
**
Request
Responses
- 200
- 400
- 401
- 403
- 404
Address updated successfully
Response Headers
Invalid input data
Response Headers
Unauthorized (invalid or missing JWT token)
Response Headers
NOT_ALLOWED - The address does not belong to this company
Response Headers
Address not found