# ES Business Units cURL Examples (v1)

Use env vars:
- `ES_URL`
- `ES_API_KEY`
- `ES_INDEX=customer_subscription_v1`

## Currency-wise subscribers + revenue
```bash
curl -sS -H "Authorization: ApiKey $ES_API_KEY" "$ES_URL/$ES_INDEX/_search" \
  -H 'Content-Type: application/json' -d '{
  "size": 0,
  "query": {"bool": {"must": [{"term": {"app_id": 1004}}]}},
  "aggs": {
    "orders_nested": {
      "nested": {"path": "orders"},
      "aggs": {
        "by_currency": {
          "terms": {"field": "orders.currency", "size": 50},
          "aggs": {
            "revenue": {"sum": {"field": "orders.price"}},
            "users": {"cardinality": {"field": "orders.sms_cust_id"}}
          }
        }
      }
    }
  }
}'
```
