# Create a Saved Location

## POST /v1/saved-locations

> Create a Saved Location

````json
{"openapi":"3.1.0","info":{"title":"PredictHQ Saved Locations API","version":"1.0.0"},"tags":[{"name":"Saved Locations API"}],"servers":[{"url":"https://api.predicthq.com"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"$API_KEY","description":"Enter your PredictHQ API key. The Bearer prefix is added automatically.\n\nWhen calling the API directly, send: `Authorization: Bearer <YOUR_API_KEY>` as documented at [https://docs.predicthq.com/api/overview/authenticating](https://docs.predicthq.com/api/overview/authenticating)\n"}},"schemas":{"CreateSavedLocationRequest":{"type":"object","properties":{"location_code":{"description":"An optional identifier for your location.\n\n\nThe intention here is to use your own identifier for the location if you have one. \nE.g., you might have stores/hotels/etc in your system with their own ID \n- use that ID here to make it easier to lookup the location later.","type":"string","title":"Location Code"},"name":{"description":"Name of the Saved Location.\n\nE.g. `My Location`","type":"string","title":"Name"},"description":{"description":"Description of the location.","type":"string","title":"Description"},"labels":{"description":"A list of labels to help you categorize your locations.\nYou can use these labels to search upon.\n\n\n**E.g.**\n  ```json\n    {\n      \"labels\": [\"label1\", \"label2\"]\n    }\n  ```","type":"array","items":{"type":"string"},"title":"Labels"},"geojson":{"description":"We recommend omitting this parameter and providing only the `origin_geojson` field instead.\nThis allows PredictHQ to automatically calculate and store a Predicted Impact Area for the location,\nwhich provides a more accurate representation of event impact than a manually specified area.\n\nOnly use `geojson` if you need to define a specific area.\nFor Point geometry types, a radius is required using the `radius` and `radius_unit` properties.\nThe radius must be an integer or a float up to 2 decimal places.\n\nNote: GeoJSON coordinates are ordered longitude then latitude.","$ref":"#/components/schemas/GeoJson-Input"},"place_ids":{"description":"You can define the geolocation of the Saved Location either by GeoJSON or Place IDs.\n\nThe Place IDs option is typically used when the location covers an entire city, county, state or country.\n\nUse our [Places API](https://docs.predicthq.com/api/places/search-places) to search for the correct Place ID.","type":"array","items":{"type":"integer"},"title":"Place Ids"},"formatted_address":{"type":"string","title":"Formatted Address"},"industry":{"description":"The industry of your business. This is used to calculate the Impact Area for your location when you specify\nthe `origin_geojson` field.","$ref":"#/components/schemas/Industry"},"origin_geojson":{"description":"Defines the exact location of your business. This is different from `geojson`,\nwhich defines the area around your business used to scope event searches.\n\nWe recommend providing `origin_geojson` without specifying `geojson` or `place_ids`.\nPredictHQ will automatically calculate a Predicted Impact Area for the location and store it\nin the `geojson` field.\n\nNote: GeoJSON coordinates are ordered longitude then latitude.\nRefer to our [Predicted Impact Area](https://docs.predicthq.com/api/impact-area/get-impact-area)\ndocumentation for more details.","$ref":"#/components/schemas/OriginGeoJson"}},"title":"CreateSavedLocationRequest"},"GeoJson-Input":{"type":"object","properties":{"type":{"type":"string","const":"Feature","title":"Type"},"properties":{"$ref":"#/components/schemas/Properties"},"geometry":{"discriminator":{"propertyName":"type","mapping":{"LineString":"#/components/schemas/LineString","MultiLineString":"#/components/schemas/MultiLineString","MultiPolygon":"#/components/schemas/MultiPolygon","Point":"#/components/schemas/Point","Polygon":"#/components/schemas/Polygon"}},"oneOf":[{"$ref":"#/components/schemas/Point"},{"$ref":"#/components/schemas/Polygon"},{"$ref":"#/components/schemas/MultiPolygon"},{"$ref":"#/components/schemas/LineString"},{"$ref":"#/components/schemas/MultiLineString"}],"title":"Geometry"}},"required":["type","geometry"],"title":"GeoJSON (Input)"},"Properties":{"description":"Custom properties for embedding the radius information","type":"object","properties":{"radius":{"type":"number","title":"Radius"},"radius_unit":{"$ref":"#/components/schemas/RadiusUnit"}},"title":"Properties"},"RadiusUnit":{"description":"The unit of the radius returned. This will be the unit specified in the radius_unit parameter in the call made.","type":"string","enum":["m","km","ft","mi"],"title":"RadiusUnit"},"Point":{"type":"object","properties":{"type":{"type":"string","default":"Point","const":"Point","title":"Type"},"coordinates":{"anyOf":[{"prefixItems":[{"type":"number"},{"type":"number"}],"type":"array","maxItems":2,"minItems":2},{"prefixItems":[{"type":"number"},{"type":"number"},{"type":"number"}],"type":"array","maxItems":3,"minItems":3}],"title":"Coordinates"}},"required":["coordinates"],"title":"Point"},"Polygon":{"type":"object","properties":{"type":{"type":"string","default":"Polygon","const":"Polygon","title":"Type"},"coordinates":{"type":"array","items":{"items":{"anyOf":[{"prefixItems":[{"type":"number"},{"type":"number"}],"type":"array","maxItems":2,"minItems":2},{"prefixItems":[{"type":"number"},{"type":"number"},{"type":"number"}],"type":"array","maxItems":3,"minItems":3}]},"type":"array"},"title":"Coordinates"}},"required":["coordinates"],"title":"Polygon"},"MultiPolygon":{"type":"object","properties":{"type":{"type":"string","default":"MultiPolygon","const":"MultiPolygon","title":"Type"},"coordinates":{"type":"array","items":{"items":{"items":{"anyOf":[{"prefixItems":[{"type":"number"},{"type":"number"}],"type":"array","maxItems":2,"minItems":2},{"prefixItems":[{"type":"number"},{"type":"number"},{"type":"number"}],"type":"array","maxItems":3,"minItems":3}]},"type":"array"},"type":"array"},"title":"Coordinates"}},"required":["coordinates"],"title":"MultiPolygon"},"LineString":{"type":"object","properties":{"type":{"type":"string","default":"LineString","const":"LineString","title":"Type"},"coordinates":{"type":"array","items":{"anyOf":[{"prefixItems":[{"type":"number"},{"type":"number"}],"type":"array","maxItems":2,"minItems":2},{"prefixItems":[{"type":"number"},{"type":"number"},{"type":"number"}],"type":"array","maxItems":3,"minItems":3}]},"title":"Coordinates"}},"required":["coordinates"],"title":"LineString"},"MultiLineString":{"type":"object","properties":{"type":{"type":"string","default":"MultiLineString","const":"MultiLineString","title":"Type"},"coordinates":{"type":"array","items":{"items":{"anyOf":[{"prefixItems":[{"type":"number"},{"type":"number"}],"type":"array","maxItems":2,"minItems":2},{"prefixItems":[{"type":"number"},{"type":"number"},{"type":"number"}],"type":"array","maxItems":3,"minItems":3}]},"type":"array"},"title":"Coordinates"}},"required":["coordinates"],"title":"MultiLineString"},"Industry":{"type":"string","enum":["parking","restaurants","retail","accommodation","cpg","tourism","marketing","transportation","other"],"title":"Industry"},"OriginGeoJson":{"type":"object","properties":{"type":{"type":"string","default":"Feature","const":"Feature","title":"Type"},"geometry":{"$ref":"#/components/schemas/Point"}},"additionalProperties":false,"required":["geometry"],"title":"OriginGeoJson"},"HTTPValidationError":{"type":"object","properties":{"error":{"type":"string"},"details":{"type":"array","items":{"$ref":"#/components/schemas/ValidationError"}}},"title":"HTTPValidationError"},"ValidationError":{"type":"object","properties":{"field":{"type":"string"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"title":"ValidationError"}}},"paths":{"/v1/saved-locations":{"post":{"operationId":"save_location_public_locations_post","summary":"Create a Saved Location","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateSavedLocationRequest"}}}},"responses":{"201":{"description":"Location created successfully","content":{"application/json":{"schema":{"type":"object","properties":{"location_id":{"type":"string"}},"required":["location_id"]}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"tags":["Saved Locations API"]}}}}
````

## Examples

### Create Using Point and Radius

{% tabs %}
{% tab title="curl" %}

```bash
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
            ]
        }
    }
}'
```

{% endtab %}

{% tab title="python" %}

```python
import requests
import json

url = "https://api.predicthq.com/v1/saved-locations"

payload = json.dumps({
  "name": "Example of creating a saved location",
  "geojson": {
    "type": "Feature",
    "properties": {
      "radius": 1,
      "radius_unit": "mi"
    },
    "geometry": {
      "type": "Point",
      "coordinates": [
        -115.1728484,
        36.1147065
      ]
    }
  }
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}
{% endtabs %}

### Create Using Place ID

{% tabs %}
{% tab title="curl" %}

```bash
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 ]
}'
```

{% endtab %}

{% tab title="python" %}

```python
import requests
import json

url = "https://api.predicthq.com/v1/saved-locations"

payload = json.dumps({
  "name": "Example with place_id",
  "place_ids": [
    2750405
  ]
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer TOKEN'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
```

{% endtab %}
{% endtabs %}

## OpenAPI Spec

The OpenAPI spec for Saved Locations API can be [found here](https://api.predicthq.com/docs/?urls.primaryName=Saved+Locations+API).

## Guides

Below are some guides relevant to this API:

* [Working with Location-Based Subscriptions](https://app.gitbook.com/s/tNhzHETmXsrWeVBndqqJ/getting-started/guides/geolocation-guides/searching-by-location/working-with-location-based-subscriptions)
