> For the complete documentation index, see [llms.txt](https://docs.predicthq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.predicthq.com/api/beam/analysis-groups/create-an-analysis-group.md).

# Create an Analysis Group

Creating an Analysis Group allows to aggregate Feature Importance for a number of Analyses

## Create an Analysis Group

> Creating an Analysis Group allows to aggregate Feature Importance for a number of Analyses

```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","maxLength":256,"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","maxLength":256},"maxItems":1200,"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","maxLength":256,"title":"Unit Descriptor"}},"title":"AnalysisGroupDemandTypeInput"},"AnalysisGroupIdResponse":{"type":"object","properties":{"group_id":{"description":"The autogenerated identifier for the analysis group.","type":"string","title":"Group Id"}},"title":"AnalysisGroupIdResponse"},"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"},"HTTPError":{"type":"object","properties":{"error":{"description":"A human-readable error message.","type":"string","title":"Error"}},"required":["error"],"title":"HTTPError"}}},"paths":{"/v1/beam/analysis-groups":{"post":{"operationId":"create_analysis_group","summary":"Create an Analysis Group","description":"Creating an Analysis Group allows to aggregate Feature Importance for a number of Analyses","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PutAnalysisGroupRequest"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalysisGroupIdResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ValidationError"},{"$ref":"#/components/schemas/HTTPError"}]}}}},"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"}}}}},"tags":["Analysis Groups"]}}}}
```

## Examples

Create an Analysis Group with curl or Python:

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

```bash
curl -X POST "https://api.predicthq.com/v1/beam/analysis-groups" \
     -H "Accept: application/json" \
     -H "Authorization: Bearer $API_TOKEN" \
     --data @<(cat <<EOF
    {
        "name": "Analysis Group 1",
        "analysis_ids": [
            "zRa_kk7MlAA",
            "3aR-gbJp98I",
            "JBb08XsZqAo",
            "q9iX2XqFBxM"
        ]
    }
    EOF
    )
```

{% endtab %}

{% tab title="python" %}

```python
import requests

response = requests.post(
    url="https://api.predicthq.com/v1/beam/analysis-groups",
    headers={
        "Authorization": "Bearer $API_TOKEN",
        "Accept": "application/json"
    },
    json={
        "name": "Analysis Group 1",
        "analysis_ids": [
            "zRa_kk7MlAA",
            "3aR-gbJp98I",
            "JBb08XsZqAo",
            "q9iX2XqFBxM",
        ],
    }
)

print(response.json())
```

{% endtab %}
{% endtabs %}

## Best practices

See the [ML features by group notebook](https://github.com/predicthq/phq-data-science-docs/blob/master/demand-forecasting-with-events/identify-group-level-features-with-beam-api.ipynb) for best practices on grouping Analyses.

## OpenAPI spec

See the [Beam API OpenAPI spec](https://api.predicthq.com/docs/?urls.primaryName=Beam+API).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.predicthq.com/api/beam/analysis-groups/create-an-analysis-group.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
