Inventory & Products | Locations | Set Locations

Set Locations

This endpoint creates new stock locations (warehouses) or updates existing ones through https://easycms.fi/public_api/set_locations/.



Endpoint and Method

  • Endpoint: https://easycms.fi/public_api/set_locations/
  • Method: POST
  • Content-Type: application/json



Authentication

  • Header: Authorization1: {API_TOKEN}
  • Body parameters: username, password, account



Request Parameters

Creating a location (omit location_id)

Parameter Type Required Description
username string Yes API username
password string Yes API password
account string Yes Account domain
name string Yes Location name. Must be unique per account
address string No Street address
postal string No Postal code
email string No Contact email
phone string No Contact phone
country_id integer No Country ID (defaults to 40 / Finland)
city_id integer No City ID (defaults to 1)
locationNumber integer No Reference number
parent_id integer No Parent location ID
is_main_warehouse integer No Main warehouse flag (default 0)
visible integer No 1 = visible (default), 0 = hidden

Updating a location (include location_id)

Parameter Type Required Description
username string Yes API username
password string Yes API password
account string Yes Account domain
location_id integer Yes Location ID to update
name string No New name (must stay unique per account)
address, postal, email, phone string No Contact fields
country_id, city_id integer No Reference IDs
locationNumber, parent_id integer No References
is_main_warehouse integer No Main warehouse flag (1/0)
visible integer No 1 = visible, 0 = hidden

Only the fields you provide are updated. cr_location_id is reserved for the cash-register sync and is ignored.



Behavior

  • Unique names: the API rejects duplicate location names (HTTP 409 LOCATION_NAME_ALREADY_EXISTS). The cash-register sync target enforces UNIQUE(name), so a duplicate would break the nightly sync — the same guard the admin UI applies.
  • Default shelf: every newly created location automatically gets a default shelf ("Shelf 1", shelf_number 0) so stock operations can immediately resolve a location+shelf pair. The new shelf_id is returned in the response.
  • Defaults: country_id defaults to 40 (Finland) and city_id to 1 — both columns are required by the database.
  • Every location insert/update writes to the account's activity log automatically.



Response Format

{
    "status": "success",
    "message": "Location created successfully",
    "data": {
        "location_id": 15,
        "default_shelf_id": 124,
        "location": {
            "location_id": "15",
            "name": "Tammisto warehouse",
            "address": "Kartanontie 1",
            "postal": "01300",
            "email": "",
            "phone": "",
            "locationNumber": null,
            "country_id": "40",
            "city_id": "1",
            "parent_id": null,
            "visible": "1",
            "cr_location_id": null,
            "is_main_warehouse": "0"
        }
    },
    "changes": {
        "location_created": {
            "location_id": 15,
            "name": "Tammisto warehouse",
            "default_shelf_id": 124
        }
    }
}

Update responses carry message: "Location updated successfully" and a changes.location object with old/new values per updated field.



Error Responses

HTTP Code Error Code Description
400 MISSING_REQUIRED_FIELDS name missing on create
400 NOTHING_TO_UPDATE No valid location fields provided on update
409 LOCATION_NAME_ALREADY_EXISTS Another location already uses that name
404 LOCATION_NOT_FOUND location_id does not exist
500 CREATE_FAILED / UPDATE_FAILED Database write failed



Call Examples

Create a location

curl -X POST "https://easycms.fi/public_api/set_locations/" \
  -H "Content-Type: application/json" \
  -H "Authorization1: YOUR_API_TOKEN" \
  -d '{
    "username": "your_username",
    "password": "your_password",
    "account": "your_account",
    "name": "Tammisto warehouse",
    "address": "Kartanontie 1",
    "postal": "01300"
  }'

Rename a location

curl -X POST "https://easycms.fi/public_api/set_locations/" \
  -H "Content-Type: application/json" \
  -H "Authorization1: YOUR_API_TOKEN" \
  -d '{
    "username": "your_username",
    "password": "your_password",
    "account": "your_account",
    "location_id": 15,
    "name": "Tammisto main warehouse"
  }'