---
title: "Fetch cost traces for a customer by external ID"
method: GET
path: "/customers/external/{externalId}/costs"
tags: ["customers"]
---

# Fetch cost traces for a customer by external ID

`GET /customers/external/{externalId}/costs`

## Request

- Base URL: `https://api.agentpaid.io/api/v1`
- URL: `https://api.agentpaid.io/api/v1/customers/external/{externalId}/costs`
- Auth: HTTP bearer

## Path parameters

- `externalId` string, required

## Query parameters

- `limit` integer
- `offset` integer
- `startTime` string, date-time
- `endTime` string, date-time

## Response `200`

Success response

- CostTracesResponse: Response containing cost traces and pagination metadata
  - `traces` CostTrace[], required
    - `name` string, required: The name/type of the operation (e.g., "trace.openai.agents.on_agent")
    - `vendor` string, required: The vendor/provider (e.g., "openai", "anthropic", "mistral")
    - `model` string: The model used for the operation (e.g., "gpt-4o-mini", "claude-3-sonnet")
    - `cost` CostAmount, required: Cost amount with currency
      - `amount` number, double, required: The cost amount
      - `currency` string, required: The currency code (e.g., "USD")
    - `startTimeUnixNano` string, required: Unix timestamp in nanoseconds when the operation started
    - `endTimeUnixNano` string, required: Unix timestamp in nanoseconds when the operation completed
    - `attributes` object, required: Additional metadata about the trace (e.g., tokens, etc.)
  - `meta` PaginationMeta, required: Pagination metadata for cost traces
    - `limit` integer, required: The requested limit
    - `offset` integer, required: The requested offset
    - `count` integer, required: Number of items returned in this response
    - `hasMore` boolean, required: Whether there are more results available
    - `startTime` string, date-time: The startTime filter that was applied (if any)
    - `endTime` string, date-time: The endTime filter that was applied (if any)
    - `externalCustomerId` string: The externalCustomerId filter that was applied (if any)
    - `externalProductId` string: The externalProductId filter that was applied (if any)
    - `externalAgentId` string: DEPRECATED: Use externalProductId instead. The externalAgentId filter that was applied (if any)
    - `metadata` string: The metadata filter that was applied (if any)

## Other responses

- `400`: Bad request - Invalid query parameters
- `403`: Forbidden - Invalid or missing API key
- `404`: Customer not found

---

[API](https://skmtc.dev/paid/apis/paid-2.md) - [All operations](https://skmtc.dev/paid/apis/paid-2/llms.txt) - [OpenAPI document](https://skmtc.dev/paid/apis/paid-2/revisions/dbdf4a60ed27?raw)
