Skip to main content

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:

  1. Permission validation (admin/editor)
  2. Verification that the address belongs to the user's company
  3. If isDefault=true:
    • Unsets the current default address
    • Sets this address as the new default
  4. 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

Address successfully updated