Skip to main content
This example creates an audience and runs it. You need bash, curl, jq, an organization API key, and audience access.
Creating an active audience can use an audience slot or eligible one-shot access. This example writes files in a new local directory and leaves the audience in your organization. Review the preview before running the creation step.

Find topic IDs

Set LEADPIPE_API_KEY in your environment. Search for topics and select the returned IDs that match your use case:
Set ORBIT_TOPIC_IDS to a JSON array of your selected integer IDs. Use values returned by discovery, not IDs copied from an unrelated example. The following scripts share files in the working directory you create in the next step.

Validate and preview

Run in Bash:
Review the preview size and audience mix. Samples are masked. Add filters using the live catalog, then repeat validation and preview if needed.

Create, run, and export

After reviewing the preview, run this in the same Bash session and directory. It stops immediately on request failures and polls only 202 responses, for at most 60 attempts. The five-second interval and attempt limit are example client settings, not service timing guarantees.
On 401, 403, 409, or 429, this example stops instead of treating the error as pending. Read the response before retrying. For 429, honor Retry-After when present. A request timeout can leave a write’s outcome uncertain: inspect existing audiences or retry the run request with its saved idempotency key rather than restarting creation blindly. results.json contains only the first page. Follow result pagination to read every row. Direct CSV exports are capped at 300,000 rows.

Stored exports

For a reusable export record and an expiring signed URL, use stored exports. Signed URLs contain access credentials; keep them out of public logs and shared tickets.

Finish the evaluation

The example leaves an active audience behind. Pause it if you do not want future automatic refreshes. Deletion also removes its runs, results, and exports and does not restore a consumed one-shot trial.