# Update an Analysis

## Update an Analysis

> Update (replace) an existing Analysis.\
> \
> This endpoint accepts the same request body fields as the Create an Analysis endpoint.\
> \
> Remember this is a PUT endpoint which means you must provide all supported fields or you may lose data - you are\
> effectively replacing the existing record with a new record containing all the fields you provide.\
> We recommend first getting the existing record and pre-populating the request body with the current values,\
> then change the fields you need to change.\
> \
> If you wish to update a smaller number of fields please use the PATCH endpoint.

```json
{"openapi":"3.1.0","info":{"title":"PredictHQ Beam API","version":"1.0.0"},"tags":[{"name":"Analyses"}],"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":{"PutAnalysisRequest":{"type":"object","properties":{"name":{"description":"Name of an analysis.","type":"string","minLength":1,"title":"Name"},"location":{"description":"The geographic location for the analysis.","$ref":"#/components/schemas/Location"},"demand_type":{"description":"The demand type configuration for the analysis.","$ref":"#/components/schemas/DemandType"},"external_id":{"description":"External identifier associated with the Analysis (optional, user-defined).","type":"string","minLength":1,"title":"External Id"},"label":{"description":"Comma-separated list of labels that can be used to search and filter analyses.","type":"array","items":{"type":"string","minLength":1},"explode":false,"minItems":1,"style":"form","title":"Label"},"rank":{"description":"The rank type and level thresholds for event filtering.","$ref":"#/components/schemas/Rank"}},"additionalProperties":false,"required":["name","location"],"title":"PutAnalysisRequest"},"Location":{"description":"Location of the Analysis.\n\nSupports one of the following location options:\n  - `saved_location_id`\n  - `geopoint` with `radius` and `unit`","type":"object","properties":{"geopoint":{"description":"The latitude and longitude coordinates for the analysis location.","$ref":"#/components/schemas/GeoPoint"},"radius":{"description":"Must be an integer or a float number up to 2 decimal places. It represents the radius of the event search around\nyour `geopoint` to use for time series modelling and correlation. We **strongly recommend** using the\n[Suggested Radius API](https://docs.predicthq.com/api/suggested-radius/get-suggested-radius) to find a\nsuitable radius for your location/industry.","type":"number","exclusiveMinimum":0,"title":"Radius"},"unit":{"description":"The unit for `radius` where\n  - `m` is meters\n  - `km` is kilometers\n  - `ft` is feet\n  - `mi` is miles","type":"string","enum":["m","mi","km","ft"],"title":"Unit"},"saved_location_id":{"description":"The ID of a previously created Saved Location for your analysis as documented at\n[Saved Locations API](https://docs.predicthq.com/api/saved-locations/create-a-saved-location)","type":"string","minLength":1,"title":"Saved Location Id"}},"title":"Location"},"GeoPoint":{"description":"Contains `lat` and `lon` coordinates for your analysis, e.g. if you are creating an analysis for a store in\nSeattle you'd specify the latitude and longitude of your store.","type":"object","properties":{"lat":{"description":"Latitude coordinate as a decimal number between -90 and 90.","type":"string","pattern":"^[-+]?(90(\\.0+)?|([1-8]\\d|[1-9])(\\.\\d+)?|0+\\.(\\d+)?[1-9]+(\\d+)?)$","title":"Lat"},"lon":{"description":"Longitude coordinate as a decimal number between -180 and 180.","type":"string","pattern":"^[-+]?(180(\\.0+)?|(1[0-7]\\d|\\d\\d|[1-9])(\\.\\d+)?|0+\\.(\\d+)?[1-9]+(\\d+)?)$","title":"Lon"}},"required":["lat","lon"],"title":"GeoPoint"},"DemandType":{"description":"Provides information about the demand type of the analysis.","type":"object","properties":{"industry":{"description":"The industry of the demand data being analysed. Determines which event categories and features are used.","$ref":"#/components/schemas/Industry"},"interval":{"description":"The time interval of the demand data. Defaults to `day`.\n\nPossible values: `day`, `week`.","default":"day","$ref":"#/components/schemas/Interval"},"week_start_day":{"description":"The day of the week that demand data starts on. Required when `interval` is `week`.","$ref":"#/components/schemas/Weekday"},"unit_descriptor":{"description":"The description of the unit of demand, which specifies the type or measure being quantified (e.g.,\n\"Occupancy Rate\", \"Sales\", \"Number of Transactions\").","type":"string","default":"Sales","title":"Unit Descriptor"},"currency_code":{"description":"The ISO 4217 currency code for the units of demand. Defaults to `USD`.","default":"USD","$ref":"#/components/schemas/CurrencyCode"},"unit_currency_multiplier":{"description":"The multiplier used to adjust the unit of demand to its equivalent value in the specified currency.","type":"number","default":1,"exclusiveMinimum":0,"title":"Unit Currency Multiplier"}},"title":"DemandType"},"Industry":{"description":"The industry of the demand data being analysed by Beam. Choosing the right `industry` is important as this will\ndetermine the type of features used in the Analysis and will impact the accuracy of the results.","type":"string","default":"other","enum":["accommodation","cpg","tourism","marketing","parking","restaurants","retail","transportation","other"],"title":"Industry"},"Interval":{"type":"string","enum":["day","week"],"title":"Interval"},"Weekday":{"type":"string","enum":["monday","tuesday","wednesday","thursday","friday","saturday","sunday"],"title":"Weekday"},"CurrencyCode":{"description":"The ISO 4217 standard code representing the currency corresponding to the units of demand.","type":"string","default":"USD","enum":["USD","EUR","GBP","AUD","CAD"],"title":"CurrencyCode"},"Rank":{"description":"Specifies which rank type to use when calculating event impacts and anomaly detection.\n\nOptionally, specify the minimum rank level to use when calculating event impacts.\n**We strongly recommend** not setting the rank levels and instead letting Beam define the best rank levels\nbased on your industry.","type":"object","properties":{"type":{"description":"The rank type to use. `phq` uses PHQ Rank (global attendance-based), `local` uses Local Rank (locality-specific).","$ref":"#/components/schemas/RankType"},"levels":{"description":"Minimum and maximum rank thresholds for filtering events. We recommend letting Beam set these automatically.","$ref":"#/components/schemas/RankLevels"}},"required":["type"],"title":"Rank"},"RankType":{"type":"string","enum":["phq","local"],"title":"RankType"},"RankLevels":{"type":"object","properties":{"phq":{"description":"Rank level thresholds for PHQ Rank filtering.","$ref":"#/components/schemas/RankLevel"},"local":{"description":"Rank level thresholds for Local Rank filtering.","$ref":"#/components/schemas/RankLevel"}},"additionalProperties":false,"title":"RankLevels"},"RankLevel":{"type":"object","properties":{"min":{"description":"Minimum rank value (0-100).","type":"integer","maximum":100,"minimum":0,"title":"Min"},"max":{"description":"Maximum rank value (0-100).","type":"integer","maximum":100,"minimum":0,"title":"Max"}},"required":["min"],"title":"RankLevel"},"HTTPError":{"type":"object","properties":{"error":{"description":"A human-readable error message.","type":"string","title":"Error"}},"required":["error"],"title":"HTTPError"},"ValidationError":{"type":"object","properties":{"field":{"description":"The path to the field that failed validation.","type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"title":"Location"},"msg":{"description":"A human-readable validation error message.","type":"string","title":"Message"},"type":{"description":"The type of validation error.","type":"string","title":"Error Type"}},"required":["field","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/beam/analyses/{analysis_id}":{"put":{"operationId":"update_analysis","summary":"Update an Analysis","description":"Update (replace) an existing Analysis.\n\nThis endpoint accepts the same request body fields as the Create an Analysis endpoint.\n\nRemember this is a PUT endpoint which means you must provide all supported fields or you may lose data - you are\neffectively replacing the existing record with a new record containing all the fields you provide.\nWe recommend first getting the existing record and pre-populating the request body with the current values,\nthen change the fields you need to change.\n\nIf you wish to update a smaller number of fields please use the PATCH endpoint.","parameters":[{"name":"analysis_id","in":"path","description":"An existing Beam Analysis ID.","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutAnalysisRequest"}}}},"responses":{"204":{"description":"Successful Response"},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/HTTPError"},{"$ref":"#/components/schemas/ValidationError"}]}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}}},"403":{"description":"Bearer token scope insufficient","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}}},"404":{"description":"Analysis not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}}},"409":{"description":"Data conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}}}},"tags":["Analyses"]}}}}
```

