> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bijection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Advertising performance reports

> Submit, poll and download a bounded configurable performance report on your app.

Mount `@bijectionhq/app-microsoft-advertising` for `microsoft-advertising.performance.report`. Use a Microsoft Advertising
v13 reporting principal with access to the chosen account. Declare the OAuth
access token and the developer token as separate secrets for the reporting
receiver.

```ts app.ts theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
import { app, label, secret } from "@bijectionhq/bijection";
import microsoftAdvertising, {
  microsoftAdvertisingDownload, microsoftAdvertisingReporting,
} from "@bijectionhq/app-microsoft-advertising";

const ads = label();
const token = secret();
const developerToken = secret();
const reporting = microsoftAdvertisingReporting({ secret: token, developerToken, label: ads });
const download = microsoftAdvertisingDownload(["bingadsappsstorageprod.blob.core.windows.net"], ads);

export default app({ ads, token, developerToken, reporting, download, msads: microsoftAdvertising({ data: ads, reporting, download }) });
```

```sh theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
bijection secret set token
bijection secret set developerToken
```

`msads.operator` is granted from code: `ctx.grant(msads.operator, { to, under })` in one of your
mutations ([Grants](https://docs.bijection.com/access/grants.md)).

The mount requires a protected `data` label: under the public label
`reports.start` refuses `PublicLabel`. Its `operator` role clears `data` and is
the only role `msads.reports.start`, `msads.reports.status` and
`msads.records.list` allow.

Review the exact download hostnames your Microsoft Reporting API returns
before binding the download receiver. The hostname in this example comes
from a recorded report. Microsoft can change its download host. The receiver
requires an approved public DNS name on HTTPS port 443, pins the resolved
address, and sends the provider's temporary URL without the reporting
credentials. A redirect is not followed. The app exposes report status
without the temporary URL.

Call `msads.reports.start` with a stable request key, the manager and account
IDs, an inclusive interval of one to 31 dates, and the report shape.

```json theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
{ "key": "january-2026", "customerId": "254000", "accountId": "1810200",
  "since": "2026-01-01", "until": "2026-01-31",
  "level": "campaign", "breakdowns": ["DeviceType"], "metrics": ["Impressions", "Clicks", "Spend"], "limit": 100 }
```

Choose a report level from `account`, `campaign`, `adGroup`, `ad` and
`keyword`. Add applicable `DeviceType` and `Network` breakdowns, or use an
empty list. Select metrics from `Impressions`, `Clicks`, `Spend`,
`Conversions`, `Revenue`, `AllConversions` and `AllRevenue`.

Reusing that key with identical inputs answers `replayed`, and other inputs
refuse `KeyReused`. An invalid key or ID refuses `InvalidIdentity`. A mount
runs one request at a time. It submits once and polls the retained Microsoft
report ID at least two minutes apart, for up to 45 minutes. An unavailable
download is recovered by polling the same ID for a fresh link. A submission
that settles `Unknown` is never automatically resubmitted. Renew the
sealed OAuth access token before it expires. Use `reports.status` to inspect
the result. It returns a workflow failure reason and a structured `refusal`
with `code` and `message` when a task supplied one. Use `refusalText` from
`@bijectionhq/bijection/client` to format that refusal for display.

The app accepts one UTF-8 CSV member in a ZIP up to 36 KiB, with up to
48 KiB of CSV and an installer bound of up to 100 rows. It publishes in one
commit using the report shape, entity, date and breakdown values as the key.
A later explicit report can update those keys. Days omitted by the provider leave their prior observations in
place. `records.list({ cursor })` returns `{ facts, next }`, at most 31 rows a
page; pass `next` as the following call's `cursor`, and start with `null`. The
table is [protected](https://docs.bijection.com/database/protected-tables.md), so pages come in row order,
not by key. Deployment
requires the release-produced ZIP/CSV connector parser.

[Microsoft Advertising Reporting Service](https://learn.microsoft.com/en-us/advertising/reporting-service/request-download-report?view=bingads-13)

## Campaign Management entities

Mount [REST](https://docs.bijection.com/integrations/native-rest.md#mount-and-bind) for entity reads.
Use `providerEndpoint` on `https://campaign.api.bingads.microsoft.com`,
with the protected `data` label and separate sealed `Authorization`
(`Bearer ` prefix) and `DeveloperToken` (no prefix) header bindings.

| Mode | Path suffix under `/CampaignManagement/v13` | `collection` |
| - | - | - |
| `microsoft-advertising.campaigns.observations` | `/Campaigns/QueryByAccountId` | Manager customer ID |
| `microsoft-advertising.ad-groups.observations` | `/AdGroups/QueryByCampaignId` | Manager and campaign IDs as `CUSTOMER:CAMPAIGN` |
| `microsoft-advertising.ads.observations` | `/Ads/QueryByAdGroupId` | Manager and ad group IDs as `CUSTOMER:AD_GROUP` |

Set `selection` to the account ID and `limit` to at most 100. The
campaigns mode reads search campaigns. The ads mode reads responsive
search ads and their embedded creative. Each poll requires the whole
scope to fit one 36 KiB answer. Keys combine account, query scope and
returned entity ID. Missing entities leave prior observations in place.

## Conversion writes

Bind a writer with `providerWriter` for
`microsoft-advertising.conversions.upload` on the Campaign Management
origin and pass it in `receivers.writers` under that mode. Use separate sealed `Authorization` (with `Bearer ` prefix),
`DeveloperToken`, `CustomerId` and `CustomerAccountId` headers.
Submit a `create` command with `MicrosoftClickId`, `ConversionName` and
`ConversionTime` in UTC. The receipt requires an empty `PartialErrors` array.

Follow the [native write guide](https://docs.bijection.com/integrations/native-rest.md#native-provider-writes)
and bind the same protected `data` label to the mount and writer.
Each command takes one JSON object up to 24 KiB. The mount binds its
key to the exact command and dispatches once. A dispatch that settles
`Unknown` stays unresolved. Acknowledgement does not establish attribution.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.