> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.getunleash.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.getunleash.io/_mcp/server.

# Send metrics in bulk

POST https://app.unleash-instance.example.com/api/client/metrics/bulk
Content-Type: application/json

This operation accepts batched metrics from any client. Metrics will be inserted into Unleash's metrics storage

Reference: https://docs.getunleash.io/api/client-bulk-metrics

## Authentication

- `Authorization` header (required) — API key needed to access this API
- `Authorization` header (bearer token, required) — API key needed to access this API, in Bearer token format

## Request

### Body (application/json)

- `applications` (list of object, required) — A list of applications registered by an Unleash SDK
  - `appName` (string, required) — The name of the application that is evaluating toggles
  - `environment` (string, required) — Which environment the application is running in
  - `instanceId` (string, required) — A [(somewhat) unique identifier](https://docs.getunleash.io/sdks/node#advanced-usage) for the application
  - `connectVia` (list of object, optional) — A list of applications this app registration has been registered through. If connected directly to Unleash, this is an empty list. This can be used in later visualizations to tell how many levels of proxy or Edge instances our SDKs have connected through
    - `appName` (string, required)
    - `instanceId` (string, required)
  - `interval` (double, optional) — How often (in seconds) the application refreshes its features
  - `started` (string or integer, optional) — The application started at
  - `strategies` (list of string, optional) — Enabled [strategies](https://docs.getunleash.io/concepts/activation-strategies) in the application
  - `projects` (list of string, optional) — The list of projects used in the application
  - `sdkVersion` (string, optional) — The version the sdk is running. Typically \<client>:\<version>
  - `sdkType` (enum, optional, nullable) — The sdk type
    - Allowed values: `frontend`, `backend`
  - `sdkFlavor` (string, optional) — The identifier of an integration built on top of an Unleash SDK (e.g. an OpenFeature provider), forwarded by Edge so adoption of the integration can be tracked alongside sdkVersion.
  - `sdkFlavorVersion` (string, optional) — The version of the integration identified by sdkFlavor.
- `metrics` (list of object, required) — a list of client usage metrics registered by downstream providers. (Typically Unleash Edge)
  - `featureName` (string, required) — Name of the feature checked by the SDK
  - `appName` (string, required) — The name of the application the SDK is being used in
  - `environment` (string, required) — Which environment the SDK is being used in
  - `timestamp` (string or integer, optional) — The start of the time window these metrics are valid for. The window is 1 hour wide
  - `yes` (integer, optional) — How many times the toggle evaluated to true
  - `no` (integer, optional) — How many times the toggle evaluated to false
  - `variants` (map from string to integer, optional) — How many times each variant was returned
- `impactMetrics` (list of object or object, optional) — a list of custom impact metrics registered by downstream providers. (Typically Unleash Edge)
  - object
    - `name` (string, required) — Name of the impact metric
    - `help` (string, required) — Human-readable description of what the metric measures
    - `type` (enum, required) — Type of the metric
      - Allowed values: `counter`, `gauge`
    - `samples` (list of object, required) — Samples of the numeric metric
      - `value` (double, required) — The value of the metric sample
      - `labels` (map from string to string or double, optional) — Optional labels for the metric sample
  - object
    - `name` (string, required) — Name of the impact metric
    - `help` (string, required) — Human-readable description of what the metric measures
    - `type` (enum, required) — Type of the metric
      - Allowed values: `histogram`
    - `samples` (list of object, required) — Samples of the histogram metric
      - `count` (double, required) — Total count of observations
      - `sum` (double, required) — Sum of all observed values
      - `buckets` (list of object, required) — Histogram buckets
        - `le` (double or enum, required) — Upper bound of the bucket
        - `count` (double, required) — Count of observations in this bucket
      - `labels` (map from string to string or double, optional) — Optional labels for the metric sample
- `seenTokens` (list of string, optional) — A list of API tokens observed by downstream providers. (Typically Unleash Edge)

## Response

### 202

This response has no body.

## Examples

**Request**

```json
{
  "applications": [
    {
      "appName": "Ingress load balancer",
      "environment": "development",
      "instanceId": "application-name-dacb1234"
    }
  ],
  "metrics": [
    {
      "featureName": "my.special.feature",
      "appName": "accounting",
      "environment": "development"
    }
  ]
}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://app.unleash-instance.example.com/api/client/metrics/bulk"

payload = {
    "applications": [
        {
            "appName": "Ingress load balancer",
            "environment": "development",
            "instanceId": "application-name-dacb1234"
        }
    ],
    "metrics": [
        {
            "featureName": "my.special.feature",
            "appName": "accounting",
            "environment": "development"
        }
    ]
}
headers = {
    "Authorization": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://app.unleash-instance.example.com/api/client/metrics/bulk';
const options = {
  method: 'POST',
  headers: {Authorization: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"applications":[{"appName":"Ingress load balancer","environment":"development","instanceId":"application-name-dacb1234"}],"metrics":[{"featureName":"my.special.feature","appName":"accounting","environment":"development"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.unleash-instance.example.com/api/client/metrics/bulk"

	payload := strings.NewReader("{\n  \"applications\": [\n    {\n      \"appName\": \"Ingress load balancer\",\n      \"environment\": \"development\",\n      \"instanceId\": \"application-name-dacb1234\"\n    }\n  ],\n  \"metrics\": [\n    {\n      \"featureName\": \"my.special.feature\",\n      \"appName\": \"accounting\",\n      \"environment\": \"development\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.unleash-instance.example.com/api/client/metrics/bulk")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"applications\": [\n    {\n      \"appName\": \"Ingress load balancer\",\n      \"environment\": \"development\",\n      \"instanceId\": \"application-name-dacb1234\"\n    }\n  ],\n  \"metrics\": [\n    {\n      \"featureName\": \"my.special.feature\",\n      \"appName\": \"accounting\",\n      \"environment\": \"development\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.unleash-instance.example.com/api/client/metrics/bulk")
  .header("Authorization", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"applications\": [\n    {\n      \"appName\": \"Ingress load balancer\",\n      \"environment\": \"development\",\n      \"instanceId\": \"application-name-dacb1234\"\n    }\n  ],\n  \"metrics\": [\n    {\n      \"featureName\": \"my.special.feature\",\n      \"appName\": \"accounting\",\n      \"environment\": \"development\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.unleash-instance.example.com/api/client/metrics/bulk', [
  'body' => '{
  "applications": [
    {
      "appName": "Ingress load balancer",
      "environment": "development",
      "instanceId": "application-name-dacb1234"
    }
  ],
  "metrics": [
    {
      "featureName": "my.special.feature",
      "appName": "accounting",
      "environment": "development"
    }
  ]
}',
  'headers' => [
    'Authorization' => '<apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.unleash-instance.example.com/api/client/metrics/bulk");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"applications\": [\n    {\n      \"appName\": \"Ingress load balancer\",\n      \"environment\": \"development\",\n      \"instanceId\": \"application-name-dacb1234\"\n    }\n  ],\n  \"metrics\": [\n    {\n      \"featureName\": \"my.special.feature\",\n      \"appName\": \"accounting\",\n      \"environment\": \"development\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "applications": [
    [
      "appName": "Ingress load balancer",
      "environment": "development",
      "instanceId": "application-name-dacb1234"
    ]
  ],
  "metrics": [
    [
      "featureName": "my.special.feature",
      "appName": "accounting",
      "environment": "development"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.unleash-instance.example.com/api/client/metrics/bulk")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```