## Examples

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

```bash
curl -X PUT "https://api.predicthq.com/v1/beam/analyses/$ANALYSIS_ID" \
     -H "Accept: application/json" \
     -H "Authorization: Bearer $API_TOKEN" \
     --data @<(cat <<EOF
    {
        "name": "Analysis 2",
        "location": {
        "geopoint": {
            "lat": "-36.849761",
            "lon": "174.7628903"
            },
            "radius": 1.2,
            "unit": "km"
        },
        "rank": {
            "type": "phq"
        }
    }
    EOF
    )
```

{% endtab %}

{% tab title="python" %}

```python
import requests

response = requests.put(
    url="https://api.predicthq.com/v1/beam/analyses/$ANALYSIS_ID",
    headers={
        "Authorization": "Bearer $API_TOKEN",
        "Accept": "application/json"
    },
    json={
        "name": "Analysis 2",
        "location": {
            "geopoint": {
                "lat": "-36.849761",
                "lon": "174.7628903"
            },
            "radius": 1.2,
            "unit": "km"
        },
        "rank": {
            "type": "phq"
        }
    }
)

print(response.status_code)
```

{% endtab %}
{% endtabs %}

## OpenAPI Spec

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

## Guides

Below are some guides relevant to this API:

* [Beam Guides](/getting-started/guides/beam-guides.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.predicthq.com/api/beam/analyses/update-an-analysis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
