> This page is for Gateway.

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

# Get Organization Usage

GET https://api-gateway.merge.dev/v1/organization/usage

Organization-wide spend for a date range: totals by day, a per-model
breakdown by month, and optionally a breakdown by project, API key or
vendor.

Reference: https://docs.merge.dev/merge-gateway/management-api/usage/get-organization-usage

## Authentication

- `Authorization` header (bearer token, required) — A management key (`mgmt_...`), sent as `Authorization: Bearer <key>`. Reading /v1/routing-policies also accepts the organization's gateway API keys; writing there needs a management key.

## Request

### Query parameters

- `start` (string, optional, nullable) — First day of the range, `YYYY-MM-DD`, inclusive. Defaults to the 1st of this month.
- `end` (string, optional, nullable) — Last day of the range, `YYYY-MM-DD`, inclusive. Defaults to today.
- `group_by` (enum, optional, nullable) — Also break spend down by project, API key or vendor.
  - Allowed values: `project`, `api_key`, `vendor`

## Response

### 200

The organization's spend and usage for the range

- `byok_spend` (double, required) — Spend on your own provider credentials (BYOK), at list price, USD.
- `end` (string, required) — Last day of the range, inclusive, `YYYY-MM-DD`.
- `merge_hosted_spend` (double, required) — Spend on Merge-managed credentials, USD.
- `model_spend` (map from string to double, required) — Spend in USD per `provider/model`, with BYOK spend at list price. Covers the whole months the range overlaps.
- `model_spend_granularity` ("month", required) — `model_spend` and `vendors` cover the whole months overlapping `start` to `end`.
- `request_count` (integer, required) — Number of requests.
- `start` (string, required) — First day of the range, `YYYY-MM-DD`.
- `total_spend` (double, required) — All spend, USD.
- `web_search_spend` (double, required) — Server-side web search cost, USD.
- `api_keys` (list of APIKeySpendV1, optional) — Spend per API key. Present with `group_by=api_key`.
- `projects` (list of ProjectSpendV1, optional) — Spend per project. Present with `group_by=project`.
- `vendors` (map from string to double, optional) — Spend in USD per serving vendor, by month like `model_spend`. Present with `group_by=vendor`.

## Errors

### 401 Unauthorized Error

The key is missing or invalid.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 403 Forbidden Error

The key lacks the scope this route needs, or the change is not allowed.

- `detail` (ErrorResponseDetail, required) — A message, or an object with a `code` to branch on and a `message`.

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### APIKeySpendV1

One API key's spend.

- `api_key_id` (string, required) — The key's `hash`.
- `byok_spend` (double, required) — Spend on your own provider credentials (BYOK), at list price, USD.
- `merge_hosted_spend` (double, required) — Spend on Merge-managed credentials, USD.
- `request_count` (integer, required) — Number of requests.
- `total_spend` (double, required) — All spend, USD.
- `web_search_spend` (double, required) — Server-side web search cost, USD.

### ProjectSpendV1

One project's spend.

- `byok_spend` (double, required) — Spend on your own provider credentials (BYOK), at list price, USD.
- `merge_hosted_spend` (double, required) — Spend on Merge-managed credentials, USD.
- `project_id` (string, required) — The project's id.
- `request_count` (integer, required) — Number of requests.
- `total_spend` (double, required) — All spend, USD.
- `web_search_spend` (double, required) — Server-side web search cost, USD.

### ErrorResponseDetail

A message, or an object with a `code` to branch on and a `message`.

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `ctx` (ValidationErrorCtx, optional)
- `input` (any, optional)

### ErrorDetail

A structured error. Some carry extra fields, like `count`.

- `code` (string, required) — A stable code to branch on, like `payment_method_required`.
- `message` (string, required) — A human-readable explanation.

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Response**

```json
{
  "byok_spend": 371.85,
  "end": "2026-09-30",
  "merge_hosted_spend": 902.17,
  "model_spend": {
    "anthropic/claude-sonnet-4-6": 811.4,
    "openai/gpt-5-mini": 74.5,
    "openai/gpt-5.5": 398.62
  },
  "model_spend_granularity": "month",
  "request_count": 48210,
  "start": "2026-09-01",
  "total_spend": 1284.52,
  "web_search_spend": 10.5,
  "projects": [
    {
      "byok_spend": 371.85,
      "merge_hosted_spend": 902.17,
      "project_id": "8b6f2d4a-1c3e-4b5a-9f7d-2e0c6a8b4d91",
      "request_count": 48210,
      "total_spend": 1284.52,
      "web_search_spend": 10.5
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api-gateway.merge.dev/v1/organization/usage"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/organization/usage';
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api-gateway.merge.dev/v1/organization/usage"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")

	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://api-gateway.merge.dev/v1/organization/usage")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

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.get("https://api-gateway.merge.dev/v1/organization/usage")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api-gateway.merge.dev/v1/organization/usage', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/organization/usage");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-gateway.merge.dev/v1/organization/usage")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

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()
```