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

# List Keys

GET https://api-gateway.merge.dev/v1/keys

Return the organization's API keys, newest first, with their current
usage. The management key's organization is implied by the key itself. A
page holds at most 100 keys; while `has_more` is true, advance `offset` to
read the rest. Filter with `project_id` or `disabled`.

Reference: https://docs.merge.dev/merge-gateway/management-api/api-keys/list-keys

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

- `offset` (integer, optional, default: 0) — Number of keys to skip.
- `limit` (integer, optional, default: 100) — Maximum number of keys to return (at most 100).
- `project_id` (string, optional, nullable) — Only keys scoped to this project.
- `disabled` (boolean, optional, nullable) — Only disabled keys (true) or only enabled keys (false).

## Response

### 200

The list of API keys

- `data` (list of KeyObject, required) — The keys on this page, newest first.
- `has_more` (boolean, optional, default: false) — True when more keys remain beyond this page. Advance `offset` until it's false.
- `object` ("list", optional, default: list) — Always `list`.

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

### 503 Service Unavailable Error

A service the request needs, such as billing or the gateway itself, is temporarily unavailable. Retry later.

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

## Types

### KeyObject

An API key and its current spend.

- `byok_usage` (double, required) — The part of usage from requests that ran on the organization's own provider credentials (BYOK).
- `byok_usage_daily` (double, required) — The BYOK part of usage_daily.
- `byok_usage_monthly` (double, required) — The BYOK part of usage_monthly.
- `byok_usage_weekly` (double, required) — The BYOK part of usage_weekly.
- `creator_user_id` (string, required, nullable) — The dashboard user who created the key. Null for keys created with a management key.
- `disabled` (boolean, required) — Whether the key is disabled. A disabled key can't call the gateway but isn't deleted.
- `hash` (string, required) — Stable identifier for the key: the SHA-256 hash of the raw key, as 64 hex characters. Not the secret, so it's safe to store and log. Use it in get, update and delete calls.
- `label` (string, required) — Display label: the key's first characters, like `mg_8Kx2pQr`. Not the secret.
- `usage` (double, required) — Spend in USD in the current `limit_reset` window.
- `usage_daily` (double, required) — USD spend today.
- `usage_monthly` (double, required) — USD spend since the 1st of the month.
- `usage_weekly` (double, required) — USD spend since Monday.
- `allowed_models` (list of string, optional, nullable) — Models the key may call. Null means unrestricted; an empty list blocks every model.
- `budget_group_id` (string, optional, nullable) — The Merge for Workforce budget group the key draws down.
- `created_at` (datetime, optional, nullable) — When the key was created.
- `expires_at` (datetime, optional, nullable) — When the key stops working. Null means it never expires.
- `limit` (double, optional, nullable) — Spend cap in USD over the `limit_reset` window. Null means no cap.
- `limit_remaining` (double, optional, nullable) — Spend left in USD before the cap: `limit` minus `usage`, never below 0. Null when there's no limit.
- `limit_reset` (enum, optional, nullable) — The window the spend cap applies to, reset at midnight UTC: `daily`, `weekly` (from Monday) or `monthly` (from the 1st). Monthly when unset.
  - Allowed values: `daily`, `weekly`, `monthly`
- `name` (string, optional, nullable) — The key's name.
- `project_id` (string, optional, nullable) — Project the key is scoped to, or null for an organization-wide key. Can't be changed after creation.
- `routing_policy_id` (string, optional, nullable) — Routing policy bound to the key, if any.
- `updated_at` (datetime, optional, nullable) — When the key last changed.

### 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
{
  "data": [
    {
      "byok_usage": 4.1,
      "byok_usage_daily": 0.3,
      "byok_usage_monthly": 4.1,
      "byok_usage_weekly": 1.05,
      "creator_user_id": null,
      "disabled": false,
      "hash": "5f3c8a1e9b2d4f6a7c0e1b3d5f7a9c2e4b6d8f0a1c3e5b7d9f2a4c6e8b0d1f3a",
      "label": "mg_8Kx2pQr",
      "usage": 12.4,
      "usage_daily": 0.82,
      "usage_monthly": 12.4,
      "usage_weekly": 3.15,
      "allowed_models": [
        "anthropic/claude-sonnet-4-6",
        "openai/*"
      ],
      "budget_group_id": null,
      "created_at": "2026-06-02T17:04:00Z",
      "expires_at": null,
      "limit": 50,
      "limit_remaining": 37.6,
      "limit_reset": "monthly",
      "name": "customer-acme",
      "project_id": "8b6f2d4a-1c3e-4b5a-9f7d-2e0c6a8b4d91",
      "routing_policy_id": null,
      "updated_at": "2026-09-14T09:30:00Z"
    }
  ],
  "has_more": false,
  "object": "list"
}
```

**SDK Code**

```python
import requests

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

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

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

print(response.json())
```

```javascript
const url = 'https://api-gateway.merge.dev/v1/keys';
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/keys"

	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/keys")

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/keys")
  .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/keys', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api-gateway.merge.dev/v1/keys");
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/keys")! 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()
```