Location API Retrieve, Create and Update Locations
This guide documents the two Location endpoints:
get_locations export the current list from Microkeeperupsert_locations insert new locations or update existing ones
Retrieving Locations (get_locations)
The get_locations call returns all locations (active and inactive) that belong to the authenticated business.
| Variable | Values & example |
|---|
| mk_action | get_locations |
| mk_data | { "status":"all" } |
Response
| Field | Description |
|---|
| locations | Array of location objects (see below) |
| Field | Description | Example |
|---|
| LID | Microkeeper Location ID | 1234 |
| third_ID | External reference ID | EXT-LOC-A |
| title | Name / label | Brisbane Depot |
| lon | Longitude (string) | 153.025131 |
| lat | Latitude (string) | -27.469770 |
| JID | Default Job ID | 0 |
| manager_eusername | Array of manager usernames | ["alice","bob"] |
| GID | Group ID (visibility in roster UI) | 269 |
| CID | Client ID | 4 |
| hours_goal | Budgeted hours | "100.00" |
| cost_goal | Budgeted labour cost | "10000.00" |
| color | HEX colour used in roster UI | #FF80EA |
| active | "1" (active) or "0" (inactive) | 1 |
| address1 | Street line 1 |
|
| address2 | Street line 2 |
|
| city | City / suburb |
|
| state | State / region |
|
| postcode | Postcode | 4000 |
| country | Country code / name | AU |
{
"success":"1",
"authenticated":"1",
"message":"Location data",
"data":{"locations":[{ rows as above }]}
}
Creating & Updating Locations (upsert_locations)
upsert_locations inserts new locations or updates existing ones.
Any location sent is up-inserted; locations that are not sent remain unchanged.
- Each
locations[] object must include title, active, and either LID (set to 0 to insert) or third_ID. LID = 0 or an unknown third_ID > new location (auto-increment id).- Unknown non-zero
LID aborts the call with "LID x does not exist". manager_eusername is an array.
| Variable | Values & example |
|---|
| mk_action | upsert_locations |
| mk_data | { "config": { "write_list": "all" }, "locations": [ { "LID" : "0", "third_ID" : "EXT-LOC-A", "title" : "Brisbane Depot", "lon" : "153.025131", "lat" : "-27.469770", "manager_eusername": ["alice_long","frank_fulltime","john_smith"], "GID" : "269", "CID" : "4", "hours_goal" : "100.00", "cost_goal" : "10000.00", "color" : "#FF80EA", "active" : "1" }, { "LID" : "1234", "title" : "Melbourne HQ", "active" : "0" } ] } |
mk_data variables
| Name | Type | Notes |
|---|
| config | Object | Contains write_list |
| locations | Array | Locations to upsert |
config object
| Field | Description | Required | Accepted |
|---|
| write_list | Reserved for future use cases; must be "all" | TRUE | all |
locations[] field reference
| Field | Description | Required | Example / format |
|---|
| LID | 0 to insert; existing LID to update. | Conditional | 0 / 1234 |
| third_ID | External ID used for lookup. | Conditional | EXT-LOC-A |
| title | Name / label. | TRUE | Brisbane Depot |
| active | "1" enable "0" disable. | TRUE | "1" |
| lon | Longitude. | FALSE | "153.025131" |
| lat | Latitude. | FALSE | "-27.469770" |
| JID | Default Job ID. | FALSE | 0 |
| manager_eusername | Array of manager usernames. | FALSE | ["alice","bob"] |
| GID | Group ID (visibility). | FALSE | 269 |
| CID | Client ID. | FALSE | 4 |
| hours_goal | Budgeted hours. | FALSE | "100.00" |
| cost_goal | Budgeted labour cost. | FALSE | "10000.00" |
| color | Roster colour (HEX). | FALSE | #FF80EA |
| Optional address block |
| address1 | Street line 1 | FALSE | 1 High St |
| address2 | Street line 2 | FALSE |
|
| city | City / suburb | FALSE | Brisbane |
| state | State / region | FALSE | QLD |
| postcode | Postcode | FALSE | 4000 |
| country | Country code / name | FALSE | AU |
Successful Response
| Field | Description |
|---|
| LID | Array of LIDs inserted or updated. |
{
"success":"1",
"authenticated":"1",
"message":"Locations updated",
"data":{"LID":[1234,1235]}
}