> This page is for version 2025-09-18 (default).
> For other versions, use one of these documentation indexes:
> - 2025-09-18 (default): https://apidocs.polytomic.com/2025-09-18/llms.txt
> - 2024-02-08: https://apidocs.polytomic.com/2024-02-08/llms.txt
> - 2023-04-25: https://apidocs.polytomic.com/2023-04-25/llms.txt
> - 2022-12-12: https://apidocs.polytomic.com/2022-12-12/llms.txt
> - 2021-05-23: https://apidocs.polytomic.com/2021-05-23/llms.txt

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

# Get Connection Usage

GET https://app.polytomic.com/api/connections/{id}/usage

Returns the connection's API consumption over the last 24 hours, broken down by sync when the backend supports it.

Not all integrations support usage reporting.

- `callsLast24h` is null when the backend does not expose a usage count.
- `reportsSyncStats` is `false`, and `bySync` is empty, when the backend
  reports a total but cannot attribute calls to individual syncs.

When per-sync stats are available, each entry in `bySync` carries a
`categories` breakdown. **Category keys and labels are integration-specific.**
For example, Salesforce reports `rest` and `bulk` categories
(collapsing Bulk API v1 and v2 into a single `bulk` bucket), while another
integration may report an entirely different set or none at all. Treat `key`
as an opaque, backend-defined identifier and use `label` for display; do not
assume a fixed vocabulary across connection types.

Reference: https://apidocs.polytomic.com/api-reference/connections/get-usage

## Authentication

- `Authorization` header (bearer token, required) — Bearer user API key
- `Authorization` header (basic auth, required) — Basic organization-scoped API key

## Request

### Path parameters

- `id` (string, required) — Unique identifier of the connection whose API consumption should be returned.

## Response

### 200

OK

- `data` (ConnectionUsageResponse, optional)

## Errors

### 401 Unauthorized Error

Unauthorized

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 404 Not Found Error

Not Found

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

### 500 Internal Server Error

Internal Server Error

- `key` (string, optional)
- `message` (string, optional)
- `metadata` (map from string to any, optional)
- `status` (integer, optional)

## Types

### ConnectionUsageResponse

- `bySync` (list of ConnectionUsageSyncStats, optional, nullable) — Per-sync breakdown of API calls spent against this connection in the last 24 hours, sorted by total calls descending.
- `callsLast24h` (integer, optional, nullable) — Total backend API calls made through this connection over the last 24 hours, or null if the backend does not report usage.
- `connectionId` (string, optional) — Unique identifier of the connection the usage applies to.
- `reportsSyncStats` (boolean, optional) — True when the backend can break its API consumption down per sync; otherwise only the 24h total is reported.

### ConnectionUsageSyncStats

- `categories` (list of ConnectionUsageCategoryStats, optional, nullable) — Per-category breakdown of the sync's calls, sorted by calls descending.
- `lastRunAt` (datetime, optional, nullable) — Start time of the sync's most recent execution, or null if it has never run.
- `syncId` (string, optional) — Unique identifier of the sync that spent the calls.
- `syncName` (string, optional) — Human-readable name of the sync, or empty if it could not be resolved.
- `syncType` (string, optional) — Kind of sync that spent the calls (model or bulk).
- `totalCalls` (integer, optional) — Total API calls the sync spent against this connection in the last 24 hours.

### ConnectionUsageCategoryStats

- `calls` (integer, optional) — Calls the sync spent in this category over the last 24 hours.
- `key` (string, optional) — Backend-defined category identifier (e.g. rest, bulk).
- `label` (string, optional) — Human-readable category name for display.

## Examples

**Response**

```json
{
  "data": {
    "bySync": [
      {
        "categories": [
          {
            "calls": 1,
            "key": "string",
            "label": "string"
          }
        ],
        "lastRunAt": "2024-01-15T09:30:00Z",
        "syncId": "248df4b7-aa70-47b8-a036-33ac447e668d",
        "syncName": "string",
        "syncType": "string",
        "totalCalls": 1
      }
    ],
    "callsLast24h": 1,
    "connectionId": "248df4b7-aa70-47b8-a036-33ac447e668d",
    "reportsSyncStats": true
  }
}
```

**SDK Code**

```python
import requests

url = "https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/usage"

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

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

print(response.json())
```

```javascript
const url = 'https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/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://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/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://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/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://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/usage")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/usage', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/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://app.polytomic.com/api/connections/248df4b7-aa70-47b8-a036-33ac447e668d/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()
```