> This page is for Developer Documentation.

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

# Export the tenant's usage of credits as a CSV file

POST https://{tenant_name}.benchling.com/api/v3/tenant-metering-summary:export-usage
Content-Type: application/json

Export the tenant's usage of Benchling credits as a CSV file. Returns a task; when the task completes, its result contains a presigned download `url` and an expiration timestamp.

## Notes

- Requires tenant admin permission.
- The report reflects only AI credits.
- Returns `400` if `fromTimestamp` is later than `toTimestamp`, or if `userId` does not identify a user in the tenant.
- If the export cannot retrieve all usage in the requested range, the result has `truncated: true`, no `url`, and a `message` explaining why. Narrow the time range and try again.

Reference: https://docs.benchling.com/docs/api/benchling-api/tenant-metering-summary/exportusage

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Headers

- `EARLY-ACCESS` (string, optional) — Set to true to access beta operations via /api/v3.

### Body (application/json)

This endpoint expects an ExportTenantUsageInput.

- `fromTimestamp` (string, required) — Start of the time range of usage events to export
- `toTimestamp` (string, required) — End of the time range of usage events to export.
- `includeNonCreditProducts` (boolean, optional) — Whether to include usage that does not draw from the tenant's credit grant. Defaults to true.
- `userId` (string, optional) — Restrict the export to usage by the user with this ID.

## Response

### 202

Task started

- `pollingUri` (string, optional)
- `taskId` (string, optional)

## Errors

### 400 Bad Request Error

Bad Request

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 403 Forbidden Error

Forbidden

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 404 Not Found Error

Not Found

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 409 Conflict Error

Conflict

- `detail` (GeneralErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 429 Too Many Requests Error

Too Many Requests

- `detail` (TooManyRequestsErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `invalidId` (string, optional)

### 500 Internal Server Error

Internal Server Error

- `detail` (InternalServerErrorDetail, required, nullable)
- `instance` (string, required)
- `status` (integer, required)
- `title` (string, required, nullable)
- `type` (string, required)
- `errorId` (string, optional)

## Types

### GeneralErrorDetail

- string
- map from string to any

### TooManyRequestsErrorDetail

- string
- map from string to any

### InternalServerErrorDetail

- string
- map from string to any

## Examples

**Request**

```json
{
  "fromTimestamp": "string",
  "toTimestamp": "string"
}
```

**Response**

```json
{
  "pollingUri": "string",
  "taskId": "string"
}
```

**SDK Code**

```python
import requests

url = "https://{tenant_name}.benchling.com/api/v3/tenant-metering-summary:export-usage"

payload = {
    "fromTimestamp": "string",
    "toTimestamp": "string"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://{tenant_name}.benchling.com/api/v3/tenant-metering-summary:export-usage';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"fromTimestamp":"string","toTimestamp":"string"}'
};

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