# Attribution & coverage

Map provider projects, workspaces and API keys to customers, read attribution coverage, and set a coverage minimum for the close.

AI Spendbook documentation, Analysis & planning. Web page: https://www.aispendbook.com/docs/attribution-and-coverage

Attribution says which customer each dollar of AI spend was for. It comes from two places: a **mapping** from a provider project, workspace or API key to a customer, and the **telemetry split** of the rest by request cost share. The two never overlap. **Coverage** is how much of the month's spend has a customer.

## Map provider projects, workspaces and keys

- Customers, Mapping lists the OpenAI projects, Anthropic workspaces, Google projects and provider API keys that carried spend in the last 30 days, with the provider's name for each. An admin maps a value to a customer id, and optionally a feature. Values not seen yet can be added by id.
- Matching order: API key, then workspace, then project.
- Mapped spend is taken out of each day and provider's spend before the telemetry split. Billed days read billing records; days still on a provider usage estimate read provider usage records. Days with telemetry only are never mapped.
- [Customer margin](https://www.aispendbook.com/docs/customer-margin) shows “Of which mapped” per customer, and [client statements](https://www.aispendbook.com/docs/client-statements) get a separate line with basis “Mapped”.

## Environment, API key and run

- Usage Explorer, Grouped can group by environment, API key and run, alone or with other dimensions.
- Environment and run come from request telemetry: `environment` and `run_id` on ingested events, or `deployment.environment.name` and `spendbook.run_id` on OpenTelemetry spans. Keep `project_id` for the project or team; do not put the environment there.
- API key alone reads the key id the provider reports.

## Coverage and the close minimum

- Overview, Margin and Customers, Mapping show attribution coverage: the share of this month's spend attributed to a customer (mapped plus telemetry split), the share with telemetry but no customer id, the share with no telemetry, and a six-month trend.
- An admin can set a minimum coverage for the close on Customers, Mapping. Below it, [close readiness](https://www.aispendbook.com/docs/month-end-close) lists a blocking item and closing the month is refused until coverage rises or the minimum changes.

## Display names

Customers, Names gives a customer id, feature id or plan id a readable name, by hand or from a CSV (import type “Customer, feature and plan names”). Names are used on margin, statements (frozen when drafted), statement share links and analytics tables. A plan name set here wins over the product name read from Stripe.

## Limits

- Requests in a mapped project that also send telemetry with a customer id still take part in the telemetry split of the remaining spend. Map a value only when its requests are not tagged in telemetry.
- OpenAI cost reports carry the project but not the API key, so API key mappings for OpenAI apply to usage estimates only.
- Mapped spend is not used by the accounting split, credits or deal actuals.
- Mapping reads raw records, up to 50,000 per request. Grouping and filtering by environment, API key or run read daily totals kept at ingest, with no record limit. Days ingested before those totals existed need a rebuild: an admin sends `POST /api/v1/settings/aggregates/rebuild` with a start and end date.
