> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meter.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Strategy Groups

> Organize strategies into groups for bulk management, shared schedules, and unified output schemas

# Strategy Groups

A **strategy group** is an organizational layer above individual strategies. It lets you manage many strategies as a single unit — applying schedules, output schemas, and webhooks to all members at once.

## When to use strategy groups

**Use strategy groups when:**

* You monitor many URLs with similar extraction needs (e.g., 50 product pages)
* You want a single schedule and webhook for all strategies in a batch
* You need to apply or change an output schema across many strategies at once
* You create strategies via [Bulk Upload](/guides/bulk-upload) and want to keep them organized

**Use individual strategies when:**

* You have a handful of unrelated strategies
* Each strategy needs its own schedule or webhook configuration

## How they work

```mermaid theme={null}
graph TD
    G[Strategy Group] --> S1[Strategy A]
    G --> S2[Strategy B]
    G --> S3[Strategy C]
    G --> |"Group Schedule"| SCH[Shared Schedule Config]
    G --> |"Group Schema"| OS[Shared Output Schema]
    SCH --> S1
    SCH --> S2
    SCH --> S3
    OS --> S1
    OS --> S2
    OS --> S3
```

A strategy group provides:

* **Group-level scheduling** — Apply a single schedule configuration (interval or cron, webhook URL, webhook type) to every strategy in the group. Each strategy gets its own schedule instance, but they share the same configuration.
* **Group-level output schemas** — Apply an [output schema](/concepts/output-schemas) to all strategies at once. Meter regenerates each strategy asynchronously to match the new schema.
* **Bulk management** — Enable/disable all schedules, delete all schedules, or test webhooks for the whole group in one call.

## Creating and managing groups

### Create a group

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    from meter_sdk import MeterClient

    client = MeterClient(api_key="sk_live_...")

    group = client.create_strategy_group(
        name="E-commerce Monitors",
        description="Product price tracking across 50 stores"
    )

    print(f"Group ID: {group['id']}")
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={null}
    curl -X POST https://api.meter.sh/api/strategy-groups \
      -H "Authorization: Bearer sk_live_..." \
      -H "Content-Type: application/json" \
      -d '{
        "name": "E-commerce Monitors",
        "description": "Product price tracking across 50 stores"
      }'
    ```
  </Tab>
</Tabs>

### Add strategies to a group

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    client.add_strategies_to_group(
        group_id=group["id"],
        strategy_ids=[
            "550e8400-e29b-41d4-a716-446655440000",
            "660e8400-e29b-41d4-a716-446655440000"
        ]
    )
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={null}
    curl -X POST https://api.meter.sh/api/strategy-groups/{group_id}/strategies \
      -H "Authorization: Bearer sk_live_..." \
      -H "Content-Type: application/json" \
      -d '{
        "strategy_ids": [
          "550e8400-e29b-41d4-a716-446655440000",
          "660e8400-e29b-41d4-a716-446655440000"
        ]
      }'
    ```
  </Tab>
</Tabs>

### Remove a strategy from a group

Removing a strategy from a group does not delete the strategy — it just becomes ungrouped.

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    client.remove_strategy_from_group(
        group_id=group["id"],
        strategy_id="550e8400-e29b-41d4-a716-446655440000"
    )
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={null}
    curl -X DELETE https://api.meter.sh/api/strategy-groups/{group_id}/strategies/{strategy_id} \
      -H "Authorization: Bearer sk_live_..."
    ```
  </Tab>
</Tabs>

### List and inspect groups

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    # List all groups
    groups = client.list_strategy_groups()
    for g in groups:
        print(f"{g['name']}: {g['strategy_count']} strategies")

    # Get group details with member strategies
    detail = client.get_strategy_group(group["id"])
    for strategy in detail["strategies"]:
        print(f"  - {strategy['name']}")
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={null}
    # List groups
    curl https://api.meter.sh/api/strategy-groups \
      -H "Authorization: Bearer sk_live_..."

    # Get group detail
    curl https://api.meter.sh/api/strategy-groups/{group_id} \
      -H "Authorization: Bearer sk_live_..."
    ```
  </Tab>
</Tabs>

## Group scheduling

Apply a schedule to every strategy in the group with a single call. Each strategy gets its own schedule instance with the same configuration.

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    # Schedule all strategies to run every hour with a webhook
    client.apply_group_schedule(
        group_id=group["id"],
        interval_seconds=3600,
        webhook_url="https://your-app.com/webhooks/meter"
    )

    # Or use a cron expression
    client.apply_group_schedule(
        group_id=group["id"],
        cron_expression="0 */6 * * *",  # Every 6 hours
        webhook_url="https://hooks.slack.com/services/T.../B.../xxx"
        # webhook_type auto-detected as "slack"
    )
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={null}
    curl -X POST https://api.meter.sh/api/strategy-groups/{group_id}/schedule \
      -H "Authorization: Bearer sk_live_..." \
      -H "Content-Type: application/json" \
      -d '{
        "interval_seconds": 3600,
        "webhook_url": "https://your-app.com/webhooks/meter"
      }'
    ```
  </Tab>
</Tabs>

### Manage group schedules

```python theme={null}
# Pause all schedules in the group
client.toggle_group_schedules(group["id"], enabled=False)

# Resume all schedules
client.toggle_group_schedules(group["id"], enabled=True)

# Delete all schedules in the group
client.delete_group_schedules(group["id"])
```

<Note>
  Provide either `interval_seconds` or `cron_expression`, not both. The minimum interval is 60 seconds.
</Note>

## Group output schemas

Apply an [output schema](/concepts/output-schemas) to every strategy in a group. Meter regenerates each strategy asynchronously to match the schema structure.

```python theme={null}
# Apply a product schema to all strategies in the group
client.apply_group_schema(
    group_id=group["id"],
    output_schema={
        "product_name": "string",
        "price": "number",
        "in_stock": "boolean",
        "image_url": "string"
    }
)

# Poll for regeneration progress
progress = client.get_schema_progress(group["id"])
print(progress)
```

See [Output Schemas](/concepts/output-schemas) for details on schema definition and type support.

## Deleting a group

Deleting a group does **not** delete the strategies inside it. They become ungrouped.

<Tabs>
  <Tab title="Python SDK">
    ```python theme={null}
    client.delete_strategy_group(group["id"])
    ```
  </Tab>

  <Tab title="curl">
    ```bash theme={null}
    curl -X DELETE https://api.meter.sh/api/strategy-groups/{group_id} \
      -H "Authorization: Bearer sk_live_..."
    ```
  </Tab>
</Tabs>

## Next steps

<CardGroup cols={2}>
  <Card title="Output Schemas" icon="table" href="/concepts/output-schemas">
    Define the exact JSON structure for extraction results
  </Card>

  <Card title="Bulk Upload" icon="upload" href="/guides/bulk-upload">
    Create many strategies at once with bulk upload
  </Card>

  <Card title="Strategy Group API" icon="brackets-curly" href="/api-reference/rest/strategy-groups">
    Full REST API reference for strategy groups
  </Card>

  <Card title="Python SDK" icon="python" href="/api-reference/python/client">
    Strategy group methods in the Python SDK
  </Card>
</CardGroup>

## Need help?

Email me at [mckinnon@meter.sh](mailto:mckinnon@meter.sh)
