Query Locations
List of paths to query for all locations across an application.
Methods and Paths
| Method | URI | Name | Summary | 
|---|---|---|---|
| GET | /v1.0/admin/locations | Retrieve locations for current application | |
| GET | /v1.0/admin/locations/count | Count all locations for current application | |
| GET | /v1.0/admin/locations/{location_id} | Retrieve a single location | |
| POST | /v1.0/admin/locations | Create a location | |
| PUT | /v1.0/admin/locations/{location_id} | Update a location | |
| DELETE | /v1.0/admin/locations/{location_id} | Delete location | |
| PUT | /v1.1/organizations/{organization_id}/applications/{application_id}/locations/{location_id} | Set location parent ID (for sub-locations) | 
Query Parameters
| Name | Source | Type | 
|---|---|---|
| application_id | query | string | 
| limit | query | number | 
| page | query | number | 
| user_id | query | string | 
| external_id | query | string | 
Response Codes
| Code | Status | Description | Has headers | Schema | 
|---|---|---|---|---|
| 200 | OK | Successful company retrieval | schema | |
| 400 | Bad Request | Bad request sent to server | schema | |
| 401 | Unauthorized | You are unauthorized | schema | |
| 403 | Forbidden | You are forbidden to perform this action | schema | 
List Locations
List all locations within your realm
Example Request:
curl --request GET --url https://api.mydevices.com/v1.0/admin/locations \
--header 'authorization: Bearer YourAuthToken' \
--header 'content-type: application/json'
Example Response:
{
  "count": 3,
  "limit": 100,
  "page": 0,
  "rows": [
    {
      "id": 881,
      "name": "neosmart",
      "industry": "[\"Food & Beverage\"]",
      "address": "1 Rocket Rd",
      "city": "Hawthorne",
      "state": "CA",
      "zip": "90250",
      "country": "United States",
      "latitude": 33.9206814,
      "longitude": -118.3280263,
      "timezone": "America/Los_Angeles",
      "user_id": "f8ef7b38-daf7-45a2-a0b2-1d8f1a0e5455",
      "application_id": "neosmart",
      "status": 0,
      "created_at": "2019-04-26T18:16:12.000Z",
      "updated_at": "2019-04-26T18:16:12.000Z"
    },
    {
      "id": 884,
      "name": "NeoSmart",
      "industry": "[\"Food & Beverage\"]",
      "address": "200 I St NE",
      "city": "Miami",
      "state": "OK",
      "zip": "74354",
      "country": "United States",
      "latitude": 36.8795784,
      "longitude": -94.8674195,
      "timezone": "America/Chicago",
      "user_id": "8284bd9b-f00a-4689-b5ed-aed736c5716c",
      "application_id": "neosmart",
      "status": 0,
      "created_at": "2019-04-26T18:37:12.000Z",
      "updated_at": "2019-04-26T18:37:12.000Z"
    }
  ]
}
Create Location
Request:
curl --request POST \
--url https://api.mydevices.com/v1.0/admin/locations \
--header 'authorization: Bearer YourAuthToken' \
--header 'Content-Type: application/json' \
--data \
'
{
    "user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
    "company_id": 464,
    "name": "CreatedLocationAsAdmin02",
    "address": "3900 W Alameda Ave",
    "city": "Burbank",
    "state": "CA",
    "zip": "91505",
    "country": "USA",
    "industry": "[\"IoT\"]",
    "external_id": "myid_location_1"
}'
Example Response:
{
  "id": 448,
  "user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
  "company_id": 464,
  "name": "CreatedLocationAsAdmin02",
  "address": "3900 W Alameda Ave",
  "city": "Burbank",
  "state": "CA",
  "zip": "91505",
  "country": "USA",
  "industry": "[\"IoT\"]",
  "external_id": "myid_location_1",
  "supported_device": "Default",
  "latitude": 34.1526642,
  "longitude": -118.3428161,
  "timezone": "America/Los_Angeles",
  "status": 0,
  "application_id": "iotinabox",
  "updatedAt": "2022-01-06T20:53:03.502Z",
  "createdAt": "2022-01-06T20:53:03.502Z",
  "primary_users": [],
  "authorization": "admin"
}
Update Location
Request:
curl --request PUT \
--url https://api.mydevices.com/v1.0/admin/locations/448 \
--header 'authorization: Bearer YourAuthToken' \
--header 'Content-Type: application/json' \
--data \
'
{
    "user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
    "company_id": 464,
    "name": "UpdatedLocationAsAdmin03"
}'
Example Response:
{
  "id": 448,
  "user_id": "0dfb9c58-5a0b-40eb-9e8c-36c0b1ff883b",
  "company_id": 464,
  "name": "UpdatedLocationAsAdmin03",
  "address": "3900 W Alameda Ave",
  "city": "Burbank",
  "state": "CA",
  "zip": "91505",
  "country": "USA",
  "industry": "[\"IoT\"]",
  "external_id": "myid_location_1",
  "supported_device": "Default",
  "latitude": 34.1526642,
  "longitude": -118.3428161,
  "timezone": "America/Los_Angeles",
  "status": 0,
  "application_id": "iotinabox",
  "updatedAt": "2022-01-06T20:53:03.502Z",
  "createdAt": "2022-01-06T20:53:03.502Z",
  "primary_users": [],
  "authorization": "admin"
}
Delete Location
Request:
info
Note: This request requires user_id to be passed in the body. The user_id can be found in the response of the GET /v1.0/admin/locations or GET /v1.0/admin/locations/_id endpoint.
curl --request DELETE \
--url https://api.mydevices.com/v1.0/admin/locations/448 \
--header 'Authorization: Bearer YourAuthToken' \
--header 'Content-Type: application/json' \
--data '{ "user_id": "USER_ID_FROM_GET_LOCATION"}'
Example Response:
{
  "success": true
}
Query Location by External Id
Request:
curl -- request GET \
-- url https://api.mydevices.com/v1.0/admin/locations?external_id=1234 \
-- header 'Authorization: Bearer YourAuthToken' \
-- header 'Content-Type: application/json'
Set location parent ID
This is used when working with sub-locations, i.e., setting a location as a child of another location.
Request:
curl --request PUT \
--url https://api.mydevices.com/v1.1/organizations/{organization_id}/applications/{application_id}/locations/{location_id}
--header 'authorization: Bearer YourAuthToken'
--data '{"parent_id": "10116"}'
Example Response:
{
  "id": 10127,
  "name": "AlexLocation45_1_2",
  "industry": "[]",
  "company_id": 10829,
  "user_id": "46ece99a-8f08-4050-9d2c-fb5d22bcbc23",
  "application_id": "iotinabox",
  "address": "0",
  "city": "0",
  "state": null,
  "zip": "0",
  "country": "United States",
  "latitude": 37.09024,
  "longitude": -95.712891,
  "timezone": "America/Chicago",
  "status": 0,
  "supported_device": "Default",
  "deleted_at": null,
  "external_id": null,
  "parent_id": 10116,
  "createdAt": "2023-12-05T19:14:03.000Z",
  "updatedAt": "2024-09-05T15:11:57.000Z"
}