# Update an Analysis Group

## Update an Analysis Group

> Update (replace) an existing Analysis Group.\
> \
> This endpoint accepts the same request body fields as the Create an Analysis Group endpoint.\
> \
> Remember this is a PUT endpoint which means you must provide all supported fields - 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.

```json
{"openapi":"3.1.0","info":{"title":"PredictHQ Beam API","version":"1.0.0"},"tags":[{"name":"Analysis Groups"}],"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":{"PutAnalysisGroupRequest":{"type":"object","properties":{"name":{"description":"Name of an analysis group.","type":"string","minLength":1,"title":"Name"},"analysis_ids":{"description":"The list of existing analysis IDs to include in the group.\n\nAnalyses can belong to multiple groups. Analyses must have the same demand type (the interval must match \nand, for weekly analyses, week_start_day must also be consistent).\nEvery analysis in the group must have the same industry, if set.","type":"array","items":{"type":"string"},"title":"Analysis Ids"},"demand_type":{"description":"Optional demand type settings for the group. Currently supports unit_descriptor to customize labels.\nIf omitted, settings are derived from the included analyses.","$ref":"#/components/schemas/AnalysisGroupDemandTypeInput"}},"required":["name","analysis_ids"],"title":"PutAnalysisGroupRequest"},"AnalysisGroupDemandTypeInput":{"type":"object","properties":{"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"}},"title":"AnalysisGroupDemandTypeInput"},"HTTPError":{"type":"object","properties":{"error":{"type":"string","title":"Error"}},"required":["error"],"title":"HTTPError"},"ValidationError":{"type":"object","properties":{"field":{"type":"array","items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"required":["field","msg","type"],"title":"ValidationError"}}},"paths":{"/v1/beam/analysis-groups/{group_id}":{"put":{"operationId":"update_analysis_group","summary":"Update an Analysis Group","description":"Update (replace) an existing Analysis Group.\n\nThis endpoint accepts the same request body fields as the Create an Analysis Group endpoint.\n\nRemember this is a PUT endpoint which means you must provide all supported fields - you are effectively replacing \nthe existing record with a new record containing all the fields you provide. We recommend first getting the \nexisting record and pre-populating the request body with the current values, then change the fields you need to \nchange.","parameters":[{"name":"group_id","in":"path","description":"An Analysis Group ID. Analyses that belong to this group will be returned.","required":true,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutAnalysisGroupRequest"}}}},"responses":{"202":{"description":"Successful Response"},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/HTTPError"},{"$ref":"#/components/schemas/ValidationError"}]}}}},"403":{"description":"Bearer token scope insufficient"},"404":{"description":"Analysis Group not found"},"409":{"description":"A data conflict has occurred due to the analysis group being modified elsewhere. Please retry your call later."}},"tags":["Analysis Groups"]}}}}
```

## Examples

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

```bash
curl -X PUT "https://api.predicthq.com/v1/beam/analysis-groups/$GROUP_ID" \
     -H "Accept: application/json" \
     -H "Authorization: Bearer $ACCESS_TOKEN" \
     --data @<(cat <<EOF
    {
        "name": "Analysis Group 2",
        "analysis_ids": [
            "zRa_kk7MlAA",
            "Wfjj1_PCArw"
        ]
    }
    EOF
    )
```

{% endtab %}

{% tab title="python" %}

```python
import requests

response = requests.put(
    url="https://api.predicthq.com/v1/beam/analysis-groups/$GROUP_ID",
    headers={
        "Authorization": "Bearer $ACCESS_TOKEN",
        "Accept": "application/json"
    },
    json={
        "name": "Analysis Group 2",
        "analysis_ids": [
            "zRa_kk7MlAA",
            "Wfjj1_PCArw",
        ],
    }
)

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).


---

# 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/analysis-groups/update-an-analysis-group.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.
