# Get credit usage

> GET https://api.nabrah.ai/api/ext/insights/usage

Group: Analytics. Page: https://www.nabrah.ai/en/docs/api-reference/analytics/get-credit-usage

Returns credit use for the current billing period: the period's start and end, total `credits_used`, the AI and AI insights credits within it, and call minutes by call type (inbound, outbound, web). Use it to track spend or to bill your own customers.

## Good to know

- **Whole workspace**: Usage covers the whole workspace tied to your API key, not one agent. For per-agent numbers, use POST /api/ext/insights/agents.
- **unavailable**: Lists the parts that could not be loaded this time ("usage" or "minutes"); retry later for them. Results are cached for up to an hour.

## Authorization

- `X-API-Key` (string, header, required): your workspace API key.

## Query parameters

- `tz` (string, required): Your IANA time zone, e.g. Asia/Riyadh. The period is counted up to the start of today in this zone.

## Response

### 200 Successful Response

Content type: `application/json`

```json
{
  "period_start": "2026-01-15T12:00:00.000Z",
  "period_end": "2026-01-15T12:00:00.000Z",
  "credits_used": 0,
  "ai_credits": 0,
  "ai_insights_credits": 0,
  "minutes": {
    "inbound": 0,
    "outbound": 0,
    "web": 0,
    "total": 0
  },
  "unavailable": [
    "string"
  ]
}
```

### 422 Validation Error

Content type: `application/json`

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
```

## Request examples

### cURL

```bash
curl --request GET \
  --url 'https://api.nabrah.ai/api/ext/insights/usage?tz=<tz>' \
  --header 'X-API-Key: <your-api-key>'
```

### Python

```python
import requests

url = "https://api.nabrah.ai/api/ext/insights/usage?tz=<tz>"
headers = {"X-API-Key": "<your-api-key>"}

response = requests.get(url, headers=headers)
response.raise_for_status()
print(response.json())
```

### JavaScript

```javascript
const response = await fetch("https://api.nabrah.ai/api/ext/insights/usage?tz=<tz>", {
  method: "GET",
  headers: { "X-API-Key": "<your-api-key>" },
});

const data = await response.json();
console.log(data);
```

### Go

```go
package main

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

func main() {
	req, _ := http.NewRequest("GET", "https://api.nabrah.ai/api/ext/insights/usage?tz=<tz>", nil)
	req.Header.Set("X-API-Key", "<your-api-key>")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(string(out))
}
```
