Create a Saved Location

Create a new Saved Location to begin seeing insights.

Create a Saved Location

post
Authorizations
Body
location_codestringOptional

An optional identifier for your location.

The intention here is to use your own identifier for the location if you have one. E.g., you might have stores/hotels/etc in your system with their own ID

  • use that ID here to make it easier to lookup the location later.
namestringOptional

Name of the Saved Location.

E.g. My Location

descriptionstringOptional

Description of the location.

labelsstring[]Optional

A list of labels to help you categorize your locations. You can use these labels to search upon.

E.g.

  {
    "labels": ["label1", "label2"]
  }
place_idsinteger[]Optional

You can define the geolocation of the Saved Location either by GeoJSON or Place IDs.

The Place IDs option is typically used when the location covers an entire city, county, state or country.

Use our Places API to search for the correct Place ID.

formatted_addressstringOptional
Responses
201

Location created successfully

application/json
post
POST /v1/saved-locations HTTP/1.1
Host: api.predicthq.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 235

{
  "location_code": "text",
  "name": "text",
  "description": "text",
  "labels": [
    "text"
  ],
  "geojson": {
    "type": "text",
    "properties": {
      "radius": 1,
      "radius_unit": "m"
    },
    "geometry": {
      "type": "Point",
      "coordinates": []
    }
  },
  "place_ids": [
    1
  ],
  "formatted_address": "text"
}
{
  "location_id": "text"
}

Examples

Create Using Point and Radius

curl --location 'https://api.predicthq.com/v1/saved-locations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
    "name": "Example of creating a saved location",
    "geojson": {
        "type": "Feature",
        "properties": {
            "radius": 2.23,
            "radius_unit": "mi"
        },
        "geometry": {
            "type": "Point",
            "coordinates": [
                -115.1728484,
                36.1147065
            ]
        }
    }
}'

Create Using Place ID

curl --location 'https://api.predicthq.com/v1/saved-locations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer TOKEN' \
--data '{
    "name": "Test with place_id",
    "place_ids": [ 2750405 ]
}'

OpenAPI Spec

The OpenAPI spec for Saved Locations API can be found here.

Guides

Below are some guides relevant to this API:

Last updated

Was this helpful?