> For the complete documentation index, see [llms.txt](https://hexpandify.gitbook.io/hexpandify-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hexpandify.gitbook.io/hexpandify-docs/api-docs/metric-series.md). Agents can also search and read this documentation through its [MCP server](https://hexpandify.gitbook.io/hexpandify-docs/~gitbook/mcp).

# Metric Series

## POST /api/v1/hex/metrics

> Send metric data

```json
{"openapi":"3.0.0","info":{"title":"Hexpandify API - Hex Metrics","version":"1.0.0"},"servers":[{"url":"https://app.hexpandify.com","description":"Production server"},{"url":"http://localhost:8080","description":"Local development"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-KEY"}},"schemas":{"MetricData":{"type":"object","required":["date_start","hex_metric_data"],"properties":{"hex_metric_config":{"type":"object","additionalProperties":{"$ref":"metric-definitions.yaml#/components/schemas/MetricDefinition"},"description":"Optional metric definitions to process along with the data"},"hex_metric_data":{"type":"object","additionalProperties":{"type":"array","items":{"oneOf":[{"type":"number"},{"type":"string"}]}},"description":"Map of metric values where key is in format hexKey.category.metricName"},"date_start":{"type":"string","format":"date","description":"Start date for the metric data (UTC)"},"date_gmt":{"type":"integer","minimum":-12,"maximum":14,"default":0,"description":"GMT offset for date_start"}}}}},"paths":{"/api/v1/hex/metrics":{"post":{"summary":"Send metric data","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricData"}}}},"responses":{"202":{"description":"Data accepted for processing","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"string"}}}}}},"429":{"description":"Too many requests","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"string"},"retry_after":{"type":"integer"}}}}}}}}}}}
```

### Limits and Considerations

* Metrics must be submitted in chronological order.
* The maximum `windowSize` depends on `bucketSize`.
* Metric names can only contain letters, numbers, and dots.
* The `metricKey` format must be: hexKey.category.metricName.

## Apply delta operations to metric data

> Applies increments or decrements to existing metrics.\
> \- If the metric DOES NOT exist on the specified date: it is created with value 0 and then the delta is applied\
> \- If the metric ALREADY exists: the current value is taken and the delta is added/subtracted\
> \
> This endpoint is ideal for:\
> \- Incremental counters (sales, users, clicks)\
> \- Inventory adjustments (in/out)\
> \- Debit/credit operations<br>

```json
{"openapi":"3.0.0","info":{"title":"Hexpandify API - Hex Metrics","version":"1.0.0"},"servers":[{"url":"https://app.hexpandify.com","description":"Production server"},{"url":"http://localhost:8080","description":"Local development"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-KEY"}},"schemas":{"MetricDeltaData":{"type":"object","required":["hex_metric_delta"],"properties":{"hex_metric_delta":{"type":"object","additionalProperties":{"type":"number"},"description":"Map of metric delta values where key is in format hexKey.category.metricName.\nThe value represents an increment (positive) or decrement (negative) to apply.\nIf the metric does not exist on the specified date, it is created with value 0 and then the delta is applied.\nIf the metric already exists, the current value is taken and the provided delta is added/subtracted.\n"},"date_start":{"type":"string","format":"date","description":"Date on which the delta will be applied (UTC). If not provided, the current date adjusted by date_gmt is used"},"date_gmt":{"type":"integer","minimum":-12,"maximum":14,"default":0,"description":"GMT offset for date_start (only applied if date_start is not present)"}}}}},"paths":{"/api/v1/hex/metrics/delta":{"post":{"summary":"Apply delta operations to metric data","description":"Applies increments or decrements to existing metrics.\n- If the metric DOES NOT exist on the specified date: it is created with value 0 and then the delta is applied\n- If the metric ALREADY exists: the current value is taken and the delta is added/subtracted\n\nThis endpoint is ideal for:\n- Incremental counters (sales, users, clicks)\n- Inventory adjustments (in/out)\n- Debit/credit operations\n","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MetricDeltaData"}}}},"responses":{"200":{"description":"Delta processed successfully (DIRECT strategy)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"string"},"results":{"type":"array","items":{"type":"object","properties":{"metricKey":{"type":"string"},"status":{"type":"string","enum":["SUCCESS","ERROR"]},"message":{"type":"string"}}}}}}}}},"202":{"description":"Delta accepted for processing (QUEUE strategy)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"string"}}}}}},"422":{"description":"Validation error","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"string"}}}}}},"429":{"description":"Too many requests","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"status":{"type":"string"},"retry_after":{"type":"integer"}}}}}}}}}}}
```

## GET /api/v1/hex/summary

> Get metrics summary

```json
{"openapi":"3.0.0","info":{"title":"Hexpandify API - Hex Metrics","version":"1.0.0"},"servers":[{"url":"https://app.hexpandify.com","description":"Production server"},{"url":"http://localhost:8080","description":"Local development"}],"security":[{"ApiKeyAuth":[]}],"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-KEY"}}},"paths":{"/api/v1/hex/summary":{"get":{"summary":"Get metrics summary","parameters":[{"name":"date","in":"query","schema":{"type":"string","format":"date"},"description":"End date for data window"},{"name":"bucketSize","in":"query","schema":{"type":"string","enum":["DAILY","WEEKLY","MONTHLY","YEARLY","LIFETIME"]},"description":"Time aggregation granularity","default":"DAILY"},{"name":"windowSize","in":"query","schema":{"type":"integer","minimum":1},"description":"Number of time periods","default":1},{"name":"metricKey","in":"query","schema":{"type":"string"},"description":"Filter for specific hex/metric"},{"name":"loadAll","in":"query","schema":{"type":"boolean"},"description":"Load all available data","default":false}],"responses":{"200":{"description":"Successful operation","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"object","additionalProperties":{"type":"object"}},"metadata":{"type":"object","properties":{"bucketSize":{"type":"string"},"windowSize":{"type":"integer"},"startDate":{"type":"string"},"endDate":{"type":"string"}}}}}}}}}}}}}
```
