> 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/add-data.md). Agents can also search and read this documentation through its [MCP server](https://hexpandify.gitbook.io/hexpandify-docs/~gitbook/mcp).

# Add data

{% openapi src="/files/55PS6TzOloSjRYKyV7up" path="/api/v1/hex/metadata" method="post" %}
[openapi.yaml](https://2861864537-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUdbZXi5eYcVVJEns736y%2Fuploads%2FQ02pfkXUYPDh1cZyekUd%2Fopenapi.yaml?alt=media\&token=fd7fe1b1-2482-4707-8716-9e1ffeefd070)
{% endopenapi %}

{% openapi src="/files/4EE0wNCiRhWiagjfxSF7" path="/api/v1/hex/metrics" method="post" %}
[openapi.yaml](https://2861864537-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUdbZXi5eYcVVJEns736y%2Fuploads%2Ft4UCvtRvFhv5niT5pjwz%2Fopenapi.yaml?alt=media\&token=c73bed86-c138-4ff8-ae17-413150bc6e64)
{% endopenapi %}

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

### Usage Examples

#### Create a New Hexagon

```bash
bashCopiarEditarcurl -X POST \
  'http://app.hexpandify.com/api/v1/hex/metadata' \
  -H 'X-API-KEY: your-api-key' \
  -H 'Content-Type: application/json' \
  -d '{
    "hexKey": "u001",
    "displayName": "User 001",
    "shortName": "U1",
    "description": "Premium Customer"
  }'
```

#### Submit Metrics

```bash
bashCopiarEditarcurl -X POST \
  'http://app.hexpandify.com/api/v1/hex/metrics' \
  -H 'X-API-KEY: your-api-key' \
  -H 'Content-Type: application/json' \
  -d '{
    "dateStart": "2024-01-01",
    "metricData": {
      "u001.production.songs_played": [100, 150, 200],
      "u001.health.session_time": [45, 60, 75]
    }
  }'
```
