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

# Snapchat Ads source connector

> Read Snapchat ad accounts, campaigns, ad squads, ads, creatives, audiences, and delivery stats with Filament, the open-source data movement engine.

Connector ID `snapchat_ads`

The Snapchat Ads source reads organizations, ad accounts, the campaign hierarchy,
creatives, media, audience segments, and delivery stats from the
[Snap Marketing API](https://developers.snap.com/api/marketing-api/Ads-API/introduction).
It uses an [HTTP manifest](https://filament.getgalaxy.io/pages/connectors/building-a-connector/http-manifests.md)
and targets API version `v1`. The connector is in preview. It has been checked
against Snap's API docs and tested with mock responses, but has not yet been
tested against a live account.

## Configuration

| Field | Scope | Default | Description |
| - | - | - | - |
| `client_id` | Connection | | Required. OAuth client ID of your Snap app. |
| `client_secret` | Connection | | Required. Secret. OAuth client secret of your Snap app. |
| `refresh_token` | Connection | | Required. Secret. Refresh token issued to the authorizing member. |
| `start_date` | Pipeline | | First day of the stats window. Required by daily stats, hourly stats, and stats report resources only. |
| `end_date` | Pipeline | | Day after the last day of the stats window. Must be later than `start_date`. |

An Organization Admin creates the OAuth app in the **Business Details** section
of [Snap Business Manager](https://business.snapchat.com/) and sets a redirect
URI. Open the authorization URL with the `snapchat-marketing-api` scope,
approve access, then exchange the returned code for tokens. See
[Snap's authentication guide](https://developers.snap.com/api/marketing-api/Ads-API/authentication)
for the full flow. Filament exchanges the refresh token for a new access token
whenever it needs one.

Tokens carry the authorizing member's permissions. That member needs access to
every ad account in each organization it can see, because a forbidden ad account
fails the resources that read it. An Organization Admin has that access. Invoices
also need the Organization Admin, Ad Account Admin, or Campaign Manager role. The
refresh token stops working when the member loses access, so authorize with an
account your team keeps. Connection testing lists the member's organizations.

Dates use `YYYY-MM-DD`. Snap reads the window in each ad account's time zone
and treats `end_date` as exclusive. Hourly stats resources accept at most 7 days
and daily stats resources at most 31 days. Snap rejects a longer window for
them. Stats reports have no span limit. One window applies to all of them, so
read hourly stats in their own pipeline when you want daily stats over a longer
window.

## Resources

The default selection includes the entity resources and lifetime stats for ad
accounts and campaigns. All other resources are opt-in.

### Accounts and campaigns

| Resource | Endpoint | Parent |
| - | - | - |
| `organizations` | `GET /v1/me/organizations` | |
| `ad_accounts` | `GET /v1/organizations/{organization_id}/adaccounts` | `organizations` |
| `campaigns` | `GET /v1/adaccounts/{ad_account_id}/campaigns` | `ad_accounts` |
| `ad_squads` | `GET /v1/adaccounts/{ad_account_id}/adsquads` | `ad_accounts` |
| `ads` | `GET /v1/adaccounts/{ad_account_id}/ads` | `ad_accounts` |
| `creatives` | `GET /v1/adaccounts/{ad_account_id}/creatives` | `ad_accounts` |
| `media` | `GET /v1/adaccounts/{ad_account_id}/media` | `ad_accounts` |
| `segments` | `GET /v1/adaccounts/{ad_account_id}/segments` | `ad_accounts` |

### Stats

| Resource | Endpoint | Parent |
| - | - | - |
| `ad_account_stats_lifetime` | `GET /v1/adaccounts/{ad_account_id}/stats` | `ad_accounts` |
| `campaign_stats_lifetime` | `GET /v1/campaigns/{campaign_id}/stats` | `campaigns` |
| `ad_squad_stats_lifetime` | `GET /v1/adsquads/{ad_squad_id}/stats` | `ad_squads` |
| `ad_stats_lifetime` | `GET /v1/ads/{ad_id}/stats` | `ads` |
| `ad_account_stats_daily` | `GET /v1/adaccounts/{ad_account_id}/stats` | `ad_accounts` |
| `campaign_stats_daily` | `GET /v1/campaigns/{campaign_id}/stats` | `campaigns` |
| `ad_squad_stats_daily` | `GET /v1/adsquads/{ad_squad_id}/stats` | `ad_squads` |
| `ad_stats_daily` | `GET /v1/ads/{ad_id}/stats` | `ads` |
| `ad_account_stats_hourly` | `GET /v1/adaccounts/{ad_account_id}/stats` | `ad_accounts` |
| `campaign_stats_hourly` | `GET /v1/campaigns/{campaign_id}/stats` | `campaigns` |
| `ad_squad_stats_hourly` | `GET /v1/adsquads/{ad_squad_id}/stats` | `ad_squads` |
| `ad_stats_hourly` | `GET /v1/ads/{ad_id}/stats` | `ads` |
| `campaign_stats_daily_report` | `GET /v1/adaccounts/{ad_account_id}/stats` with `async=true` | `ad_accounts` |
| `ad_stats_daily_report` | `GET /v1/adaccounts/{ad_account_id}/stats` with `async=true` | `ad_accounts` |

### Organization and billing

| Resource | Endpoint | Parent |
| - | - | - |
| `funding_sources` | `GET /v1/organizations/{organization_id}/fundingsources` | `organizations` |
| `billing_centers` | `GET /v1/organizations/{organization_id}/billingcenters` | `organizations` |
| `members` | `GET /v1/organizations/{organization_id}/members` | `organizations` |
| `organization_roles` | `GET /v1/organizations/{organization_id}/roles` | `organizations` |
| `ad_account_roles` | `GET /v1/adaccounts/{ad_account_id}/roles` | `ad_accounts` |
| `pixels` | `GET /v1/organizations/{organization_id}/pixels` | `organizations` |
| `mobile_apps` | `GET /v1/organizations/{organization_id}/mobile_apps` | `organizations` |
| `invoices` | `GET /v1/adaccounts/{ad_account_id}/invoices` | `ad_accounts` |

Entity resources have one row per entity, keyed by `id`. `invoices` is keyed by
`invoice_id` instead. Deleted campaigns, ad
squads, and ads are not requested. Targeting, placement, delivery status, and
other nested settings stay in JSON columns. `ad_squads` asks for `placement_v2`.

Lifetime stats have one row per entity, keyed by its ID. Snap serves lifetime
stats as finalized data only, about 48 to 72 hours behind. Daily stats have one
row per entity and day, and hourly stats have one row per entity and hour. Both
are keyed by the entity ID and `start_time`. Days and hours with no activity are
omitted. `start_time` and `end_time` are stored in UTC. For daily stats they
mark midnight in the ad account's time zone, which `ad_accounts.timezone`
records.

`campaign_stats_daily_report` and `ad_stats_daily_report` run one
[asynchronous report](https://developers.snap.com/api/marketing-api/Ads-API/measurement#asynchronous-reporting-requests)
per ad account, broken down by campaign or by ad at daily granularity. Each row
is one line of Snap's CSV file, parsed into a JSON object in `raw` that maps
each column header to its value as a string, next to `ad_account_id`. Snap does
not document the file's columns, so these rows have no typed metrics and no key. Use them with **full replace**, or prefer the typed
daily stats resources when a window of 31 days or less is enough.

Ad account stats report spend only. Campaign, ad squad, and ad stats request a
fixed set of delivery, video, attachment, lens, lead, coupon, reach, install, and
conversion metrics. Conversions cover the Snap Pixel standard events other than
visits, the five custom events, and `conversion_purchases_value`. Hourly stats leave out
the reach metrics `uniques`, `frequency`, `attachment_uniques`,
`attachment_frequency`, `total_reach`, and `earned_reach`, which Snap does not
serve by the hour. Every stats request sets a 28-day swipe attribution window, a
1-day view attribution window, and conversion-time reporting, which are Snap's
defaults. Metrics that do not apply to an ad's type are null.

Monetary values such as `spend` and `daily_budget_micro` are in micro-currency of
the ad account's currency, where 1,000,000 equals one unit. Invoice amounts are in
cents. IDs are stored as strings. Optional fields are nullable, timestamps include
time zones, and the `raw` column keeps fields that aren't mapped to their own
columns.

`funding_sources` includes card brand, the last four card digits, and expiry for
card funding sources. `members` includes member email addresses.

## Modes

All resources support full reads. Use **full upsert** to refresh existing rows,
or **full replace** to also remove rows Snap no longer returns.

Incremental reads are not supported. Entity lists have no updated-since filter.
Daily stats, hourly stats, and stats reports read the configured window on every
run, because Snap requires an end time for daily and hourly data and the
connector has no way to name the current day. For daily and hourly stats, move
the window forward and use full upsert to build history. Rerun at least the last
3 days to pick up finalized delivery metrics. Stats request conversion-time
reporting, so a conversion counts on the day it happens rather than on the day
of the swipe or view it is attributed to. The attribution window does not by
itself call for a longer rerun.

The report resources have no key, so use full replace for them. Each run then
overwrites the previous report window, and keeping report history needs storage
outside this pipeline.

## Behavior

* **Auth.** Every request sends a bearer access token obtained from the refresh
  token at `accounts.snapchat.com`.
* **Pagination.** Lists request 500 entities per page and follow
  `paging.next_link` until it is absent. Stats requests cover one entity each.
* **Fan-out.** Stats make one request per selected entity. Ad squad and ad
  stats can take a long time on large accounts, hourly stats most of all.
  Stats reports make one job per ad account instead.
* **Report jobs.** Each report job is created once, then polled every 15
  seconds until Snap marks it completed, for up to an hour. The CSV is
  downloaded from `data-transfer.snapads.com` without credentials. Any status
  other than started, running, or completed fails the read. An interrupted run
  resumes polling the jobs it already created. A run that stops while a job is
  being created cannot tell whether Snap created it, so the next run fails until
  the saved state is reset. Filament also lists the parent
  entities a selected child needs, even when the parent isn't selected.
* **Rate limiting.** Five requests per second, below Snap's documented limit of
  10 per token. Throttled requests are retried.
* **Errors.** A response that carries an `error_code` fails the read. Snap
  rejects stats responses that are too large with error `E9001`. A shorter
  window makes each response smaller.
* **Item status.** Snap wraps each listed entity with its own
  `sub_request_status`, which lands in the `sub_request_status` column. The
  connector does not check it, because Snap's examples spell success as both
  `SUCCESS` and `success`. A failed item that still carries its entity is
  written as a row, so filter on that column if you need only successful items.
  A failed item without its entity fails the read.

This version covers the Ads API entity hierarchy, delivery stats, and account
administration. Breakdowns by geography or demographics, conversion breakouts
by source, SKAdNetwork metrics, creative and media stats, audit logs, catalogs
and product feeds, lead form submissions, previews, and targeting reference data
are outside its scope. Creative and media stats are unavailable for some creative
and media types that the lists return, so a fan-out over every creative would
fail. The Conversions API, Public Profile API, and MMM API are separate products.


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