Skip to main content
Use the SDK in server-side software that calls Apostra’s V3 HTTP API. It does not open an MCP connection, obtain credentials, or retry writes for you. You need an API key or M2M access token with access to the intended account, plus a draft campaign to preview. This guide uses a provisioned synthetic buyer and draft campaign in automated checks. Do not put its credentials, or any production credential, in source code. Run the same steps with your own account and campaign before enabling a real launch.

1. Install the SDK

TypeScript requires Node.js 22.18 or later. Python requires Python 3.11 or later. The TypeScript SDK is ESM-only.

2. Supply the API key

Keep the key in your server-side secret manager. These examples read the environment in application code and pass the value to the SDK. The SDK does not read environment variables itself, persist credentials, or send them anywhere except the Apostra API.
APOSTRA_ACCOUNT_ID is optional when the credential already resolves to one account. If you set it, it must name an account that credential can reach.

3. Verify the account

Call getStatus before a write. It returns the account resolved by the credential, its readiness and any blockers.

4. Preview, then confirm a launch

Use a new idempotency key for each distinct write. Keep the same key only when retrying the exact same request after its result is uncertain. A launch request without confirmLaunch previews the draft campaign. Inspect that response and only then make a separate confirmed request.
confirmLaunch: true can activate the campaign’s staged media buys. Do not put the confirmation call on an automatic retry path. The current SDK makes zero automatic retries and sends the key you supply unchanged.

5. Read delivery

Use getDelivery with the campaign and a reporting window. The result is a page, not a fixed snapshot: preserve the same query when following a cursor.
The complete runnable examples live in each package: examples/first-value.ts and examples/first_value.py. They make the launch confirmation opt-in with APOSTRA_CONFIRM_LAUNCH=true so the default synthetic-seller run stops after the preview. For transport error and retry behaviour, use the current SDK guide; future transport improvements do not change this flow.