# Cost Tracking

You can label requests with your own cost-tracking tags, and then report usage and cost by those tags. A tag is a free-form label — a project, a team, a customer, a test run — and the Dolby OptiView Ad Engine attributes the usage of every tagged request to it.

## Tagging a Request

Add the `x-rasp-cost-tags` header to any request:

```text
POST https://api.galaxy.dolbyrasp.com/cloud-preview/omakase
x-rasp-auth-token: <your token>
Content-Type: application/json
x-rasp-cost-tags: spring_campaign
```

To apply several tags, separate them with commas:

```text
x-rasp-cost-tags: spring_campaign,trailer_review
```

Each tag is recorded separately, so the usage of this request is attributed to both `spring_campaign` and `trailer_review`.

### Choosing Tag Values

* Use a distinct value you can search for later, such as one per project, team or run — for example `<project>_<batch_id>`.
* A tag cannot contain a comma, because commas always separate tags.
* Avoid `/` and `::`. The platform uses them in the tags it generates itself.
* Tags are case-sensitive: `Spring_Campaign` and `spring_campaign` are different tags.

## Tags on Previews and Conformed Ads

When a request creates a Cloud Preview or a conformed ad, the tags you send are stored with it. Usage from later requests to it — such as playback of the preview or delivery of the ad — is attributed to the same tags, so you do not need to tag those requests yourself.

## Reading Tags Back

The response to a tagged request carries the `x-rasp-cost-tags` header as well, listing your tags. It may also include a tag the platform generated for the request; treat that value as opaque.

## Reporting Usage by Tag

Usage is accounted by the hour, so a tagged request appears in Billing Query once the hour it ran in has been accounted. Its's `meta.coverage.complete_through` shows how far accounting has reached; usage in hours after it is missing from every figure, so a zero there does not mean nothing was used.

[Billing Query](https://optiview.dolby.com/docs/ad-engine/reference/billing-report-query.md) reports cost in currency as well as usage, and tells you whether the data for the period is complete. Use `filters.tags` to select the tags you list, up to five, and group by `tag` for one row per tag. A row is returned for each listed tag that has usage:

```json
{
  "period": {
    "from": "2026-10-01T00:00:00Z",
    "to": "2026-11-01T00:00:00Z"
  },
  "filters": {
    "tags": ["spring_campaign", "trailer_review"]
  },
  "group_by": ["tag"]
}
```

In a filter, list each tag as its own entry, not as a comma-separated string.

The `summary` is the aggregate of everything the filters select, and `data` is the breakdown by the dimensions in `group_by`. Every filter narrows the summary as well as the rows, so a query filtered to one tag reports that tag's usage in its `summary`. Group by `tag` to get one row per tag; without `group_by`, the response has only the `summary` and no rows.

Tags cannot be combined with `ruid`, either in `filters` or in `group_by`, because billing records do not keep the link between a tag and an asset. A query that combines them is rejected with a `400`.

### Tag Rows Do Not Add Up to the Total

A request with two tags counts in full under each of them. So when you group by tag, or filter by more than one tag, the rows and the `summary` do not add up to your real spend. Billing Query flags this: `meta.grouping.overlapping` is `true`, and `meta.grouping.additive_metrics` is empty. Read each tag's usage from its own row, and do not add the rows together. With a single tag in `filters.tags`, the figures are exact. Without a tag filter, the `summary` also includes usage that carries no tag, which appears in no row.
