# Facebook Ad Details (`facebook.ad_details`)

One Meta Ad Library ad by id or URL: advertiser, creative text, call to action, platforms, run dates and media.

Docs: https://primaryapi.com/docs/api-reference/facebook/ad_details

- Endpoint: `POST https://api.primaryapi.com/v1/run/facebook.ad_details`
- Category: Web Intelligence · Platform: `facebook` · Kind: lookup · Status: live
- Price: 2 credits per call. Every call costs the same, including calls that were retried automatically.
- Billing unit: per successful call
- Reliability: routed to a healthy upstream and retried automatically when an attempt fails; live 30-day status: `GET https://api.primaryapi.com/v1/status/apis?sku=facebook.ad_details`
- Execution: synchronous (answers 202 only if it outlives the wait window)

## Input

| Field | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
| `id` | string | no |  | pattern: ^\d{5,25}$ | Meta Ad Library archive id: the number after ?id= in an Ad Library URL (e.g. "962050096457659"). Provide id or url. |
| `url` | string | no |  | max 2048 chars; pattern: ^https?:\/\/(?:[a-z0-9-]+\.)*facebook\.com\/ads\/library\/?\?(?:[^#]*&)?id=\d+ | Meta Ad Library ad URL (e.g. "https://www.facebook.com/ads/library?id=1185617869915074"). Provide id or url. |

Unknown fields are rejected with `400 invalid_input`. The routing controls `preferLatencyUnderMs` and `maxCredits` may be sent in the same JSON body.

## Output

When `output.found` is `true`, `output.data` has this shape:

| Field | Type | Description |
|---|---|---|
| `id` | string | Ad Library archive id (ad_archive_id) |
| `adArchiveId` | string | Same value as id (AnyAPI field name) |
| `active` | boolean \| null | Ad was delivering when scraped |
| `pageId` | string \| null | Advertiser page id |
| `pageName` | string \| null |  |
| `pageUrl` | string \| null |  |
| `pageProfilePicture` | string \| null |  |
| `pageLikes` | integer \| null |  |
| `pageCategories` | string[] |  |
| `pageDeleted` | boolean \| null |  |
| `text` | string \| null | Primary ad copy |
| `body` | string \| null | Same value as text (AnyAPI field name) |
| `title` | string \| null | Headline |
| `caption` | string \| null | Display domain / link caption |
| `linkDescription` | string \| null |  |
| `linkUrl` | string \| null | Landing page URL |
| `ctaText` | string \| null |  |
| `ctaType` | string \| null |  |
| `displayFormat` | string \| null | IMAGE, VIDEO, CAROUSEL, DCO, … |
| `type` | enum \| null | video when the creative has a video, else image when it has one |
| `image` | string \| null | First image (or video preview image) URL |
| `videoUrl` | string \| null | First video URL |
| `creatives` | object[] \| null | Per-card / per-version creative of multi-version ads ([] for single-creative ads, null when unknown) |
| `creatives[].body` | string \| null |  |
| `creatives[].title` | string \| null |  |
| `creatives[].caption` | string \| null |  |
| `creatives[].linkDescription` | string \| null |  |
| `creatives[].linkUrl` | string \| null |  |
| `creatives[].ctaText` | string \| null |  |
| `creatives[].ctaType` | string \| null |  |
| `creatives[].image` | string \| null | Full-size image URL (expiring CDN link) |
| `creatives[].imageResized` | string \| null |  |
| `creatives[].videoUrl` | string \| null | HD video URL when available, else SD |
| `creatives[].videoPreviewImage` | string \| null |  |
| `media` | object[] |  |
| `media[].type` | enum |  |
| `media[].url` | string \| null | Image URL, or the preview image of a video |
| `media[].videoUrl` | string \| null |  |
| `startDate` | integer \| null | Delivery start, Unix seconds |
| `endDate` | integer \| null | Delivery end, Unix seconds; null while the ad is running |
| `platforms` | string[] | FACEBOOK, INSTAGRAM, MESSENGER, AUDIENCE_NETWORK, THREADS |
| `isReshared` | boolean \| null |  |
| `adCount` | integer \| null | Ads sharing this creative (collation_count) |
| `currency` | string \| null | Only disclosed for political / social-issue ads |
| `categories` | string[] \| null | Special ad categories, when the source exposes them |
| `sourceUrl` | string | Ad Library permalink |
| `url` | string | Same value as sourceUrl (AnyAPI field name) |

When the thing you asked about does not exist (or a search matches nothing) the call still succeeds: `output.found` is `false`, `output.data` is `null` and `output.reason` says why (`not_found`, `private`, `no_results`, …). Misses are free unless the notes below say misses are billed.

## Example request

```bash
curl -sS -X POST "https://api.primaryapi.com/v1/run/facebook.ad_details" \
  -H "Authorization: Bearer $PRIMARYAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"id":"1016451784037642"}'
```

## Example response

_Values are placeholders that follow the output schema; `credits` is what this call would cost at the usual price._

```json
{
  "output": {
    "found": true,
    "data": {
      "id": "1016451784037642",
      "adArchiveId": "string",
      "active": true,
      "pageId": "string",
      "pageName": "string",
      "pageUrl": "https://example.com",
      "pageProfilePicture": "string",
      "pageLikes": 0,
      "pageCategories": [
        "string"
      ],
      "pageDeleted": true,
      "text": "string",
      "body": "string",
      "title": "string",
      "caption": "string",
      "linkDescription": "string",
      "linkUrl": "https://example.com",
      "ctaText": "string",
      "ctaType": "string",
      "displayFormat": "string",
      "type": "image",
      "image": "string",
      "videoUrl": "https://example.com",
      "creatives": [
        {
          "body": "string",
          "title": "string",
          "caption": "string",
          "linkDescription": "string",
          "linkUrl": "https://example.com",
          "ctaText": "string",
          "ctaType": "string",
          "image": "string",
          "imageResized": "string",
          "videoUrl": "https://example.com",
          "videoPreviewImage": "string"
        }
      ],
      "media": [
        {
          "type": "image",
          "url": "https://example.com",
          "videoUrl": "https://example.com"
        }
      ],
      "startDate": 0,
      "endDate": 0,
      "platforms": [
        "string"
      ],
      "isReshared": true,
      "adCount": 0,
      "currency": "string",
      "categories": [
        "string"
      ],
      "sourceUrl": "https://example.com",
      "url": "https://example.com"
    }
  },
  "provider": "PrimaryAPI",
  "credits": 2,
  "items": 1,
  "requestId": "req_01JBXK6Y2N9V8T4R3Q2P1M0A7Z"
}
```

## Pricing and reliability

- Usual price: 2 credits per call
- Price ceiling: the usual price, even when a call is retried. A quote’s `maxCredits` is the most a given call can cost; the `maxCredits` routing control caps it per call
- Live 30-day status, success rate, uptime and latency: `GET https://api.primaryapi.com/v1/status/apis?sku=facebook.ad_details`

## Errors to handle

`invalid_input`, `unauthorized`, `insufficient_balance`, `key_limit_reached`, `trial_cap_reached`, `forbidden`, `not_found`, `idempotency_conflict`, `rate_limited`, `all_sources_failed`, `service_unavailable`, `timeout`. See https://primaryapi.com/docs/errors.

## Notes

Ad media URLs are expiring CDN links; ad creative belongs to the advertiser: expose URLs only.

