---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://segmentstream.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# X Ads

Ads accounts, campaigns, line items and stats. X Ads accounts, campaigns and stats through SegmentStream's X application. Tokens and their secrets stay with the platform.

Built in

X Ads accounts, campaigns and stats through SegmentStream's X application. Tokens and their secrets stay with the platform.

Inside SegmentStream

## Connected once, used everywhere.

Connections are declared in your repository and authorised in the console. The credentials stay with the platform; apps, pipelines, workflows and the agent use them under the same roles.

segmentstream.com

![The console's connections page: the 43 connections declared in our workspace's code, here the public reference lists of AI and search crawlers, each connected, with the key it is declared under](https://segmentstream.com/screens/dark/console-connections.webp)

Connections declared in code and authorised here. The credentials stay with the platform, never in the repository.

## What the connection reaches

- Ads accounts
- Campaigns, line items and promoted posts
- Account stats

* Status

  Built into the pipeline SDK

* Connection class

  XAdsConnection

* Credential

  X account with access to the ads accounts

## Connect X Ads

Three steps, the same for every connection. The credential goes to the platform, never into the repository or pipeline code.

1. 1

   Declare it in connections/connections.py

   connections/connections.py

   ```
    from segmentstream_connections import XAdsConnection   connections = (     XAdsConnection(key="x_ads"), )
   ```

2. 2

   Deploy

   ```
   $ segmentstream deploy
   ```

3. 3

   Connect

   Open the connection in the console and sign in with the X account that manages your ads accounts, or authorise it from the terminal. Tokens are refreshed by the platform; pipeline code never sees them.

   ```
   $ segmentstream connection authorize x_ads --open
   ```

### Use it

Code asks for the connection by its key. The platform adds the credential on the way out.

pipeline/ingestion/…

```
 import segmentstream as s   with s.get_connection("x_ads").get_http_client() as client:     response = client.get("/accounts")     response.raise_for_status()
```

### Or ask your agent

“Connect X Ads and load daily stats by campaign.”

## Part of these solutions

[Growth and marketing analytics](https://segmentstream.com/solutions/growth-analytics)

[Lead scoring, cost data and attribution as code](https://segmentstream.com/solutions/growth-analytics)

## More in Advertising

[Google Ads Accounts and GAQL reporting for spend, clicks and conversions.](https://segmentstream.com/integrations/google-ads) · [Meta Ads Spend and results from Facebook and Instagram campaigns.](https://segmentstream.com/integrations/meta-ads) · [Microsoft Ads Bing and Microsoft Advertising accounts, campaigns and reports.](https://segmentstream.com/integrations/microsoft-ads) · [TikTok Ads Advertisers, campaigns and integrated reports.](https://segmentstream.com/integrations/tiktok-ads)

[All integrations →](https://segmentstream.com/integrations)

Enterprise pilot

## Want X Ads set up for you?

Our forward-deployed engineers build one solution on your data, in your own workspace, as code you own. Tell us what you run today and what you want; your note goes straight to our founder.

- One solution, on your data, in your own workspace
- First version live in two weeks
- Parity proven before anything is switched off
- Fixed scope and price, credited to your contract if you continue

Not ready for a pilot? Send the form anyway with your question. An engineer will reply, not a sales rep.

[How the pilot works](https://segmentstream.com/enterprise)

NameWork email

CompanyWhat should the pilot cover?

Anything we should knowHow did you hear about us?

Goes to our founder’s inbox. No sales queue, no newsletter.

## Connect what your company runs.

[Start a pilot](https://segmentstream.com/enterprise#pilot)

Our engineers build the first version on your data in two weeks, at a fixed price.

Or build it yourself with your coding agent:

`curl -fsSL https://segmentstream.com/install.sh | sh`

Work email

We’ll email you product updates, tips and onboarding help. Unsubscribe anytime.
