Create new address
POST/company/address/
Create a new address associated with the authenticated user's company. This endpoint allows registering physical locations such as warehouses, offices, or loading/unloading points.
Operation Flow:
- Authentication via valid JWT
- Validation of mandatory fields and formats
- Processing of Google Maps data (reverse geocoding)
- If isDefault=true, unmark any existing default address
- Persistence in the database
- Return of the created address with its ID
Important Validations:
- Requires a valid JWT token with admin/editor permissions
- 'name' field is mandatory (3-100 characters)
- Google Maps data must include:
- formatted_address: Complete formatted address
- geometry.location: Coordinates {lat, lng}
- If isDefault=true, unmark any existing default address
Typical Use Cases:
- Register a new company headquarters
- Add a logistics warehouse
- Create a pickup point for shipments
Request Example:
POST /company/address
Authorization: Bearer {token}
Content-Type: application/json
{
name: Logistics Warehouse,
company_name: CargoOffer SL,
phone: +34912345678,
addressGoogleMaps: {
formatted_address: Calle de la Logística, 123, 28045 Madrid, Spain,
geometry: {
location: {
lat: 40.123456,
lng: -3.987654
}
}
},
isDefault: false
}
Successful Response Example:
{
_id: 507f1f77bcf86cd799439011,
name: Logistics Warehouse,
company_name: CargoOffer SL,
phone: +34912345678,
street: Calle de la Logística, 123,
city: Madrid,
zipcode: 28045,
country: ES,
location: {
type: Point,
coordinates: [-3.987654, 40.123456]
},
isDefault: false,
can_be_deleted: true
}
Common Errors:
- 400 Bad Request: Missing or invalid data
- 401
Request
Responses
- 200
- 400
- 401
- 404
Successful operation
Invalid request
Unauthorized
Not found