{
  "openapi": "3.1.0",
  "info": {
    "title": "Reportei Connect API",
    "version": "1.0.0",
    "description": "Collect metrics from social networks, ad platforms, CRMs and e-commerces through a single API, without implementing OAuth for any of them.\n\n## The model\n\n```\nmerchant  →  customers  →  integration session  →  metrics\n```\n\n- **merchant** is the account that integrates. One API key, which authenticates everything.\n- **customer** is each of the merchant's customers. Created through the API, and each one has its own token.\n- **integration session** is the temporary link where the customer authorizes their accounts.\n- **metrics** are requested by stating which of that customer's connections you want to read.\n\nWhat is available to request doesn't depend on any customer: `GET /integrations` lists the platforms and `GET /metrics/{integration_slug}` lists the metrics of each one.\n\n## Authentication\n\nTwo headers, which are not the same thing. `Authorization: Bearer` identifies the merchant and goes on every request. `x-customer-token` restricts the call to one customer, and applies only to the endpoints marked with it. Getting this distinction wrong is the most common cause of 401 in this API.\n\nThe customer token is returned **only once**, at creation. No endpoint retrieves it.\n\n## Errors\n\nThis API uses **three** different error envelopes, and the distinction is observable:\n\n| Source | Body |\n|---|---|\n| Form Request validation | `{\"errors\": {\"field\": [\"message\"]}}` |\n| Validation thrown outside the Form Request (metrics) | `{\"message\": \"...\", \"extra\": ...}` |\n| Everything else | `{\"message\": \"...\"}` |\n\nBranch on the HTTP status, and on a 422 check which of the two keys came back.\n\n**An unknown resource responds 403, not 404.** The ownership check (`model_merchant_permission`) doesn't distinguish \"doesn't exist\" from \"isn't yours\", and responds `This action is unauthorized.` in both cases.\n\n## Webhooks\n\nRegister addresses at `/webhooks/endpoints` (up to 5 per account) and choose the events. Each delivery is a `POST` with the `WebhookEvent` body, and `data.object` is the resource as its `GET` returns it.\n\n**Verify the signature before trusting the body.** The `Connect-Signature` header carries `t=<unix>,v1=<hex>`. Compute `HMAC-SHA256(secret, \"{t}.{body}\")` over the received bytes, without reformatting the JSON, compare in constant time against each `v1` (in the 24 hours after a rotation there are two) and reject a `t` more than 5 minutes off from your clock.\n\nDelivery is *at least once* with no guaranteed order: deduplicate by the event `id`. Respond 2xx within 10 seconds. Any other response, including a redirect, counts as a failure, and the event is resent over about 3 days (5 min, 30 min, 2 h, 6 h, 12 h, 24 h and 24 h). An endpoint that keeps failing nonstop for 72 hours is deactivated, and a `410` deactivates it immediately. A failure that arrives more than 25 hours after the previous one restarts the count. Reactivate with `PUT` and `active: true`.\n\n`/webhook-subscriptions` is the previous format, without a body signature, and is deprecated.\n\n## Limits\n\nThe rate limit is per merchant, configured per account, and returns 429. Beyond that, an account whose trial has ended without payment gets 403 across the whole API.\n\nDuring the trial, specific limits apply: up to 5 connected accounts in total (deleting a connection doesn't free the slot), an account that another non-paying merchant connected during their trial can't be connected, metrics accept a `start` of up to 62 days back and up to 15 items in `metrics` per request, and there is a quota of 60 metrics requests per minute and 200 per day. Each refusal carries its own `error_code`: `trial_connection_limit`, `trial_account_in_use`, `trial_history_limit`, `trial_metrics_limit` and `trial_quota_exceeded`. Subscribing to a plan removes all of them.",
    "contact": {
      "name": "Reportei",
      "url": "https://lp.connect.reportei.com"
    }
  },
  "servers": [
    {
      "url": "https://connect.reportei.com/api",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Merchant",
      "description": "The account that integrates"
    },
    {
      "name": "Merchant credentials",
      "description": "Your own Meta app, registered per integration, issuing your customers' new connections. Also your OpenAI, Anthropic or Meta API key for the LLM gateway, under `openai`, `anthropic` and `meta` (the key for Meta's Model API, for the Muse models, not the Meta app used by the integrations). Applies to `facebook_ads`, `facebook` and `instagram_business` (Facebook Login, with the Meta app's App ID and App Secret) and to `instagram` (Instagram Login, with the Instagram app's App ID and App Secret)."
    },
    {
      "name": "Customers",
      "description": "The merchant's customers"
    },
    {
      "name": "Customer Integrations",
      "description": "A customer's connections to the platforms"
    },
    {
      "name": "Metrics",
      "description": "Reading a connection's metrics"
    },
    {
      "name": "Ads",
      "description": "Ad management in your customers' ad accounts.\n\n**IDs.** Wherever an ads endpoint asks for an id, either the Connect `uuid` or the object's `id` works: the numeric one the ad platform gave the campaign, ad set or ad (on Meta, the same as in Ads Manager). This includes the route's `{id}`, a level's `id` in the body (`campaign: { \"id\": … }`) and filters like `campaign_id`. The `id` works for any object in the account. The `uuid` only works for those Connect stores. Responses carry both: `id` is the object's and `uuid` is Connect's, which comes back `null` when the object isn't in Connect.\n\n**Per-integration fields.** At each level, the fields every ads integration has sit at the top (`name`, `status`, `budget`, `schedule`, `targeting`…). What belongs to only one integration goes in a block named after its `integration_slug`. Today that block is `facebook_ads: { … }`. The block's content belongs to the integration and may gain new fields. Another integration will have its own block, with different fields (for example, `google_ads: { … }`), and the top-level fields stay the same. The fields and values accepted in each block are in `GET /ads/options?integration_slug=`."
    },
    {
      "name": "Posts",
      "description": "Publishing posts to your customers' accounts: Instagram, Facebook, Threads, LinkedIn, Pinterest and YouTube.\n\n**The account.** Every route states which account it acts on in one of two ways, never both:\n\n- by connection: `?customer_integration={uuid}` in the query, the same `uuid` as in `GET /customer-integrations` and the ads routes;\n- by name: `source_name` (and, on `POST /posts`, `integration_slug`). The name survives a connection being deleted and redone for the same account.\n\n**Asynchronous.** `POST /posts` saves the post and responds `202`. Publishing runs afterwards. Track it through the webhook events `post.published`, `post.partially_published` and `post.failed` (`POST /webhooks/endpoints`), or via `GET /posts/{uuid}` until `status` is `published` or `failed`.\n\n**No duplicates.** The `Idempotency-Key` protects against repeating the same request. The `external_reference`, the post's id in your system, protects against the same post being sent again with another key: while a post with the same reference is publishing or has already been published on the same account, the new one is refused with `409`.\n\n**Errors.** Branch on `error_code`, never on the message."
    },
    {
      "name": "Media",
      "description": "Files you upload once and use by URL in posts and ads. Connect stores the file and returns a URL on `file.connect.reportei.com`, a domain the networks accept, including those that only pull media from a verified domain. Anyone with the URL can read the file, so only pass it to whoever will publish it.\n\n**Two ways to upload.** Up to 8 MB, in a single request: `POST /media` with the file in `multipart/form-data`. Above that, in parts: `POST /media/uploads` opens the upload and tells you the size of each part, `PUT /media/uploads/{uuid}/parts/{n}` sends each one (part 1 first) and `POST /media/uploads/{uuid}/complete` assembles the file.\n\n**The type comes from the file.** Connect reads the first bytes; the name and extension decide nothing. It accepts JPEG, PNG, WebP, GIF (up to 30 MB), MP4 and MOV (up to 1 GB), and checks the whole file before accepting it.\n\n**Limits.** Up to 20 open uploads per customer and a daily volume per account; above that, `429` with `media_too_many_uploads` or `media_daily_limit`.\n\n**30 days.** The URL is valid until `expires_at`, 30 days after the media becomes ready, and is always the same for the same media. After that the file is deleted. Use the URL in `POST /posts` (`media[].url`) and in ads (`media[].url`) within that window.\n\n**No duplicates.** `POST /media` and `POST /media/uploads` require `Idempotency-Key`. Same key and same request: `200` with the stored media and `Idempotent-Replay: true`. Same key with a different request: `422 idempotency_key_reused`.\n\n**Errors.** Branch on `error_code`, never on the message."
    },
    {
      "name": "Toolkits",
      "description": "Apps reached through toolkits: one spec per app, a generic engine, and actions executed on demand with the end customer's credential. Covers the long tail of apps that aren't metrics platforms: no collection, no webhooks and without the depth of a native integration. A toolkit with `oauth2` mode has no Reportei app: it only connects through the merchant's OAuth app, registered beforehand at `POST /merchants/credentials/{toolkit_slug}` (the `/merchants/credentials` route, with the toolkit slug in place of the `integration_slug`); without that registration, an OAuth-only toolkit refuses the session with 422 `toolkit_credential_missing`, and a toolkit with both modes shows the key form."
    },
    {
      "name": "LLM",
      "description": "OpenAI, Anthropic and Meta (Muse) models through a single API, **in the OpenAI API format**, with the same Connect API key. **Each call uses your own provider key:** the gateway never calls a provider with a Reportei key, and usage is billed to your provider account. Register the key at `POST /merchants/credentials/openai`, `POST /merchants/credentials/anthropic` or `POST /merchants/credentials/meta`. Meta's `-contributor` models cost less because Meta uses their prompts and responses to train its models.\n\n**With the OpenAI SDK.** Point `baseURL` to `https://connect.reportei.com/api/llm`, use the Connect key as `apiKey` and swap `model` for the `id` of a model from `GET /llm/models` (for example `anthropic/claude-sonnet-5-5`). `client.models.list()` and `client.chat.completions.create()` work without adaptation.\n\n```ts\nconst client = new OpenAI({ apiKey: process.env.CONNECT_API_TOKEN, baseURL: \"https://connect.reportei.com/api/llm\" });\nconst stream = await client.chat.completions.create({ model: \"anthropic/claude-sonnet-5-5\", max_tokens: 1024, stream: true, messages: [{ role: \"user\", content: \"Summarize the account's week.\" }] });\n```\n\n**Access.** The gateway is open to every account and only works with its key: without the provider key for a model, the call responds `400 llm_credential_missing`. By default the account uses all active models, with a cap of 4096 on `max_tokens` and up to 4 concurrent calls; support can adjust these limits or turn the gateway off for an account (`403 llm_not_enabled`).\n\n**Per merchant.** Only the API key, no `x-customer-token`: usage and cost belong to the account.\n\n**Errors.** This tag's refusals come in the OpenAI error format, `{\"error\": {\"message\", \"type\", \"code\"}}`, which the OpenAI SDK reads. Branch on `error.code`. Authentication (`401`), account payment (`403 merchant_access_denied`) and rate limit (`429`) refusals are the same as in the rest of the API, in the `{\"message\"}` format."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/merchants/settings": {
      "get": {
        "tags": ["Merchant"],
        "operationId": "getMerchantSettings",
        "summary": "The account, its limits and the enabled platforms",
        "description": "The smoke test of a new integration: 200 here means the key is valid, the account is active and the API is responding.\n\n`available_integrations` is what the merchant's plan enables: what they can offer their customers.\n\nThe platform's full catalog, enabled or not, is at `GET /integrations`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The account and its settings",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["merchant", "include_settings"],
                  "properties": {
                    "merchant": {
                      "$ref": "#/components/schemas/MerchantSettings"
                    },
                    "include_settings": {
                      "type": "boolean",
                      "const": true,
                      "description": "Constant. Signals that the payload carries the settings block; not a decision field."
                    }
                  }
                },
                "example": {
                  "merchant": {
                    "uuid": "c1e6c85a-6441-4107-ab36-b8bf581b40e0",
                    "name": "Reportei",
                    "app_url": "https://reportei.com",
                    "redirect_url": "https://reportei.com/callback",
                    "logo_url": null,
                    "trial_ends_at": "2026-09-16T17:15:12.000000Z",
                    "is_paying": true,
                    "created_at": "2026-09-02 17:07:26",
                    "updated_at": "2026-09-02 17:07:26",
                    "rate_limit_per_minute": "300",
                    "rate_limit_per_second": "10",
                    "total_customers": 2,
                    "available_integrations": [
                      {
                        "name": "Instagram Business",
                        "slug": "instagram_business"
                      },
                      {
                        "name": "Meta Ads",
                        "slug": "facebook_ads"
                      }
                    ]
                  },
                  "include_settings": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/merchants/stats": {
      "get": {
        "tags": ["Merchant"],
        "operationId": "getMerchantStats",
        "summary": "Account totals",
        "description": "How many customers, connections (and how many of them expired), posts and ads your account has in Connect, counted at request time. There is no period: these are all-time totals.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The account totals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MerchantStats"
                    }
                  }
                },
                "example": {
                  "data": {
                    "customers": 1,
                    "customer_integrations": 3,
                    "expired_customer_integrations": 1,
                    "posts": {
                      "total": 12,
                      "published": 9,
                      "failed": 1
                    },
                    "ads": {
                      "total": 7,
                      "failed": 1
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/merchants/posts": {
      "get": {
        "tags": ["Posts"],
        "operationId": "listMerchantPosts",
        "summary": "Lists the posts of all your customers",
        "description": "Your account overview: the posts of all your customers, most recent first, with just the API key, no `x-customer-token`. `customer` and `customer_integration` narrow the list; filters combine.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MerchantCustomer"
          },
          {
            "$ref": "#/components/parameters/MerchantCustomerIntegration"
          },
          {
            "name": "external_reference",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["created", "publishing", "published", "failed"]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 15
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "The posts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PostsPost"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "description": "The `customer` or `customer_integration` isn't yours, or the connection doesn't belong to the given customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "This action is unauthorized."
                }
              }
            }
          },
          "422": {
            "description": "An invalid filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "status": ["The selected status is invalid."]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/merchants/ads/campaigns": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listMerchantAdsCampaigns",
        "summary": "Lists the campaigns of all your customers",
        "description": "Your account overview: what Connect stores, like `source=connect` on `GET /ads/campaigns`, across all your customers and with just the API key, no `x-customer-token`.\n\n`customer` and `customer_integration` narrow the list. `refresh=true` requires `customer_integration`, because it rereads the account through that connection; without it, the response shows the last known state (`synced_at`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MerchantCustomer"
          },
          {
            "$ref": "#/components/parameters/MerchantCustomerIntegration"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filters by the last known status.",
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          },
          {
            "$ref": "#/components/parameters/AdsEffectiveStatus"
          },
          {
            "name": "include_deleted",
            "in": "query",
            "required": false,
            "description": "Includes deleted ones, with `deleted_at`.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/AdsPerPage"
          },
          {
            "$ref": "#/components/parameters/MerchantAdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "Lists the campaigns of all your customers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "links", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AdsCampaign"
                      }
                    },
                    "links": {
                      "$ref": "#/components/schemas/AdsPageLinks"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AdsPageMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "120250000000000001",
                      "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                      "customer_uuid": "0b6e1c2a-3f4d-4e5f-8a9b-1c2d3e4f5a6b",
                      "customer_integration_uuid": "5d7e8f9a-0b1c-4d2e-9f3a-4b5c6d7e8f90",
                      "origin": "created",
                      "synced_at": "2026-11-19T10:00:00-03:00",
                      "deleted_at": null,
                      "name": "Black Friday",
                      "status": "paused",
                      "effective_status": "paused",
                      "issues": [],
                      "budget": {
                        "amount": 50,
                        "type": "daily",
                        "level": "campaign",
                        "currency": "BRL"
                      },
                      "adsets_count": 1,
                      "facebook_ads": {
                        "objective": "traffic",
                        "spend_cap": null,
                        "bid_strategy": "lowest_cost"
                      },
                      "created_at": "2026-11-19T10:00:00-0300",
                      "updated_at": "2026-11-19T10:00:00-0300"
                    }
                  ],
                  "links": {
                    "first": "https://connect.reportei.com/api/merchants/ads/campaigns?page=1",
                    "last": "https://connect.reportei.com/api/merchants/ads/campaigns?page=1",
                    "prev": null,
                    "next": null
                  },
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/merchants/ads/campaigns",
                    "per_page": 15,
                    "to": 1,
                    "total": 1
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key. With `refresh=true`, also when the connection's customer is out of trial and not marked as paying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "no_key": {
                    "value": {
                      "message": "Unauthenticated."
                    }
                  },
                  "trial_ended": {
                    "value": {
                      "message": "Customer trial ended, mark them as paying to continue using resource"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The `customer` or `customer_integration` isn't yours, or the connection doesn't belong to the given customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsError"
                },
                "example": {
                  "message": "This action is unauthorized.",
                  "error_code": "forbidden"
                }
              }
            }
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/merchants/ads/adsets": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listMerchantAdsAdsets",
        "summary": "Lists the ad sets of all your customers",
        "description": "Your account overview: what Connect stores, like `source=connect` on `GET /ads/adsets`, across all your customers and with just the API key, no `x-customer-token`.\n\n`customer` and `customer_integration` narrow the list. `refresh=true` requires `customer_integration`, because it rereads the account through that connection; without it, the response shows the last known state (`synced_at`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MerchantCustomer"
          },
          {
            "$ref": "#/components/parameters/MerchantCustomerIntegration"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filters by the last known status.",
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          },
          {
            "$ref": "#/components/parameters/AdsEffectiveStatus"
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "The campaign `id` or the Connect `uuid`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "required": false,
            "description": "Includes deleted ones, with `deleted_at`.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/AdsPerPage"
          },
          {
            "$ref": "#/components/parameters/MerchantAdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "Lists the ad sets of all your customers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "links", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AdsAdset"
                      }
                    },
                    "links": {
                      "$ref": "#/components/schemas/AdsPageLinks"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AdsPageMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "120250000000000002",
                      "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                      "customer_uuid": "0b6e1c2a-3f4d-4e5f-8a9b-1c2d3e4f5a6b",
                      "customer_integration_uuid": "5d7e8f9a-0b1c-4d2e-9f3a-4b5c6d7e8f90",
                      "origin": "created",
                      "synced_at": "2026-11-19T10:00:00-03:00",
                      "deleted_at": null,
                      "campaign_id": "120250000000000001",
                      "name": "BR 25-45",
                      "status": "paused",
                      "effective_status": "paused",
                      "issues": [],
                      "budget": null,
                      "schedule": {
                        "start": "2026-11-20T00:00:00-0300",
                        "end": null
                      },
                      "targeting": {
                        "countries": ["BR"],
                        "age_min": 25,
                        "age_max": 45,
                        "genders": ["all"]
                      },
                      "facebook_ads": {
                        "optimization_goal": "link_clicks",
                        "billing_event": "impressions",
                        "bid_strategy": null,
                        "bid_amount": null,
                        "placements": {},
                        "targeting": {
                          "interests": [],
                          "custom_audiences": [],
                          "excluded_custom_audiences": [],
                          "advantage_audience": false,
                          "raw": {}
                        }
                      },
                      "created_at": "2026-11-19T10:00:00-0300",
                      "updated_at": "2026-11-19T10:00:00-0300"
                    }
                  ],
                  "links": {
                    "first": "https://connect.reportei.com/api/merchants/ads/adsets?page=1",
                    "last": "https://connect.reportei.com/api/merchants/ads/adsets?page=1",
                    "prev": null,
                    "next": null
                  },
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/merchants/ads/adsets",
                    "per_page": 15,
                    "to": 1,
                    "total": 1
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key. With `refresh=true`, also when the connection's customer is out of trial and not marked as paying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "no_key": {
                    "value": {
                      "message": "Unauthenticated."
                    }
                  },
                  "trial_ended": {
                    "value": {
                      "message": "Customer trial ended, mark them as paying to continue using resource"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The `customer` or `customer_integration` isn't yours, or the connection doesn't belong to the given customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsError"
                },
                "example": {
                  "message": "This action is unauthorized.",
                  "error_code": "forbidden"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/merchants/ads": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listMerchantAds",
        "summary": "Lists the ads of all your customers",
        "description": "Your account overview: what Connect stores, like `source=connect` on `GET /ads`, across all your customers and with just the API key, no `x-customer-token`.\n\n`customer` and `customer_integration` narrow the list. `refresh=true` requires `customer_integration`, because it rereads the account through that connection; without it, the response shows the last known state (`synced_at`).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MerchantCustomer"
          },
          {
            "$ref": "#/components/parameters/MerchantCustomerIntegration"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filters by the last known status.",
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          },
          {
            "$ref": "#/components/parameters/AdsEffectiveStatus"
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "The campaign `id` or the Connect `uuid`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "adset_id",
            "in": "query",
            "required": false,
            "description": "The ad set `id` or the Connect `uuid`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "required": false,
            "description": "Includes deleted ones, with `deleted_at`.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/AdsPerPage"
          },
          {
            "$ref": "#/components/parameters/MerchantAdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "Lists the ads of all your customers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "links", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AdsAd"
                      }
                    },
                    "links": {
                      "$ref": "#/components/schemas/AdsPageLinks"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AdsPageMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "120250000000000003",
                      "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                      "customer_uuid": "0b6e1c2a-3f4d-4e5f-8a9b-1c2d3e4f5a6b",
                      "customer_integration_uuid": "5d7e8f9a-0b1c-4d2e-9f3a-4b5c6d7e8f90",
                      "origin": "created",
                      "synced_at": "2026-11-19T10:00:00-03:00",
                      "deleted_at": null,
                      "campaign_id": "120250000000000001",
                      "adset_id": "120250000000000002",
                      "name": "Black Friday, imagem",
                      "status": "active",
                      "effective_status": "pending_review",
                      "issues": [],
                      "format": "image",
                      "headline": "Black Friday",
                      "body": "Up to 50% off",
                      "description": null,
                      "link_url": "https://loja.com/bf",
                      "call_to_action": "shop_now",
                      "thumbnail_url": null,
                      "facebook_ads": {
                        "creative_id": "120250000000000004",
                        "page_id": "1068595869664481",
                        "instagram_account_id": null,
                        "post_id": null
                      },
                      "created_at": "2026-11-19T10:00:00-0300",
                      "updated_at": "2026-11-19T10:00:00-0300"
                    }
                  ],
                  "links": {
                    "first": "https://connect.reportei.com/api/merchants/ads?page=1",
                    "last": "https://connect.reportei.com/api/merchants/ads?page=1",
                    "prev": null,
                    "next": null
                  },
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/merchants/ads",
                    "per_page": 15,
                    "to": 1,
                    "total": 1
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key. With `refresh=true`, also when the connection's customer is out of trial and not marked as paying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "no_key": {
                    "value": {
                      "message": "Unauthenticated."
                    }
                  },
                  "trial_ended": {
                    "value": {
                      "message": "Customer trial ended, mark them as paying to continue using resource"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The `customer` or `customer_integration` isn't yours, or the connection doesn't belong to the given customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsError"
                },
                "example": {
                  "message": "This action is unauthorized.",
                  "error_code": "forbidden"
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/merchants/credentials/{integration_slug}": {
      "get": {
        "tags": ["Merchant credentials"],
        "operationId": "getMerchantCredential",
        "summary": "Shows the credential of an integration or toolkit",
        "description": "The app registered for this integration or toolkit, without the `client_secret`. Includes the `callback_url` that must be in the Meta app's \"Valid OAuth Redirect URIs\" (for `instagram`, in the Instagram app's \"Business login settings\") and how many active connections it has issued.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "integration_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The integration: `facebook_ads`, `facebook` and `instagram_business` (Facebook app), `instagram` (Instagram app, Instagram Login), or the `slug` of a toolkit that connects via OAuth (`oauth2` mode in `GET /toolkits`), even if disabled. Also the LLM provider `openai`, `anthropic` or `meta`, for your own LLM gateway API key. Any other responds 422."
          }
        ],
        "responses": {
          "200": {
            "description": "The credential.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "credential": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/MerchantCredential"
                        },
                        {
                          "$ref": "#/components/schemas/MerchantLlmCredential"
                        }
                      ]
                    }
                  }
                },
                "example": {
                  "credential": {
                    "integration": "facebook_ads",
                    "client_id": "1234567890123456",
                    "redirect_url": null,
                    "scopes": null,
                    "callback_url": "https://connect.reportei.com/api/oauth/facebook_ads/callback",
                    "active_connections": 3,
                    "created_at": "2026-10-13T12:00:00.000000Z",
                    "updated_at": "2026-10-13T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "No credential registered for this integration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No credential is registered for this integration",
                  "error_code": "credential_not_found"
                }
              }
            }
          },
          "422": {
            "description": "The integration doesn't accept its own credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "This integration does not accept a merchant app credential",
                  "error_code": "credential_unsupported_integration"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": ["Merchant credentials"],
        "operationId": "createMerchantCredential",
        "summary": "Registers your app for a Meta integration or an OAuth toolkit",
        "description": "From here on, every new connection your customers make in this integration goes through your app: the consent screen shows your brand and API usage counts against your quota. Existing connections stay on the Reportei app until they are redone. Before registering, add the `callback_url` returned here to your Meta app's \"Valid OAuth Redirect URIs\" (for `instagram`, to the Instagram app's \"Business login settings\"), and don't enable \"Require App Secret\". Connect doesn't verify or renew the tokens your app issues, and Meta's user token lasts about 60 days: when Meta invalidates one, the connection stays `active` and collection comes back empty until the customer reconnects. For a toolkit with `oauth2` mode, this registration comes before the first session: the toolkit has no Reportei app, and the `callback_url` returned here is the redirect URL to register in the toolkit's OAuth app (the app's documentation, at `docs_url`, says where). One credential per integration or toolkit: to replace it, use `PUT`.\n\n**LLM provider (`openai`, `anthropic`, `meta`).** The body is just `api_key`, your API key with the provider. The LLM gateway only calls a provider with your key: without it, `POST /llm/chat/completions` responds `400 llm_credential_missing`. The key is stored encrypted, never returned (the response carries only the last 4 characters in `api_key_hint`) and usage is billed to your provider account.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "integration_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The integration: `facebook_ads`, `facebook` and `instagram_business` (Facebook app), `instagram` (Instagram app, Instagram Login), or the `slug` of an enabled toolkit that connects via OAuth (`oauth2` mode in `GET /toolkits`). Also the LLM provider `openai`, `anthropic` or `meta`, for your own LLM gateway API key. Any other responds 422."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": ["client_id", "client_secret"],
                    "properties": {
                      "client_id": {
                        "type": "string",
                        "maxLength": 255,
                        "description": "Your Meta app's App ID; for `instagram`, the Instagram app's."
                      },
                      "client_secret": {
                        "type": "string",
                        "maxLength": 255,
                        "description": "Your Meta app's App Secret; for `instagram`, the Instagram app's. Stored encrypted and never returned."
                      },
                      "redirect_url": {
                        "type": ["string", "null"],
                        "format": "uri",
                        "maxLength": 2048,
                        "description": "Only if you prefer to receive the callback on your domain and redirect from there to the `callback_url`. Must be `https`. If blank, Meta redirects straight to the `callback_url`."
                      },
                      "scopes": {
                        "type": ["array", "null"],
                        "items": {
                          "type": "string"
                        },
                        "description": "Replaces the entire list of permissions requested at consent, including publishing ones. If blank, the default list applies."
                      }
                    }
                  },
                  {
                    "$ref": "#/components/schemas/MerchantLlmCredentialInput"
                  }
                ]
              },
              "example": {
                "client_id": "1234567890123456",
                "client_secret": "3f1c...a9e2"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "credential": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/MerchantCredential"
                        },
                        {
                          "$ref": "#/components/schemas/MerchantLlmCredential"
                        }
                      ]
                    }
                  }
                },
                "example": {
                  "credential": {
                    "integration": "facebook_ads",
                    "client_id": "1234567890123456",
                    "redirect_url": null,
                    "scopes": null,
                    "callback_url": "https://connect.reportei.com/api/oauth/facebook_ads/callback",
                    "active_connections": 3,
                    "created_at": "2026-10-13T12:00:00.000000Z",
                    "updated_at": "2026-10-13T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "409": {
            "description": "A credential already exists for this integration. Replace it with `PUT` or remove it with `DELETE`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "A credential is already registered for this integration",
                  "error_code": "credential_already_exists"
                }
              }
            }
          },
          "422": {
            "description": "**Two envelopes.** A rule failure returns `errors`. An integration outside the accepted ones (`facebook_ads`, `facebook`, `instagram_business`, `instagram` or an enabled toolkit that connects via OAuth), or an account that can't have its own credential (`credential_not_available`), returns `message` and `error_code`.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                },
                "example": {
                  "message": "This integration does not accept a merchant app credential",
                  "error_code": "credential_unsupported_integration"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "tags": ["Merchant credentials"],
        "operationId": "replaceMerchantCredential",
        "summary": "Replaces the credential of an integration or toolkit",
        "description": "Full replacement: missing `redirect_url` and `scopes` revert to the defaults. **Changing the `client_id` means changing apps**, so every active connection issued by the previous app is marked `expired` and must be redone by the customer; the total comes in `invalidated_connections`. A new `client_secret` for the same app (resetting the secret in the Meta dashboard) invalidates nothing, and neither does changing only `redirect_url` or `scopes`: it applies to subsequent connections. For `openai`, `anthropic` and `meta`, replaces the API key; there is no connection to invalidate.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "integration_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The integration: `facebook_ads`, `facebook` and `instagram_business` (Facebook app), `instagram` (Instagram app, Instagram Login), or the `slug` of a toolkit that connects via OAuth (`oauth2` mode in `GET /toolkits`), even if disabled. Also the LLM provider `openai`, `anthropic` or `meta`, for your own LLM gateway API key. Any other responds 422."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": ["client_id", "client_secret"],
                    "properties": {
                      "client_id": {
                        "type": "string",
                        "maxLength": 255,
                        "description": "Your Meta app's App ID; for `instagram`, the Instagram app's."
                      },
                      "client_secret": {
                        "type": "string",
                        "maxLength": 255,
                        "description": "Your Meta app's App Secret; for `instagram`, the Instagram app's. Stored encrypted and never returned."
                      },
                      "redirect_url": {
                        "type": ["string", "null"],
                        "format": "uri",
                        "maxLength": 2048,
                        "description": "Only if you prefer to receive the callback on your domain and redirect from there to the `callback_url`. Must be `https`. If blank, Meta redirects straight to the `callback_url`."
                      },
                      "scopes": {
                        "type": ["array", "null"],
                        "items": {
                          "type": "string"
                        },
                        "description": "Replaces the entire list of permissions requested at consent, including publishing ones. If blank, the default list applies."
                      }
                    }
                  },
                  {
                    "$ref": "#/components/schemas/MerchantLlmCredentialInput"
                  }
                ]
              },
              "example": {
                "client_id": "1234567890123456",
                "client_secret": "3f1c...a9e2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Replaced.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "credential": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/MerchantCredential"
                        },
                        {
                          "$ref": "#/components/schemas/MerchantLlmCredential"
                        }
                      ]
                    },
                    "invalidated_connections": {
                      "type": "integer",
                      "description": "How many active connections issued by the previous app were marked `expired`."
                    }
                  }
                },
                "example": {
                  "credential": {
                    "integration": "facebook_ads",
                    "client_id": "1234567890123456",
                    "redirect_url": null,
                    "scopes": null,
                    "callback_url": "https://connect.reportei.com/api/oauth/facebook_ads/callback",
                    "active_connections": 3,
                    "created_at": "2026-10-13T12:00:00.000000Z",
                    "updated_at": "2026-10-13T12:00:00.000000Z"
                  },
                  "invalidated_connections": 3
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "No credential registered for this integration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No credential is registered for this integration",
                  "error_code": "credential_not_found"
                }
              }
            }
          },
          "422": {
            "description": "**Two envelopes.** A rule failure returns `errors`. An integration outside the accepted ones (`facebook_ads`, `facebook`, `instagram_business`, `instagram` or a toolkit that connects via OAuth), or an account that can't have its own credential (`credential_not_available`), returns `message` and `error_code`.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                },
                "example": {
                  "message": "This integration does not accept a merchant app credential",
                  "error_code": "credential_unsupported_integration"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "tags": ["Merchant credentials"],
        "operationId": "deleteMerchantCredential",
        "summary": "Removes the credential of an integration or toolkit",
        "description": "Goes back to using the Reportei app for new connections. Every active connection issued by your app is marked `expired` and must be redone by the customer; the total comes in `invalidated_connections`. For `openai`, `anthropic` and `meta`, removes the API key, and LLM gateway calls to that provider's models start responding `400 llm_credential_missing`; the response doesn't include `invalidated_connections`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "integration_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The integration: `facebook_ads`, `facebook` and `instagram_business` (Facebook app), `instagram` (Instagram app, Instagram Login), or the `slug` of a toolkit that connects via OAuth (`oauth2` mode in `GET /toolkits`), even if disabled. Also the LLM provider `openai`, `anthropic` or `meta`, for your own LLM gateway API key. Any other responds 422."
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["message"],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "invalidated_connections": {
                      "type": "integer",
                      "description": "How many active connections issued by the app were marked `expired`."
                    }
                  }
                },
                "example": {
                  "message": "Credential removed",
                  "invalidated_connections": 3
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "No credential registered for this integration.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No credential is registered for this integration",
                  "error_code": "credential_not_found"
                }
              }
            }
          },
          "422": {
            "description": "The integration doesn't accept its own credential.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "This integration does not accept a merchant app credential",
                  "error_code": "credential_unsupported_integration"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/integrations": {
      "get": {
        "tags": ["Merchant"],
        "operationId": "listIntegrations",
        "summary": "The Connect platform catalog",
        "description": "Everything Connect can collect, enabled for this account or not. What the merchant's plan enables is in `available_integrations` of `/merchants/settings`, and that subset is what they can offer their customers.\n\nEach item's `slug` is what `GET /metrics/{integration_slug}` takes, and what the integration session accepts in `available_integrations`.\n\nIt's a complete list, with no pagination.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Integration"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": 1,
                      "name": "Instagram Business",
                      "slug": "instagram_business",
                      "type": 1,
                      "color": "#FC4ADE",
                      "icon": {
                        "name": "social.instagram_business",
                        "color": "pink-600"
                      },
                      "enabled": true,
                      "created_at": "2024-09-13 14:12:56",
                      "updated_at": "2024-09-13 14:12:56"
                    },
                    {
                      "id": 3,
                      "name": "Meta Ads",
                      "slug": "facebook_ads",
                      "type": 3,
                      "color": "#0668E1",
                      "icon": {
                        "name": "social.meta_ads",
                        "color": "indigo-600"
                      },
                      "enabled": true,
                      "created_at": "2024-09-13 14:12:56",
                      "updated_at": "2024-09-13 14:12:56"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customers": {
      "get": {
        "tags": ["Customers"],
        "operationId": "listCustomers",
        "summary": "Lists the merchant's customers",
        "description": "Always restricted to the authenticated account's customers.\n\nBesides the documented parameters, any table column name works as a `LIKE` filter. This is generic behavior of the listing layer, not a contract. Don't build your integration on it.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PerPage"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/Descending"
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "description": "Partial filter by customer name.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of customers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Customer"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "uuid": "caedbbbe-7d93-476f-b965-bf97cd7ce874",
                      "name": "Cliente 1",
                      "created_at": "2026-09-02 17:07:34",
                      "updated_at": "2026-09-02 17:07:34",
                      "trial_ends_at": "2026-09-16 17:07:34",
                      "is_paying": true,
                      "merchant": "Reportei"
                    }
                  ],
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/customers",
                    "per_page": 15,
                    "to": 1,
                    "total": 1,
                    "sortBy": null,
                    "descending": false
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": ["Customers"],
        "operationId": "createCustomer",
        "summary": "Creates a customer",
        "description": "**The response carries `api_token`, and this is the only time it appears.** It is the value of that customer's `x-customer-token` header. No other endpoint returns it, and there is no way to recover it. Persist it alongside the customer record, in the same transaction in which you create it.\n\nThe customer is created with `is_paying` true. Merchants still billed per paying customer (legacy) get it false, with a 14-day trial in `trial_ends_at`, and change it through the payment status endpoint.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "Customer name. Doesn't need to be unique."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "name": "Cliente 1"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Customer created. **Contains the customer token.**",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer"],
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerCreated"
                    }
                  }
                },
                "example": {
                  "customer": {
                    "uuid": "caedbbbe-7d93-476f-b965-bf97cd7ce874",
                    "name": "Cliente 1",
                    "created_at": "2026-09-02 17:07:34",
                    "updated_at": "2026-09-02 17:07:34",
                    "trial_ends_at": "2026-09-16 17:07:34",
                    "is_paying": true,
                    "merchant": "Reportei",
                    "api_token": "8f14e45fceea167a5a36dedd4bea2543a1b2c3d4e5f60718293a4b5c6d7e8f90"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "422": {
            "description": "Validation. `is_paying`, `trial_ends_at` and `api_token` belong to the server and are refused if sent: payment status has its own endpoint, the trial is fixed at creation and the token is generated by Connect.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "examples": {
                  "missing_name": {
                    "value": {
                      "message": "The given data was invalid.",
                      "error_code": "validation_error",
                      "errors": {
                        "name": ["The name field is required."]
                      }
                    }
                  },
                  "forbidden_field": {
                    "value": {
                      "message": "The given data was invalid.",
                      "error_code": "validation_error",
                      "errors": {
                        "is_paying": ["The is paying field is prohibited."],
                        "trial_ends_at": [
                          "The trial ends at field is prohibited."
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customers/settings": {
      "get": {
        "tags": ["Customers"],
        "operationId": "getCustomerSettings",
        "summary": "The token's customer, with their connections",
        "description": "Identifies the customer by the `x-customer-token`, so it takes no uuid. It's the way to discover what the customer connected and the `uuid` of each connection, which is what the metrics endpoints ask for.\n\nUnlike the session and metrics endpoints, this one **keeps responding** for a customer whose trial has ended.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The customer and their connections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer", "include_settings"],
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/CustomerWithIntegrations"
                    },
                    "include_settings": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                },
                "example": {
                  "customer": {
                    "uuid": "073c1e15-94d0-49b3-9861-a0e9b7ffb06c",
                    "name": "Cliente 1",
                    "created_at": "2026-09-02 19:06:08",
                    "updated_at": "2026-09-02 19:06:08",
                    "trial_ends_at": "2026-09-16 19:06:08",
                    "is_paying": true,
                    "merchant": "Reportei",
                    "integrations": [
                      {
                        "uuid": "6110b666-0327-4a81-b48e-9feb34d72f78",
                        "integration": "Instagram Business",
                        "name": "reportei",
                        "slug": "instagram_business",
                        "status": "active",
                        "icon": {
                          "name": "social.instagram_business",
                          "color": "pink-600"
                        }
                      }
                    ]
                  },
                  "include_settings": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerTokenError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customers/{uuid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/CustomerUuid"
        }
      ],
      "get": {
        "tags": ["Customers"],
        "operationId": "getCustomer",
        "summary": "A customer",
        "description": "The data of one of your customers, by `uuid`. Doesn't include connections. For that, use `GET /customer-integrations` with the customer's token, or `GET /customers/integrations` to see all of them at once.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The customer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer"],
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "tags": ["Customers"],
        "operationId": "updateCustomer",
        "summary": "Renames a customer",
        "description": "`name` is required on `PATCH` too: there is no partial update.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  }
                }
              },
              "example": {
                "name": "Novo nome"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated customer. Without `api_token`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer"],
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "422": {
            "description": "Validation. As on creation, `is_paying`, `trial_ends_at` and `api_token` are refused if sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "tags": ["Customers"],
        "operationId": "patchCustomer",
        "summary": "Renames a customer",
        "description": "Identical to `PUT` on this same route: the application registers both verbs on the same handler.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  }
                }
              },
              "example": {
                "name": "Novo nome"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The updated customer. Without `api_token`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer"],
                  "properties": {
                    "customer": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "422": {
            "description": "Validation. As on creation, `is_paying`, `trial_ends_at` and `api_token` are refused if sent.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "tags": ["Customers"],
        "operationId": "deleteCustomer",
        "summary": "Removes a customer and their connections",
        "description": "Irreversible, and cascades to the connections. That customer's token stops working.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Removed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessMessage"
                },
                "example": {
                  "success": true,
                  "message": "Record successfully removed"
                }
              }
            }
          },
          "400": {
            "description": "The removal failed in the database",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FailureMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customers/{uuid}/update-payment-status": {
      "parameters": [
        {
          "$ref": "#/components/parameters/CustomerUuid"
        }
      ],
      "post": {
        "tags": ["Customers"],
        "operationId": "updateCustomerPaymentStatus",
        "summary": "Marks the customer as paying, or unmarks them",
        "deprecated": true,
        "description": "**Legacy:** only for merchants still billed per paying customer. For every other merchant the customer is created as paying.\n\nThis is how a legacy customer stays accessible after the 14-day trial.\n\n**Not idempotent, by API design:** sending the state the customer already has responds 422. Read the current state first, or treat the 422 as \"it was already like that\".",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["is_paying"],
                "properties": {
                  "is_paying": {
                    "type": "boolean",
                    "description": "Must differ from the customer's current state."
                  }
                }
              },
              "example": {
                "is_paying": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Status changed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessMessage"
                },
                "example": {
                  "success": true,
                  "message": "Customer is now marked as a paying customer"
                }
              }
            }
          },
          "400": {
            "description": "The change failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FailureMessage"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "422": {
            "description": "Validation, including the repeated state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "is_paying": ["The customer is already marked as paying."]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customer-integrations/session": {
      "post": {
        "tags": ["Customer Integrations"],
        "operationId": "createIntegrationSession",
        "summary": "Opens the screen where the customer authorizes their accounts",
        "description": "Returns `session_link`. Send the customer to that URL: that's where they log in to the platform and choose the accounts, without you implementing OAuth.\n\n**Each call invalidates the previous session** for that merchant/customer pair. Don't open two in parallel for the same customer.\n\nThe session expires in 5 minutes by default, and `expires_in_minutes` adjusts that.\n\nDuring the trial, the merchant connects up to 5 accounts in total, and deleting a connection doesn't free the slot. An account that another non-paying merchant connected during their trial is refused. The refusal shows up for the customer in the session itself.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "requestBody": {
          "required": false,
          "description": "All fields are optional. An empty body is valid.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntegrationSessionRequest"
              },
              "examples": {
                "minimal": {
                  "value": {}
                },
                "with_limits": {
                  "summary": "Restricting what the customer sees and how many accounts they connect",
                  "value": {
                    "redirect_url": "https://sua-aplicacao.com/dashboard",
                    "locale": "pt_BR",
                    "close_on_finish": true,
                    "limits": [
                      {
                        "name": "integration_count",
                        "value": 3
                      },
                      {
                        "name": "available_integrations",
                        "value": ["instagram_business", "facebook_ads"]
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Session opened",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["integration_session"],
                  "properties": {
                    "integration_session": {
                      "$ref": "#/components/schemas/IntegrationSession"
                    }
                  }
                },
                "example": {
                  "integration_session": {
                    "session_uuid": "b1f0f8e0-3a1e-4a1b-9c2d-7e8f90a1b2c3",
                    "session_link": "https://connect.reportei.com/customer-integrations/session/b1f0f8e0-3a1e-4a1b-9c2d-7e8f90a1b2c3",
                    "expires_at": "2026-09-02T17:12:26.000000Z",
                    "merchant": "Reportei",
                    "merchant_uuid": "c1e6c85a-6441-4107-ab36-b8bf581b40e0",
                    "customer": "Cliente 1",
                    "customer_uuid": "caedbbbe-7d93-476f-b965-bf97cd7ce874",
                    "redirect_url": "https://sua-aplicacao.com/dashboard",
                    "close_on_finish": true,
                    "locale": "pt_BR",
                    "limits": [
                      {
                        "name": "integration_count",
                        "value": 3
                      }
                    ],
                    "limit_reached_url": null,
                    "enable_multi_account_selection": false
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "422": {
            "description": "Validation, or a `toolkit_slug` that only connects via OAuth without the merchant's credential registered for it (`error_code` `toolkit_credential_missing`, `MessageError` envelope).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                },
                "examples": {
                  "validation": {
                    "value": {
                      "errors": {
                        "toolkit_slug": [
                          "The selected toolkit slug is invalid."
                        ]
                      }
                    }
                  },
                  "no_credential": {
                    "value": {
                      "message": "Toolkit 'google_calendar' connects with OAuth and needs your app credential, registered at /merchants/credentials/google_calendar.",
                      "error_code": "toolkit_credential_missing"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customer-integrations": {
      "get": {
        "tags": ["Customer Integrations"],
        "operationId": "listCustomerIntegrations",
        "summary": "Lists the customer's connections",
        "description": "The connections of the `x-customer-token`'s customer, and the only way to discover each one's `uuid`, which is what the metrics endpoints ask for. Call this endpoint after the customer returns from the authorization session.\n\nBesides the documented parameters, any table column name works as a `LIKE` filter. This is generic behavior of the listing layer, not a contract. Don't build your integration on it.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/PerPage"
          },
          {
            "$ref": "#/components/parameters/SortBy"
          },
          {
            "$ref": "#/components/parameters/Descending"
          },
          {
            "name": "source_name",
            "in": "query",
            "required": false,
            "description": "Partial filter by the connected account's name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by connection state.",
            "schema": {
              "$ref": "#/components/schemas/IntegrationStatus"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Page of connections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomerIntegration"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "uuid": "4addc0da-8583-4dbb-a0e9-c7e2e8470f50",
                      "source_id": "17841400000000000",
                      "source_name": "reportei",
                      "status": "active",
                      "created_at": "2026-09-02 17:08:08",
                      "updated_at": "2026-09-02 17:08:08",
                      "email": null,
                      "profile_picture_url": null,
                      "integration": {
                        "name": "Instagram Business",
                        "slug": "instagram_business"
                      }
                    }
                  ],
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/customer-integrations",
                    "per_page": 15,
                    "to": 1,
                    "total": 1,
                    "sortBy": null,
                    "descending": false
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerTokenError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customer-integrations/{uuid}": {
      "parameters": [
        {
          "$ref": "#/components/parameters/IntegrationUuid"
        }
      ],
      "get": {
        "tags": ["Customer Integrations"],
        "operationId": "getCustomerIntegration",
        "summary": "A customer connection",
        "description": "The connection must belong to the `x-customer-token`'s customer.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The connection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer_integration"],
                  "properties": {
                    "customer_integration": {
                      "$ref": "#/components/schemas/CustomerIntegration"
                    }
                  }
                },
                "example": {
                  "customer_integration": {
                    "uuid": "4addc0da-8583-4dbb-a0e9-c7e2e8470f50",
                    "source_id": "17841400000000000",
                    "source_name": "reportei",
                    "status": "active",
                    "created_at": "2026-09-02 17:08:08",
                    "updated_at": "2026-09-02 17:08:08",
                    "email": null,
                    "profile_picture_url": null,
                    "integration": {
                      "name": "Instagram Business",
                      "slug": "instagram_business"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerTokenError"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "tags": ["Customer Integrations"],
        "operationId": "deleteCustomerIntegration",
        "summary": "Removes a customer connection",
        "description": "**This endpoint authenticates differently from all the others.** It doesn't use `Authorization: Bearer` or `x-customer-token`: authorization is the integration session, passed in `session_id` in the query string. It's the endpoint the authorization screen itself calls, and the connection must belong to that session's customer.\n\nWithout a valid, unexpired `session_id`, it responds 401.",
        "security": [],
        "parameters": [
          {
            "name": "session_id",
            "in": "query",
            "required": true,
            "description": "`session_uuid` of a valid, unexpired integration session.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Removed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessMessage"
                },
                "example": {
                  "success": true,
                  "message": "Record successfully removed"
                }
              }
            }
          },
          "400": {
            "description": "Removal failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FailureMessage"
                }
              }
            }
          },
          "401": {
            "description": "Session missing, invalid, or expired",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Session is expired or invalid"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          }
        }
      }
    },
    "/metrics/{integration_slug}": {
      "get": {
        "tags": ["Metrics"],
        "operationId": "listMetricDefinitions",
        "summary": "The metrics a platform offers",
        "description": "A platform's catalog: every available `reference_key`, with its default `component`, `metrics`, and `dimensions`. **Each item in `data` is already a valid MetricRequestItem**: copy it into `metrics[]` of `/metrics/get-data` and the query works. To request a different value or breakdown, swap `metrics`/`dimensions` for keys from `meta.setup`.\n\nMerchant key only: the catalog is the same for every customer and every connection. Find the `integration_slug` in `GET /integrations` or in the `slug` of the customer's connections.\n\nThe response is stable for weeks and cached on the Connect side, so fetch it once and store it, not on every metric query.\n\nAn account may have metrics restricted by contract; in that case `/metrics/get-data` refuses the key with 422 and names it in the message. The catalog does not reflect that restriction.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "integration_slug",
            "in": "path",
            "required": true,
            "description": "The platform's `slug`, as returned by `GET /integrations`.",
            "schema": {
              "type": "string"
            },
            "example": "facebook_ads"
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Language of `references` and of the `label` values in `meta.setup`. Does not change any key.",
            "schema": {
              "type": "string",
              "enum": ["en", "pt_br", "es", "fr", "it", "de"],
              "default": "en"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The platform catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MetricDefinition"
                      }
                    },
                    "meta": {
                      "type": "object",
                      "required": ["integration_slug", "language", "setup"],
                      "properties": {
                        "integration_slug": {
                          "type": "string"
                        },
                        "language": {
                          "type": "string"
                        },
                        "setup": {
                          "$ref": "#/components/schemas/MetricDefinitionsSetup"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "c45d148c-0d07-4473-b7d7-f886c8b56884",
                      "reference_key": "fb_ads:spend",
                      "component": "number_v1",
                      "metrics": ["spend"],
                      "dimensions": [],
                      "references": {
                        "title": "Amount spent",
                        "description": "The total estimated amount you spent on your campaign, ad set, or ad during its schedule.",
                        "tags": {
                          "cost": "pago",
                          "history": "retroativo"
                        }
                      }
                    },
                    {
                      "id": "80e06171-759e-472e-9cff-25ae8e91e1e0",
                      "reference_key": "fb_ads:insights_by_campaign",
                      "component": "datatable_v1",
                      "metrics": [
                        "results",
                        "cost_per_results",
                        "spend",
                        "reach",
                        "impressions",
                        "ctr",
                        "cpc",
                        "cpm",
                        "frequency"
                      ],
                      "dimensions": [
                        {
                          "field": "campaign"
                        }
                      ],
                      "references": {
                        "title": "Top campaigns",
                        "description": "Campaigns that had the greatest impact on your audience in the analyzed period.",
                        "tags": {
                          "cost": "pago",
                          "history": "retroativo"
                        }
                      }
                    }
                  ],
                  "meta": {
                    "integration_slug": "facebook_ads",
                    "language": "pt_br",
                    "setup": {
                      "metrics": {
                        "spend": {
                          "label": "Amount spent"
                        },
                        "results": {
                          "label": "Resultados"
                        },
                        "reach": {
                          "label": "Alcance"
                        },
                        "impressions": {
                          "label": "Impressions"
                        }
                      },
                      "dimensions": {
                        "campaign": {
                          "label": "Campaign Name"
                        },
                        "publisher_platform": {
                          "label": "Plataforma"
                        },
                        "date": {
                          "label": "Data"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "404": {
            "description": "Slug that does not exist in the catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["message", "error_code"],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string",
                      "const": "not_found"
                    }
                  }
                },
                "example": {
                  "message": "Integration slug 'meta_ads' not found",
                  "error_code": "not_found"
                }
              }
            }
          },
          "422": {
            "description": "`language` not in the accepted list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "language": ["The selected language is invalid."]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "The catalog could not be read right now. Nothing was cached; try again shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Metric catalog is temporarily unavailable, please try again"
                }
              }
            }
          }
        }
      }
    },
    "/metrics/get-data": {
      "post": {
        "tags": ["Metrics"],
        "operationId": "getMetrics",
        "summary": "Reads metrics from one or more connections",
        "description": "Synchronous. For long periods or many metrics, prefer the async version: here the request stays open while collection happens.\n\nSend **either** `customer_integration` (one connection) **or** `customer_integration_uuids` (several). All must belong to the customer of the `x-customer-token`.\n\nThe shape of each metric depends on the requested `component`, so the response payload is open: each item's key is the `id` you sent, and the value is that metric's result.\n\nThe available `reference_key` values vary by platform. Find them in `GET /metrics/{integration_slug}`: each item there already comes in the shape this endpoint accepts in `metrics[]`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MetricsRequest"
              },
              "example": {
                "customer_integration": "4addc0da-8583-4dbb-a0e9-c7e2e8470f50",
                "start": "2026-08-01",
                "end": "2026-08-31",
                "metrics": [
                  {
                    "id": "f35a44ce-dac5-4188-aace-5c44a8952176",
                    "reference_key": "ig:story_replies",
                    "component": "number_v1",
                    "metrics": ["replies"],
                    "dimensions": ["stories"]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The metrics, keyed by the `id` you sent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "object",
                      "description": "Map from metric `id` to its result. The result's shape depends on the `component`. When a single metric fails on its own, the value is an error object instead of the result (see MetricFailure).",
                      "additionalProperties": {
                        "description": "That metric's result, shaped by the requested `component`, or a failure object when only that metric failed.",
                        "anyOf": [
                          {
                            "$ref": "#/components/schemas/MetricFailure"
                          },
                          {
                            "description": "The metric's result, in the `component`'s format."
                          }
                        ]
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "f35a44ce-dac5-4188-aace-5c44a8952176": {
                      "value": 128,
                      "previous_value": 96
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Collection failed. This API wraps any unexpected failure here, so the message is the only detail.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Unexpected response from API, please try again"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "422": {
            "description": "Validation. **Two possible envelopes here**, and they differ: body rules return `errors`, while refusals for metric access, expired token, or trial history return `message`, with `extra` or `error_code`.\n\nOn trial, `start` can go back at most 62 days and `metrics` accepts up to 15 items (columns inside an item don't count). An older `start` responds `error_code` `trial_history_limit`, and more than 15 items respond `trial_metrics_limit`.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MetricsValidationError"
                    }
                  ]
                },
                "examples": {
                  "invalid_body": {
                    "value": {
                      "message": "The given data was invalid.",
                      "error_code": "validation_error",
                      "errors": {
                        "start": ["The start field is required."]
                      }
                    }
                  },
                  "connection_token_expired": {
                    "summary": "The connection must be reauthorized by the customer",
                    "value": {
                      "message": "Customer integration needs to be reintegrated, token is invalid or expired",
                      "error_code": "integration_expired",
                      "extra": {
                        "integration_status": "expired"
                      }
                    }
                  },
                  "history_beyond_trial": {
                    "summary": "On trial, the period starts earlier than allowed",
                    "value": {
                      "message": "Trial limit: metrics can be read up to 62 days back, so start must be on or after 2026-08-21. Subscribe to a plan to read the full history.",
                      "error_code": "trial_history_limit",
                      "max_history_days": 62,
                      "oldest_start": "2026-08-21"
                    }
                  },
                  "metrics_beyond_trial": {
                    "summary": "On trial, the request has more metrics than allowed",
                    "value": {
                      "message": "Trial limit: up to 15 metrics per request. Subscribe to a plan to request more.",
                      "error_code": "trial_metrics_limit",
                      "max_metrics": 15
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/MetricsRateLimited"
          }
        }
      }
    },
    "/metrics/get-data-async": {
      "post": {
        "tags": ["Metrics"],
        "operationId": "getMetricsAsync",
        "summary": "Requests metrics and receives them by webhook",
        "description": "Responds immediately and delivers the metrics later, in a `POST` to `metrics_webhook_url`. This is the recommended path for long periods.\n\nThe body delivered to your webhook is the metrics map at the root, **without** the `data` envelope the synchronous version uses.\n\nThe webhook URL is validated against internal network addresses, so it must be publicly reachable.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/MetricsRequest"
                  },
                  {
                    "type": "object",
                    "required": ["metrics_webhook_url"],
                    "properties": {
                      "metrics_webhook_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Must be http or https and point to a public address. Private IPs, loopback, and link-local are refused."
                      }
                    }
                  }
                ]
              },
              "example": {
                "metrics_webhook_url": "https://sua-aplicacao.com/webhooks/metricas",
                "customer_integration": "4addc0da-8583-4dbb-a0e9-c7e2e8470f50",
                "start": "2026-08-01",
                "end": "2026-08-31",
                "metrics": [
                  {
                    "id": "f35a44ce-dac5-4188-aace-5c44a8952176",
                    "reference_key": "ig:story_replies",
                    "component": "number_v1",
                    "metrics": ["replies"]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted. The metrics arrive at the webhook.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessMessage"
                },
                "example": {
                  "success": true,
                  "message": "Metrics will be sent to your webhook"
                }
              }
            }
          },
          "400": {
            "description": "Collection failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "422": {
            "description": "Validation. On trial, a `start` older than 62 days responds `message` with `error_code` `trial_history_limit`, and more than 15 items in `metrics` respond `trial_metrics_limit`, as in the synchronous version.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MetricsValidationError"
                    }
                  ]
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "metrics_webhook_url": [
                      "The metrics webhook url points to a restricted network address."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/MetricsRateLimited"
          }
        }
      }
    },
    "/ads/options": {
      "get": {
        "tags": ["Ads"],
        "operationId": "getAdsOptions",
        "summary": "The vocabulary of an ads integration",
        "description": "What the integration accepts, level by level: the values of the common fields and the block only it knows. Does not depend on a connection.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "integration_slug",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["facebook_ads"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The vocabulary",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsOptions"
                },
                "example": {
                  "data": {
                    "integration_slug": "facebook_ads",
                    "budget": {
                      "levels": ["campaign", "adset"],
                      "types": ["daily", "lifetime"]
                    },
                    "common": {
                      "format": ["image", "video"]
                    },
                    "facebook_ads": {
                      "campaign": {
                        "objective": ["traffic"]
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/campaigns": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsCampaigns",
        "summary": "Lists campaigns",
        "description": "Reads from the Connect database by default (`source=connect`): what Connect created or has already written in this account, like `GET /posts`. With `source=external`, reads the account live.\n\n`include_deleted` only exists with `source=connect`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsSource"
          },
          {
            "$ref": "#/components/parameters/AdsEffectiveStatus"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "With `source=connect`, filters by the last known status. With `source=external`, by the current status, and the page may return slightly more than `per_page`.",
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "required": false,
            "description": "Includes deleted ones, with `deleted_at`.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/AdsPerPage"
          },
          {
            "$ref": "#/components/parameters/AdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "Lists campaigns",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "links", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AdsCampaign"
                      }
                    },
                    "links": {
                      "$ref": "#/components/schemas/AdsPageLinks"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AdsPageMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "120250000000000001",
                      "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                      "origin": "created",
                      "synced_at": "2026-11-19T10:00:00-03:00",
                      "deleted_at": null,
                      "name": "Black Friday",
                      "status": "paused",
                      "effective_status": "paused",
                      "budget": {
                        "amount": 50,
                        "type": "daily",
                        "level": "campaign",
                        "currency": "BRL"
                      },
                      "adsets_count": 1,
                      "facebook_ads": {
                        "objective": "traffic",
                        "spend_cap": null,
                        "bid_strategy": "lowest_cost"
                      },
                      "created_at": "2026-11-19T10:00:00-0300",
                      "updated_at": "2026-11-19T10:00:00-0300"
                    }
                  ],
                  "links": {
                    "first": "https://connect.reportei.com/api/ads/campaigns?page=1",
                    "last": "https://connect.reportei.com/api/ads/campaigns?page=1",
                    "prev": null,
                    "next": null
                  },
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/ads/campaigns",
                    "per_page": 15,
                    "to": 1,
                    "total": 1
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "post": {
        "tags": ["Ads"],
        "operationId": "createAdsCampaign",
        "summary": "Creates a campaign",
        "description": "Created **paused** without `status`. With `budget`, the budget sits on the campaign (CBO); without it, on each ad set (ABO).",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsCampaignInput"
              },
              "example": {
                "name": "Black Friday",
                "budget": {
                  "amount": 50,
                  "type": "daily"
                },
                "facebook_ads": {
                  "objective": "traffic",
                  "special_ad_categories": []
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Creates a campaign",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsCampaign"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "name": "Black Friday",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": {
                      "amount": 50,
                      "type": "daily",
                      "level": "campaign",
                      "currency": "BRL"
                    },
                    "adsets_count": 1,
                    "facebook_ads": {
                      "objective": "traffic",
                      "spend_cap": null,
                      "bid_strategy": "lowest_cost"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request: the body of the first response, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsCampaign"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "name": "Black Friday",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": {
                      "amount": 50,
                      "type": "daily",
                      "level": "campaign",
                      "currency": "BRL"
                    },
                    "adsets_count": 1,
                    "facebook_ads": {
                      "objective": "traffic",
                      "spend_cap": null,
                      "bid_strategy": "lowest_cost"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/campaigns/{id}": {
      "get": {
        "tags": ["Ads"],
        "operationId": "getAdsCampaign",
        "summary": "A campaign",
        "description": "From the Connect database by default; with `source=external`, live. With `source=connect`, an object Connect does not store responds 404.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsSource"
          },
          {
            "$ref": "#/components/parameters/AdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "A campaign",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsCampaign"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "name": "Black Friday",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": {
                      "amount": 50,
                      "type": "daily",
                      "level": "campaign",
                      "currency": "BRL"
                    },
                    "adsets_count": 1,
                    "facebook_ads": {
                      "objective": "traffic",
                      "spend_cap": null,
                      "bid_strategy": "lowest_cost"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "patch": {
        "tags": ["Ads"],
        "operationId": "updateAdsCampaign",
        "summary": "Updates a campaign",
        "description": "Works for any campaign in the account. One created outside Connect enters the database on this write (`origin: imported`). Budget on an ABO campaign responds `409 budget_level_mismatch`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsCampaignUpdate"
              },
              "example": {
                "status": "active"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updates a campaign",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsCampaign"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "name": "Black Friday",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": {
                      "amount": 50,
                      "type": "daily",
                      "level": "campaign",
                      "currency": "BRL"
                    },
                    "adsets_count": 1,
                    "facebook_ads": {
                      "objective": "traffic",
                      "spend_cap": null,
                      "bid_strategy": "lowest_cost"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "delete": {
        "tags": ["Ads"],
        "operationId": "deleteAdsCampaign",
        "summary": "Deletes a campaign",
        "description": "Takes its ad sets and ads with it, in the integration and in the Connect database.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Deletes a campaign",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsDeleted"
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "deleted": true
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/campaigns/{id}/duplicate": {
      "post": {
        "tags": ["Ads"],
        "operationId": "duplicateCampaign",
        "summary": "Duplicates a campaign",
        "description": "Copies the campaign **without** its ad sets and ads: the copy keeps the objective, budget level (CBO/ABO) and special categories, and gets the requested name. It is created paused; `status: active` activates it once it exists.\n\nA `budget` is only valid if the budget stays on the campaign (CBO); otherwise, `409 budget_level_mismatch`. If the budget is refused, the copy is deleted and a retry with the same key copies again.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsCampaignDuplicateRequest"
              },
              "example": {
                "name": "Black Friday | 02",
                "budget": {
                  "amount": 150,
                  "type": "daily"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Duplicates a campaign",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsCampaign"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "name": "Black Friday",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": {
                      "amount": 50,
                      "type": "daily",
                      "level": "campaign",
                      "currency": "BRL"
                    },
                    "adsets_count": 1,
                    "facebook_ads": {
                      "objective": "traffic",
                      "spend_cap": null,
                      "bid_strategy": "lowest_cost"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request: the body of the first response, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsCampaign"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "uuid": "9a1d3f52-7c1e-4c55-9b0e-5c3f1c6a2e10",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "name": "Black Friday",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": {
                      "amount": 50,
                      "type": "daily",
                      "level": "campaign",
                      "currency": "BRL"
                    },
                    "adsets_count": 1,
                    "facebook_ads": {
                      "objective": "traffic",
                      "spend_cap": null,
                      "bid_strategy": "lowest_cost"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/adsets/{id}/duplicate": {
      "post": {
        "tags": ["Ads"],
        "operationId": "duplicateAdset",
        "summary": "Duplicates an ad set",
        "description": "Copies the ad set **without** its ads, into the `campaign_id` campaign (or into its own campaign, without it). Audience, placements, optimization and promoted object come from the source; name, budget and schedule can change. It is created paused; `status: active` activates it once it exists.\n\nA `budget` is only valid if the target campaign doesn't hold the budget (ABO); otherwise, `409 budget_level_mismatch`. If the budget or schedule is refused, the copy is deleted.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsAdsetDuplicateRequest"
              },
              "example": {
                "name": "Warm audience | 02",
                "campaign_id": "120250000000000001",
                "budget": {
                  "amount": 50,
                  "type": "daily"
                },
                "schedule": {
                  "start": "2026-11-20T00:00:00-03:00"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Duplicates an ad set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAdset"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000002",
                    "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "name": "BR 25-45",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": null,
                    "schedule": {
                      "start": "2026-11-20T00:00:00-0300",
                      "end": null
                    },
                    "targeting": {
                      "countries": ["BR"],
                      "age_min": 25,
                      "age_max": 45,
                      "genders": ["all"]
                    },
                    "facebook_ads": {
                      "optimization_goal": "link_clicks",
                      "billing_event": "impressions",
                      "bid_strategy": null,
                      "bid_amount": null,
                      "placements": {},
                      "targeting": {
                        "interests": [],
                        "custom_audiences": [],
                        "excluded_custom_audiences": [],
                        "advantage_audience": false,
                        "raw": {}
                      }
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request: the body of the first response, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAdset"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000002",
                    "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "name": "BR 25-45",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": null,
                    "schedule": {
                      "start": "2026-11-20T00:00:00-0300",
                      "end": null
                    },
                    "targeting": {
                      "countries": ["BR"],
                      "age_min": 25,
                      "age_max": 45,
                      "genders": ["all"]
                    },
                    "facebook_ads": {
                      "optimization_goal": "link_clicks",
                      "billing_event": "impressions",
                      "bid_strategy": null,
                      "bid_amount": null,
                      "placements": {},
                      "targeting": {
                        "interests": [],
                        "custom_audiences": [],
                        "excluded_custom_audiences": [],
                        "advantage_audience": false,
                        "raw": {}
                      }
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/adsets": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsAdsets",
        "summary": "Lists ad sets",
        "description": "Reads from the Connect database by default (`source=connect`): what Connect created or has already written in this account, like `GET /posts`. With `source=external`, reads the account live.\n\n`include_deleted` only exists with `source=connect`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsSource"
          },
          {
            "$ref": "#/components/parameters/AdsEffectiveStatus"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "With `source=connect`, filters by the last known status. With `source=external`, by the current status, and the page may return slightly more than `per_page`.",
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "The campaign `id` or the Connect `uuid`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "required": false,
            "description": "Includes deleted ones, with `deleted_at`.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/AdsPerPage"
          },
          {
            "$ref": "#/components/parameters/AdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "Lists ad sets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "links", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AdsAdset"
                      }
                    },
                    "links": {
                      "$ref": "#/components/schemas/AdsPageLinks"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AdsPageMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "120250000000000002",
                      "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                      "origin": "created",
                      "synced_at": "2026-11-19T10:00:00-03:00",
                      "deleted_at": null,
                      "campaign_id": "120250000000000001",
                      "name": "BR 25-45",
                      "status": "paused",
                      "effective_status": "paused",
                      "budget": null,
                      "schedule": {
                        "start": "2026-11-20T00:00:00-0300",
                        "end": null
                      },
                      "targeting": {
                        "countries": ["BR"],
                        "age_min": 25,
                        "age_max": 45,
                        "genders": ["all"]
                      },
                      "facebook_ads": {
                        "optimization_goal": "link_clicks",
                        "billing_event": "impressions",
                        "bid_strategy": null,
                        "bid_amount": null,
                        "placements": {},
                        "targeting": {
                          "interests": [],
                          "custom_audiences": [],
                          "excluded_custom_audiences": [],
                          "advantage_audience": false,
                          "raw": {}
                        }
                      },
                      "created_at": "2026-11-19T10:00:00-0300",
                      "updated_at": "2026-11-19T10:00:00-0300"
                    }
                  ],
                  "links": {
                    "first": "https://connect.reportei.com/api/ads/campaigns?page=1",
                    "last": "https://connect.reportei.com/api/ads/campaigns?page=1",
                    "prev": null,
                    "next": null
                  },
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/ads/campaigns",
                    "per_page": 15,
                    "to": 1,
                    "total": 1
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "post": {
        "tags": ["Ads"],
        "operationId": "createAdsAdset",
        "summary": "Creates an ad set",
        "description": "In an existing campaign. Created **paused** without `status`. Budget on an ad set of a CBO campaign responds `409 budget_level_mismatch`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsAdsetInput"
              },
              "example": {
                "campaign_id": "120250000000000001",
                "name": "BR 25-45",
                "budget": {
                  "amount": 20,
                  "type": "daily"
                },
                "targeting": {
                  "countries": ["BR"]
                },
                "facebook_ads": {
                  "optimization_goal": "link_clicks",
                  "billing_event": "impressions"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Creates an ad set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAdset"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000002",
                    "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "name": "BR 25-45",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": null,
                    "schedule": {
                      "start": "2026-11-20T00:00:00-0300",
                      "end": null
                    },
                    "targeting": {
                      "countries": ["BR"],
                      "age_min": 25,
                      "age_max": 45,
                      "genders": ["all"]
                    },
                    "facebook_ads": {
                      "optimization_goal": "link_clicks",
                      "billing_event": "impressions",
                      "bid_strategy": null,
                      "bid_amount": null,
                      "placements": {},
                      "targeting": {
                        "interests": [],
                        "custom_audiences": [],
                        "excluded_custom_audiences": [],
                        "advantage_audience": false,
                        "raw": {}
                      }
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request: the body of the first response, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAdset"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000002",
                    "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "name": "BR 25-45",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": null,
                    "schedule": {
                      "start": "2026-11-20T00:00:00-0300",
                      "end": null
                    },
                    "targeting": {
                      "countries": ["BR"],
                      "age_min": 25,
                      "age_max": 45,
                      "genders": ["all"]
                    },
                    "facebook_ads": {
                      "optimization_goal": "link_clicks",
                      "billing_event": "impressions",
                      "bid_strategy": null,
                      "bid_amount": null,
                      "placements": {},
                      "targeting": {
                        "interests": [],
                        "custom_audiences": [],
                        "excluded_custom_audiences": [],
                        "advantage_audience": false,
                        "raw": {}
                      }
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/adsets/{id}": {
      "get": {
        "tags": ["Ads"],
        "operationId": "getAdsAdset",
        "summary": "An ad set",
        "description": "From the Connect database by default; with `source=external`, live. With `source=connect`, an object Connect does not store responds 404.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsSource"
          },
          {
            "$ref": "#/components/parameters/AdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "An ad set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAdset"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000002",
                    "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "name": "BR 25-45",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": null,
                    "schedule": {
                      "start": "2026-11-20T00:00:00-0300",
                      "end": null
                    },
                    "targeting": {
                      "countries": ["BR"],
                      "age_min": 25,
                      "age_max": 45,
                      "genders": ["all"]
                    },
                    "facebook_ads": {
                      "optimization_goal": "link_clicks",
                      "billing_event": "impressions",
                      "bid_strategy": null,
                      "bid_amount": null,
                      "placements": {},
                      "targeting": {
                        "interests": [],
                        "custom_audiences": [],
                        "excluded_custom_audiences": [],
                        "advantage_audience": false,
                        "raw": {}
                      }
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "patch": {
        "tags": ["Ads"],
        "operationId": "updateAdsAdset",
        "summary": "Updates an ad set",
        "description": "Works for any ad set in the account. Budget on an ad set of a CBO campaign responds `409 budget_level_mismatch`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsAdsetUpdate"
              },
              "example": {
                "targeting": {
                  "age_min": 30
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updates an ad set",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAdset"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000002",
                    "uuid": "1b2c3d4e-5f60-4718-8a9b-0c1d2e3f4a5b",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "name": "BR 25-45",
                    "status": "paused",
                    "effective_status": "paused",
                    "budget": null,
                    "schedule": {
                      "start": "2026-11-20T00:00:00-0300",
                      "end": null
                    },
                    "targeting": {
                      "countries": ["BR"],
                      "age_min": 25,
                      "age_max": 45,
                      "genders": ["all"]
                    },
                    "facebook_ads": {
                      "optimization_goal": "link_clicks",
                      "billing_event": "impressions",
                      "bid_strategy": null,
                      "bid_amount": null,
                      "placements": {},
                      "targeting": {
                        "interests": [],
                        "custom_audiences": [],
                        "excluded_custom_audiences": [],
                        "advantage_audience": false,
                        "raw": {}
                      }
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "delete": {
        "tags": ["Ads"],
        "operationId": "deleteAdsAdset",
        "summary": "Deletes an ad set",
        "description": "Takes its ads with it.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Deletes an ad set",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsDeleted"
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "deleted": true
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAds",
        "summary": "Lists ads",
        "description": "Reads from the Connect database by default (`source=connect`): what Connect created or has already written in this account, like `GET /posts`. With `source=external`, reads the account live.\n\n`include_deleted` only exists with `source=connect`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsSource"
          },
          {
            "$ref": "#/components/parameters/AdsEffectiveStatus"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "With `source=connect`, filters by the last known status. With `source=external`, by the current status, and the page may return slightly more than `per_page`.",
            "schema": {
              "type": "string",
              "enum": ["active", "paused"]
            }
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "The campaign `id` or the Connect `uuid`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "adset_id",
            "in": "query",
            "required": false,
            "description": "The ad set `id` or the Connect `uuid`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_deleted",
            "in": "query",
            "required": false,
            "description": "Includes deleted ones, with `deleted_at`.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          },
          {
            "$ref": "#/components/parameters/AdsPerPage"
          },
          {
            "$ref": "#/components/parameters/AdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "Lists ads",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "links", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/AdsAd"
                      }
                    },
                    "links": {
                      "$ref": "#/components/schemas/AdsPageLinks"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AdsPageMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "120250000000000003",
                      "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                      "origin": "created",
                      "synced_at": "2026-11-19T10:00:00-03:00",
                      "deleted_at": null,
                      "campaign_id": "120250000000000001",
                      "adset_id": "120250000000000002",
                      "name": "Black Friday, imagem",
                      "status": "active",
                      "effective_status": "pending_review",
                      "format": "image",
                      "headline": "Black Friday",
                      "body": "Up to 50% off",
                      "description": null,
                      "link_url": "https://loja.com/bf",
                      "call_to_action": "shop_now",
                      "thumbnail_url": null,
                      "facebook_ads": {
                        "creative_id": "120250000000000004",
                        "page_id": "1068595869664481",
                        "instagram_account_id": null,
                        "post_id": null
                      },
                      "created_at": "2026-11-19T10:00:00-0300",
                      "updated_at": "2026-11-19T10:00:00-0300"
                    }
                  ],
                  "links": {
                    "first": "https://connect.reportei.com/api/ads/campaigns?page=1",
                    "last": "https://connect.reportei.com/api/ads/campaigns?page=1",
                    "prev": null,
                    "next": null
                  },
                  "meta": {
                    "current_page": 1,
                    "from": 1,
                    "last_page": 1,
                    "path": "https://connect.reportei.com/api/ads/campaigns",
                    "per_page": 15,
                    "to": 1,
                    "total": 1
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "post": {
        "tags": ["Ads"],
        "operationId": "createAds",
        "summary": "Creates an ad and the tree above it",
        "description": "A single shape: each level uses an existing one (`{\"id\": …}`) or describes what will be created.\n\n- **Everything is created paused.** The requested `status` is applied in the last step, so a failure midway never leaves anything spending.\n- **Each id is saved as soon as the integration responds.** A retry with the same `Idempotency-Key` resumes where it stopped.\n- **Failure:** what was created is undone; what could not be comes in `created`.\n- **Video still processing:** `409 ads_video_not_ready`. Repeat with the same key: the video and the levels already created are reused.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsTreeRequest"
              },
              "example": {
                "name": "Black Friday, imagem",
                "status": "active",
                "campaign": {
                  "name": "Black Friday",
                  "budget": {
                    "amount": 50,
                    "type": "daily"
                  },
                  "facebook_ads": {
                    "objective": "traffic",
                    "special_ad_categories": []
                  }
                },
                "adset": {
                  "name": "BR 25-45",
                  "schedule": {
                    "start": "2026-11-20T00:00:00-03:00"
                  },
                  "targeting": {
                    "countries": ["BR"],
                    "age_min": 25,
                    "age_max": 45
                  },
                  "facebook_ads": {
                    "optimization_goal": "link_clicks",
                    "billing_event": "impressions",
                    "placements": {
                      "publisher_platforms": ["facebook", "instagram"]
                    },
                    "targeting": {
                      "interests": [
                        {
                          "id": "6003139266461",
                          "name": "Moda"
                        }
                      ],
                      "advantage_audience": false
                    }
                  }
                },
                "ad": {
                  "format": "image",
                  "headline": "Black Friday",
                  "body": "Up to 50% off",
                  "link_url": "https://loja.com/bf",
                  "call_to_action": "shop_now",
                  "media": [
                    {
                      "type": "image",
                      "url": "https://cdn.loja.com/bf.jpg"
                    }
                  ],
                  "facebook_ads": {
                    "page_id": "1068595869664481"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Creates an ad and the tree above it",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "active",
                    "effective_status": "pending_review",
                    "format": "image",
                    "headline": "Black Friday",
                    "body": "Up to 50% off",
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": "1068595869664481",
                      "instagram_account_id": null,
                      "post_id": null
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request: the body of the first response, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "active",
                    "effective_status": "pending_review",
                    "format": "image",
                    "headline": "Black Friday",
                    "body": "Up to 50% off",
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": "1068595869664481",
                      "instagram_account_id": null,
                      "post_id": null
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/boost": {
      "post": {
        "tags": ["Ads"],
        "operationId": "boostAdsPost",
        "summary": "Boosts a post",
        "description": "The same tree as `POST /ads`, with an ad that promotes an existing post. The creative comes from the post.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsBoostRequest"
              },
              "example": {
                "name": "Impulsionar post",
                "status": "active",
                "campaign": {
                  "facebook_ads": {
                    "objective": "engagement"
                  }
                },
                "adset": {
                  "budget": {
                    "amount": 20,
                    "type": "daily"
                  },
                  "targeting": {
                    "countries": ["BR"]
                  },
                  "facebook_ads": {
                    "optimization_goal": "post_engagement",
                    "billing_event": "impressions"
                  }
                },
                "ad": {
                  "post_id": "18191649508387596",
                  "facebook_ads": {
                    "instagram_account_id": "17841442920331135"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Boosts a post",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "active",
                    "effective_status": "pending_review",
                    "format": "post",
                    "headline": null,
                    "body": null,
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": null,
                      "instagram_account_id": "17841442920331135",
                      "post_id": "18191649508387596"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request: the body of the first response, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "active",
                    "effective_status": "pending_review",
                    "format": "post",
                    "headline": null,
                    "body": null,
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": null,
                      "instagram_account_id": "17841442920331135",
                      "post_id": "18191649508387596"
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/validate": {
      "post": {
        "tags": ["Ads"],
        "operationId": "validateAds",
        "summary": "Validates the tree without creating anything",
        "description": "The same body as `POST /ads`. The integration validates each level; those that depend on a parent that doesn't exist yet come back `skipped`. Does not record an operation and does not need an `Idempotency-Key`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsTreeRequest"
              },
              "example": {
                "name": "Black Friday, imagem",
                "status": "active",
                "campaign": {
                  "name": "Black Friday",
                  "budget": {
                    "amount": 50,
                    "type": "daily"
                  },
                  "facebook_ads": {
                    "objective": "traffic",
                    "special_ad_categories": []
                  }
                },
                "adset": {
                  "name": "BR 25-45",
                  "schedule": {
                    "start": "2026-11-20T00:00:00-03:00"
                  },
                  "targeting": {
                    "countries": ["BR"],
                    "age_min": 25,
                    "age_max": 45
                  },
                  "facebook_ads": {
                    "optimization_goal": "link_clicks",
                    "billing_event": "impressions",
                    "placements": {
                      "publisher_platforms": ["facebook", "instagram"]
                    },
                    "targeting": {
                      "interests": [
                        {
                          "id": "6003139266461",
                          "name": "Moda"
                        }
                      ],
                      "advantage_audience": false
                    }
                  }
                },
                "ad": {
                  "format": "image",
                  "headline": "Black Friday",
                  "body": "Up to 50% off",
                  "link_url": "https://loja.com/bf",
                  "call_to_action": "shop_now",
                  "media": [
                    {
                      "type": "image",
                      "url": "https://cdn.loja.com/bf.jpg"
                    }
                  ],
                  "facebook_ads": {
                    "page_id": "1068595869664481"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The result per level",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsValidation"
                },
                "example": {
                  "data": {
                    "results": [
                      {
                        "level": "campaign",
                        "status": "validated"
                      },
                      {
                        "level": "adset",
                        "status": "skipped"
                      },
                      {
                        "level": "ad",
                        "status": "skipped"
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/{id}": {
      "get": {
        "tags": ["Ads"],
        "operationId": "getAd",
        "summary": "An ad",
        "description": "From the Connect database by default; with `source=external`, live. With `source=connect`, an object Connect does not store responds 404.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsSource"
          },
          {
            "$ref": "#/components/parameters/AdsRefresh"
          }
        ],
        "responses": {
          "200": {
            "description": "An ad",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "active",
                    "effective_status": "pending_review",
                    "format": "image",
                    "headline": "Black Friday",
                    "body": "Up to 50% off",
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": "1068595869664481",
                      "instagram_account_id": null,
                      "post_id": null
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "patch": {
        "tags": ["Ads"],
        "operationId": "updateAd",
        "summary": "Updates an ad",
        "description": "Name, status, and texts. A boosted ad cannot swap its creative (`boosted_creative_not_replaceable`).",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsAdUpdate"
              },
              "example": {
                "status": "paused"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updates an ad",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "active",
                    "effective_status": "pending_review",
                    "format": "image",
                    "headline": "Black Friday",
                    "body": "Up to 50% off",
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": "1068595869664481",
                      "instagram_account_id": null,
                      "post_id": null
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      },
      "delete": {
        "tags": ["Ads"],
        "operationId": "deleteAd",
        "summary": "Deletes an ad",
        "description": "The ad set and campaign remain.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Deletes an ad",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdsDeleted"
                },
                "example": {
                  "data": {
                    "id": "120250000000000001",
                    "deleted": true
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/{id}/duplicate": {
      "post": {
        "tags": ["Ads"],
        "operationId": "duplicateAd",
        "summary": "Duplicates an ad",
        "description": "The copy is always created paused, in the same ad set.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsObjectId"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdsDuplicateRequest"
              },
              "example": {
                "name": "Black Friday, copy"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Duplicates an ad",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "paused",
                    "effective_status": "pending_review",
                    "format": "image",
                    "headline": "Black Friday",
                    "body": "Up to 50% off",
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": "1068595869664481",
                      "instagram_account_id": null,
                      "post_id": null
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request: the body of the first response, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/AdsAd"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120250000000000003",
                    "uuid": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f",
                    "origin": "created",
                    "synced_at": "2026-11-19T10:00:00-03:00",
                    "deleted_at": null,
                    "campaign_id": "120250000000000001",
                    "adset_id": "120250000000000002",
                    "name": "Black Friday, imagem",
                    "status": "paused",
                    "effective_status": "pending_review",
                    "format": "image",
                    "headline": "Black Friday",
                    "body": "Up to 50% off",
                    "description": null,
                    "link_url": "https://loja.com/bf",
                    "call_to_action": "shop_now",
                    "thumbnail_url": null,
                    "facebook_ads": {
                      "creative_id": "120250000000000004",
                      "page_id": "1068595869664481",
                      "instagram_account_id": null,
                      "post_id": null
                    },
                    "created_at": "2026-11-19T10:00:00-0300",
                    "updated_at": "2026-11-19T10:00:00-0300"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          }
        }
      }
    },
    "/ads/facebook_ads/pages": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsPages",
        "summary": "The pages the connection manages",
        "description": "Each page includes the Instagram account linked to it, which is what an ad needs to publish through both.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The pages the connection manages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Page"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "1068595869664481",
                      "name": "Reportei Sync",
                      "picture_url": "https://cdn.meta/p.png",
                      "can_post": true,
                      "instagram_account_id": "17841442920331135"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/facebook_ads/instagram-accounts": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsInstagramAccounts",
        "summary": "The ad account's Instagram accounts",
        "description": "The accounts this ad account can use to publish.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ad account's Instagram accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/InstagramAccount"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "17841442920331135",
                      "username": "reporteisync"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/facebook_ads/posts": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsPosts",
        "summary": "The organic content that can be boosted",
        "description": "Without `source`, lists **Instagram media**, the only kind `creative.source_post_id` accepts. With `source=facebook`, lists the page's posts, which work for discovery but not for boosting.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "description": "Default `instagram`.",
            "schema": {
              "type": "string",
              "enum": ["instagram", "facebook"],
              "default": "instagram"
            }
          },
          {
            "name": "instagram_account_id",
            "in": "query",
            "required": false,
            "description": "Required with `source=instagram`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page_id",
            "in": "query",
            "required": false,
            "description": "Required with `source=facebook`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The organic content that can be boosted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Post"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "18191649508387596",
                      "source": "instagram",
                      "type": "image",
                      "caption": "Post caption",
                      "permalink": "https://instagram.com/p/x",
                      "thumbnail_url": "https://cdn.ig/a.jpg",
                      "published_at": "2026-08-19T18:47:47+0000"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/facebook_ads/pixels": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsPixels",
        "summary": "The ad account's pixels",
        "description": "A pixel's `id` goes in `adset.facebook_ads.promoted_object.pixel_id` of an ad set optimized for conversion.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The ad account's pixels",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Pixel"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "900000000000001",
                      "name": "Pixel principal",
                      "last_fired_at": "2026-09-23T10:00:00-0300",
                      "created_at": "2025-01-01T00:00:00-0300",
                      "is_unavailable": false
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/facebook_ads/pixels/{id}/events": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsPixelEvents",
        "summary": "The events a pixel has recorded",
        "description": "Count over the last **90 days**, the window the integration uses so rare events don't disappear.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The pixel id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The events a pixel has recorded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PixelEvent"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "event_name": "Purchase",
                      "count": 42
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/facebook_ads/media": {
      "post": {
        "tags": ["Ads"],
        "operationId": "deliverAdsMedia",
        "summary": "Delivers a file to the ad account",
        "description": "Delivers an image or a video to the account by URL (for example, the one from `POST /media`) and returns what ads use to reference it: the image's `hash` or the video's `id`. Deliver once per account and reuse it in as many ads as you want: that's how a creative with a feed version and a story version references each file. The image is ready immediately; the video starts as `processing` and can be used when `GET /ads/facebook_ads/videos/{id}` says `ready`. Connect stores nothing: store the `hash` or the `id` yourself.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["type", "url"],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": ["image", "video"]
                  },
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "Public https address. Image: JPEG or PNG."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "Name in the account's library. Without it, the file name in the URL."
                  }
                }
              },
              "example": {
                "type": "video",
                "url": "https://midias.reportei.com/connect-media/media/2f0c.../8b1e....mp4?exp=1795000000&sig=9c1f..."
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "What references the file in ads",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": ["type", "status"],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": ["image", "video"]
                        },
                        "status": {
                          "type": "string",
                          "enum": ["ready", "processing"]
                        },
                        "hash": {
                          "type": "string",
                          "description": "Image only."
                        },
                        "id": {
                          "type": "string",
                          "description": "Video only."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "type": "video",
                    "status": "processing",
                    "id": "120210000000001"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "200": {
            "description": "Replay of the same `Idempotency-Key`: the stored response, with `Idempotent-Replay: true`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": ["type", "status"],
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": ["image", "video"]
                        },
                        "status": {
                          "type": "string",
                          "enum": ["ready", "processing"]
                        },
                        "hash": {
                          "type": "string",
                          "description": "Image only."
                        },
                        "id": {
                          "type": "string",
                          "description": "Video only."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "type": "video",
                    "status": "processing",
                    "id": "120210000000001"
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          }
        }
      }
    },
    "/ads/facebook_ads/videos/{id}": {
      "get": {
        "tags": ["Ads"],
        "operationId": "showAdsVideo",
        "summary": "The processing of a delivered video",
        "description": "Only answers for videos this account received via `POST /ads/facebook_ads/media`; any other `id` is `404`. Give the ad a video's `id` only when `status` is `ready`. `thumbnail_url` is a frame chosen by the network, used as the ad's thumbnail.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The video",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "object",
                      "required": ["id", "status", "thumbnail_url"],
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "enum": ["processing", "ready", "failed"]
                        },
                        "thumbnail_url": {
                          "type": ["string", "null"],
                          "format": "uri"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "120210000000001",
                    "status": "ready",
                    "thumbnail_url": "https://scontent.xx.fbcdn.net/v/frame.jpg"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/facebook_ads/custom-conversions": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsCustomConversions",
        "summary": "The account's custom conversions",
        "description": "A conversion's `id` goes in `adset.facebook_ads.promoted_object.custom_conversion_id`.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The account's custom conversions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomConversion"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "700000000000001",
                      "name": "Purchase completed",
                      "event_type": "other",
                      "pixel_id": "900000000000001",
                      "is_unavailable": false
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": ["Ads"],
        "operationId": "createAdsCustomConversion",
        "summary": "Creates a custom conversion",
        "description": "Defines a custom conversion by the rule that triggers it. The created conversion appears in the next listing without `refresh`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomConversionCreateRequest"
              },
              "example": {
                "name": "Purchase completed",
                "pixel_id": "900000000000001",
                "rule": {
                  "url_contains": "/obrigado"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created conversion",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CustomConversion"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "700000000000001",
                    "name": "Purchase completed",
                    "event_type": "other",
                    "pixel_id": "900000000000001",
                    "is_unavailable": false
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "200": {
            "description": "The stored replay of a previous call with the same `Idempotency-Key` and the same request, with `Idempotent-Replay: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CustomConversion"
                    }
                  }
                },
                "example": {
                  "data": {
                    "id": "700000000000001",
                    "name": "Purchase completed",
                    "event_type": "other",
                    "pixel_id": "900000000000001",
                    "is_unavailable": false
                  }
                }
              }
            },
            "headers": {
              "Idempotent-Replay": {
                "description": "`true` when the response is the stored replay of a previous call with the same `Idempotency-Key`.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/AdsConflict"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/AdsIdempotencyKeyRequired"
          }
        ]
      }
    },
    "/ads/audiences": {
      "get": {
        "tags": ["Ads"],
        "operationId": "listAdsAudiences",
        "summary": "The account's custom audiences",
        "description": "Read-only. Creating audiences and uploading user lists are not part of this version.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The account's custom audiences",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Audience"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "800000000000001",
                      "name": "Compradores 90 dias",
                      "subtype": "custom",
                      "approximate_size": {
                        "lower": 1000,
                        "upper": 2000
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/ads/targeting/search": {
      "get": {
        "tags": ["Ads"],
        "operationId": "searchAdsTargeting",
        "summary": "Searches interests, places, and behaviors",
        "description": "Resolves a term into the ids targeting expects. **This is what takes `targeting.interests` out of \"the merchant has to already know the id\".**\n\n`behavior` browses the whole list without `q`; `interest` and `geo` require the term.\n\nRead cached for 600 s per connection. **Not paginated:** the integration returns at most 200 items per resource.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AdsCustomerIntegration"
          },
          {
            "name": "type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["interest", "geo", "behavior"]
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Required for `interest` and `geo`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "country_code",
            "in": "query",
            "required": false,
            "description": "Only takes effect on `geo`.",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2,
              "pattern": "^[A-Za-z]{2}$"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "refresh",
            "in": "query",
            "required": false,
            "description": "Bypasses the cache and fetches from the integration.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Searches interests, places, and behaviors",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TargetingResult"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/DiscoveryListMeta"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "6003279598823",
                      "name": "Marketing (business and finance)",
                      "type": "interest",
                      "subtype": null,
                      "path": [
                        "Interesses",
                        "Marketing (business and finance)"
                      ],
                      "description": null,
                      "country_code": null,
                      "audience_size": {
                        "lower": 605494039,
                        "upper": 712060990
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/AdsForbidden"
          },
          "404": {
            "$ref": "#/components/responses/AdsObjectNotFound"
          },
          "422": {
            "$ref": "#/components/responses/AdsValidationError"
          },
          "4XX": {
            "$ref": "#/components/responses/AdsIntegrationRefused"
          },
          "5XX": {
            "$ref": "#/components/responses/AdsIntegrationUnavailable"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhooks/endpoints": {
      "get": {
        "tags": ["Webhooks"],
        "operationId": "listWebhookEndpoints",
        "summary": "Lists your webhook endpoints",
        "description": "The addresses your account has registered, with the health status of each. An endpoint belongs to the account, not the customer: it receives events from all your customers. Also included: the events your account can subscribe to and the endpoint limit.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The full list, no pagination: there are at most `limit` endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "available_events", "limit"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                      }
                    },
                    "available_events": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "The event types this account can subscribe to."
                    },
                    "limit": {
                      "type": "integer",
                      "description": "How many endpoints the account can have.",
                      "example": 5
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "9b2f7c1e-4a3d-4f8e-9c21-6d0a5b8e1f34",
                      "url": "https://sua-app.com/webhooks/connect",
                      "description": "Production",
                      "events": [
                        "customer_integration.status_updated",
                        "integration_session.completed"
                      ],
                      "active": true,
                      "disabled_at": null,
                      "disabled_reason": null,
                      "consecutive_failures": 0,
                      "first_failure_at": null,
                      "last_failure_at": null,
                      "last_success_at": "2026-10-13 12:00:00",
                      "created_at": "2026-10-01 09:30:00",
                      "updated_at": "2026-10-13 12:00:00"
                    }
                  ],
                  "available_events": [
                    "customer_integration.status_updated",
                    "customer_integration.deleted",
                    "integration_session.oauth_started",
                    "integration_session.oauth_saved",
                    "integration_session.completed"
                  ],
                  "limit": 5
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": ["Webhooks"],
        "operationId": "createWebhookEndpoint",
        "summary": "Registers a webhook endpoint",
        "description": "Starts delivering the chosen events to the given address. The response includes the `secret` that signs deliveries, and this is the only time it appears: store it. If you lose it, generate another with `rotate-secret`. Each account has up to 5 endpoints; beyond that, creation is refused with 422 and `error_code: validation_error`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url", "events"],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "`https` address that will receive the events. We refuse `http`, internal or private-network addresses, and the same address twice in the same account."
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "#/components/schemas/WebhookEventType"
                    },
                    "description": "Which events this address receives."
                  },
                  "description": {
                    "type": ["string", "null"],
                    "maxLength": 255,
                    "description": "A name so you can recognize the endpoint."
                  }
                }
              },
              "example": {
                "url": "https://sua-app.com/webhooks/connect",
                "events": [
                  "customer_integration.status_updated",
                  "integration_session.completed"
                ],
                "description": "Production"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered. The only response that includes the `secret`.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["webhook_endpoint"],
                  "properties": {
                    "webhook_endpoint": {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    }
                  }
                },
                "example": {
                  "webhook_endpoint": {
                    "id": "9b2f7c1e-4a3d-4f8e-9c21-6d0a5b8e1f34",
                    "url": "https://sua-app.com/webhooks/connect",
                    "description": "Production",
                    "events": [
                      "customer_integration.status_updated",
                      "integration_session.completed"
                    ],
                    "active": true,
                    "disabled_at": null,
                    "disabled_reason": null,
                    "consecutive_failures": 0,
                    "first_failure_at": null,
                    "last_failure_at": null,
                    "last_success_at": "2026-10-13 12:00:00",
                    "created_at": "2026-10-01 09:30:00",
                    "updated_at": "2026-10-13 12:00:00",
                    "secret": "whsec_q8X0m3VbT1sYwJ4nK6pZr2uLc9hE5aGf7dNtR0oIyMk"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Validation failure, or the account already has 5 endpoints.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MetricsValidationError"
                    }
                  ]
                },
                "examples": {
                  "invalid": {
                    "summary": "Field refused",
                    "value": {
                      "message": "The given data was invalid.",
                      "error_code": "validation_error",
                      "errors": {
                        "url": ["The webhook URL must use https."]
                      }
                    }
                  },
                  "limit": {
                    "summary": "Endpoint limit",
                    "value": {
                      "message": "This account already has 5 webhook endpoints, the limit. Delete one to register another.",
                      "error_code": "validation_error",
                      "extra": "default"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhooks/endpoints/{uuid}": {
      "get": {
        "tags": ["Webhooks"],
        "operationId": "getWebhookEndpoint",
        "summary": "Shows a webhook endpoint",
        "description": "The endpoint and its health status. This is where you see whether it was disabled due to failures (`disabled_reason: failures`) or for responding 410 (`gone`). The `secret` never comes back in this response.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointUuid"
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["webhook_endpoint"],
                  "properties": {
                    "webhook_endpoint": {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    }
                  }
                },
                "example": {
                  "webhook_endpoint": {
                    "id": "9b2f7c1e-4a3d-4f8e-9c21-6d0a5b8e1f34",
                    "url": "https://sua-app.com/webhooks/connect",
                    "description": "Production",
                    "events": [
                      "customer_integration.status_updated",
                      "integration_session.completed"
                    ],
                    "active": true,
                    "disabled_at": null,
                    "disabled_reason": null,
                    "consecutive_failures": 0,
                    "first_failure_at": null,
                    "last_failure_at": null,
                    "last_success_at": "2026-10-13 12:00:00",
                    "created_at": "2026-10-01 09:30:00",
                    "updated_at": "2026-10-13 12:00:00"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No results found with id ''",
                  "error_code": "model_not_found"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "tags": ["Webhooks"],
        "operationId": "updateWebhookEndpoint",
        "summary": "Changes a webhook endpoint",
        "description": "Changes the address, events, or description, or turns the endpoint on and off. `active: false` stops deliveries (`disabled_reason: manual`). `active: true` reactivates and resets the failure count, but does not resend what was lost while it was off.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointUuid"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "Same rules as creation."
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "$ref": "#/components/schemas/WebhookEventType"
                    }
                  },
                  "description": {
                    "type": ["string", "null"],
                    "maxLength": 255
                  },
                  "active": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "active": true,
                "events": ["customer_integration.status_updated"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The changed endpoint.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["webhook_endpoint"],
                  "properties": {
                    "webhook_endpoint": {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    }
                  }
                },
                "example": {
                  "webhook_endpoint": {
                    "id": "9b2f7c1e-4a3d-4f8e-9c21-6d0a5b8e1f34",
                    "url": "https://sua-app.com/webhooks/connect",
                    "description": "Production",
                    "events": [
                      "customer_integration.status_updated",
                      "integration_session.completed"
                    ],
                    "active": true,
                    "disabled_at": null,
                    "disabled_reason": null,
                    "consecutive_failures": 0,
                    "first_failure_at": null,
                    "last_failure_at": null,
                    "last_success_at": "2026-10-13 12:00:00",
                    "created_at": "2026-10-01 09:30:00",
                    "updated_at": "2026-10-13 12:00:00"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No results found with id ''",
                  "error_code": "model_not_found"
                }
              }
            }
          },
          "422": {
            "description": "Validation failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "url": ["The webhook URL must use https."]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "tags": ["Webhooks"],
        "operationId": "deleteWebhookEndpoint",
        "summary": "Removes a webhook endpoint",
        "description": "Stops delivering to this address immediately, including scheduled attempts.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointUuid"
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["success"],
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No results found with id ''",
                  "error_code": "model_not_found"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhooks/endpoints/{uuid}/rotate-secret": {
      "post": {
        "tags": ["Webhooks"],
        "operationId": "rotateWebhookEndpointSecret",
        "summary": "Generates a new secret",
        "description": "Replaces the endpoint's `secret`. The previous one stays valid for 24 hours: during that period each delivery carries two `v1` signatures in the header, one per secret, so you can switch without losing events. The response is the only one that includes the new secret.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointUuid"
          }
        ],
        "responses": {
          "200": {
            "description": "The endpoint with the new secret.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["webhook_endpoint"],
                  "properties": {
                    "webhook_endpoint": {
                      "$ref": "#/components/schemas/WebhookEndpoint"
                    }
                  }
                },
                "example": {
                  "webhook_endpoint": {
                    "id": "9b2f7c1e-4a3d-4f8e-9c21-6d0a5b8e1f34",
                    "url": "https://sua-app.com/webhooks/connect",
                    "description": "Production",
                    "events": [
                      "customer_integration.status_updated",
                      "integration_session.completed"
                    ],
                    "active": true,
                    "disabled_at": null,
                    "disabled_reason": null,
                    "consecutive_failures": 0,
                    "first_failure_at": null,
                    "last_failure_at": null,
                    "last_success_at": "2026-10-13 12:00:00",
                    "created_at": "2026-10-01 09:30:00",
                    "updated_at": "2026-10-13 12:00:00",
                    "secret": "whsec_q8X0m3VbT1sYwJ4nK6pZr2uLc9hE5aGf7dNtR0oIyMk"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No results found with id ''",
                  "error_code": "model_not_found"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhooks/endpoints/{uuid}/test": {
      "post": {
        "tags": ["Webhooks"],
        "operationId": "testWebhookEndpoint",
        "summary": "Sends a test event",
        "description": "Sends now, and waits for the response, the most recent event in your account of the first type the endpoint subscribes to, with a new `id` and marked `livemode: false`. With no event of that type in the last 30 days, `data.object` is null. Does not enter the retry cycle. If your address responds 2xx, the endpoint's failure streak is reset; if the test fails, it doesn't count. The response shows what your address returned. Limit of 10 tests per minute.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointUuid"
          }
        ],
        "responses": {
          "200": {
            "description": "The attempt, with your address's response. `event_id` is always null in a test.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["webhook_delivery"],
                  "properties": {
                    "webhook_delivery": {
                      "$ref": "#/components/schemas/WebhookDelivery"
                    }
                  }
                },
                "example": {
                  "webhook_delivery": {
                    "id": "dlv_01k7a9x2m4p6q8r0s2t4v6w8y0",
                    "event_id": null,
                    "event_type": "customer_integration.status_updated",
                    "attempt": 1,
                    "status": "succeeded",
                    "response_status": 200,
                    "response_excerpt": "ok",
                    "error": null,
                    "duration_ms": 184,
                    "next_attempt_at": null,
                    "created_at": "2026-10-13 12:00:00"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No results found with id ''",
                  "error_code": "model_not_found"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhooks/endpoints/{uuid}/deliveries": {
      "get": {
        "tags": ["Webhooks"],
        "operationId": "listWebhookDeliveries",
        "summary": "Lists the latest deliveries",
        "description": "The 20 most recent attempts for this endpoint, newest to oldest. Each retry is its own row, with increasing `attempt`. History is kept for 30 days.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointUuid"
          }
        ],
        "responses": {
          "200": {
            "description": "The attempts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "dlv_01k7a9x2m4p6q8r0s2t4v6w8y0",
                      "event_id": "evt_01k7a9x1c3e5g7j9k1m3p5r7t9",
                      "event_type": "customer_integration.status_updated",
                      "attempt": 1,
                      "status": "succeeded",
                      "response_status": 200,
                      "response_excerpt": "ok",
                      "error": null,
                      "duration_ms": 184,
                      "next_attempt_at": "2026-10-13 12:00:00",
                      "created_at": "2026-10-13 12:00:00"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No results found with id ''",
                  "error_code": "model_not_found"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhooks/endpoints/{uuid}/deliveries/{delivery}/redeliver": {
      "post": {
        "tags": ["Webhooks"],
        "operationId": "redeliverWebhookDelivery",
        "summary": "Resends a delivery that exhausted its attempts",
        "description": "Restarts the full attempt cycle for an event. Only the event's most recent attempt can be resent, and only if it is exhausted (`status: exhausted`): any other is refused with 422, including when the event already has a cycle in progress. Sending happens in the background: track it through the deliveries list.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookEndpointUuid"
          },
          {
            "name": "delivery",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The delivery `id`, with the `dlv_` prefix.",
            "example": "dlv_01k7a9x2m4p6q8r0s2t4v6w8y0"
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted. The first attempt of the new cycle is already queued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["webhook_delivery"],
                  "properties": {
                    "webhook_delivery": {
                      "$ref": "#/components/schemas/WebhookDelivery"
                    }
                  }
                },
                "example": {
                  "webhook_delivery": {
                    "id": "dlv_01k7a9x2m4p6q8r0s2t4v6w8y0",
                    "event_id": "evt_01k7a9x1c3e5g7j9k1m3p5r7t9",
                    "event_type": "customer_integration.status_updated",
                    "attempt": 9,
                    "status": "pending",
                    "response_status": null,
                    "response_excerpt": null,
                    "error": null,
                    "duration_ms": null,
                    "next_attempt_at": "2026-10-13 12:00:00",
                    "created_at": "2026-10-13 12:00:00"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "No results found with id ''",
                  "error_code": "model_not_found"
                }
              }
            }
          },
          "422": {
            "description": "The delivery has not exhausted its attempts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricsValidationError"
                },
                "example": {
                  "message": "Only the latest attempt of an event, once it exhausted its attempts, can be sent again.",
                  "error_code": "validation_error",
                  "extra": "default"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhook-subscriptions": {
      "get": {
        "tags": ["Webhooks"],
        "operationId": "listWebhookSubscriptions",
        "deprecated": true,
        "summary": "Lists your webhooks",
        "description": "The addresses your account has registered to receive events. A webhook belongs to the account, not the customer: a single address receives events from all your customers.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 15
            },
            "description": "How many per page."
          }
        ],
        "responses": {
          "200": {
            "description": "The list, paginated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookSubscription"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Validation failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "url": [
                      "This webhook URL is already registered for your account."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": ["Webhooks"],
        "operationId": "createWebhookSubscription",
        "deprecated": true,
        "summary": "Registers a webhook",
        "description": "Starts delivering the chosen events to the given address. Deliveries are signed: verify the signature before trusting the body.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["url", "events"],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "`https` address that will receive the events. We refuse internal or private-network addresses, and the same address cannot be registered twice in the same account."
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "enum": [
                        "customer_integration.status_updated",
                        "customer_integration.deleted",
                        "oauth_started",
                        "oauth_saved",
                        "session_completed"
                      ]
                    },
                    "description": "Which events this address receives."
                  },
                  "is_active": {
                    "type": "boolean",
                    "default": true,
                    "description": "An inactive registration still exists and stops receiving."
                  }
                }
              },
              "example": {
                "url": "https://sua-app.com/webhooks/connect",
                "events": [
                  "customer_integration.status_updated",
                  "session_completed"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Registered.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook_subscription": {
                      "$ref": "#/components/schemas/WebhookSubscription"
                    }
                  }
                },
                "example": {
                  "webhook_subscription": {
                    "id": 12,
                    "url": "https://sua-app.com/webhooks/connect",
                    "events": [
                      "customer_integration.status_updated",
                      "session_completed"
                    ],
                    "is_active": true,
                    "created_at": "2026-09-01T12:00:00.000000Z",
                    "updated_at": "2026-09-01T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Validation failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "url": [
                      "This webhook URL is already registered for your account."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/webhook-subscriptions/{id}": {
      "get": {
        "tags": ["Webhooks"],
        "operationId": "getWebhookSubscription",
        "deprecated": true,
        "summary": "Shows a webhook",
        "description": "A registration in your account.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "The registration id, as returned on creation."
          }
        ],
        "responses": {
          "200": {
            "description": "The registration.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook_subscription": {
                      "$ref": "#/components/schemas/WebhookSubscription"
                    }
                  }
                },
                "example": {
                  "webhook_subscription": {
                    "id": 12,
                    "url": "https://sua-app.com/webhooks/connect",
                    "events": [
                      "customer_integration.status_updated",
                      "session_completed"
                    ],
                    "is_active": true,
                    "created_at": "2026-09-01T12:00:00.000000Z",
                    "updated_at": "2026-09-01T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Validation failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "url": [
                      "This webhook URL is already registered for your account."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Not Found"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": ["Webhooks"],
        "operationId": "updateWebhookSubscription",
        "deprecated": true,
        "summary": "Updates a webhook",
        "description": "Send only what changes. `PATCH` does the same.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "The registration id, as returned on creation."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "`https` address that will receive the events. We refuse internal or private-network addresses, and the same address cannot be registered twice in the same account."
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "enum": [
                        "customer_integration.status_updated",
                        "customer_integration.deleted",
                        "oauth_started",
                        "oauth_saved",
                        "session_completed"
                      ]
                    },
                    "description": "Which events this address receives."
                  },
                  "is_active": {
                    "type": "boolean",
                    "default": true,
                    "description": "An inactive registration still exists and stops receiving."
                  }
                }
              },
              "example": {
                "is_active": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook_subscription": {
                      "$ref": "#/components/schemas/WebhookSubscription"
                    }
                  }
                },
                "example": {
                  "webhook_subscription": {
                    "id": 12,
                    "url": "https://sua-app.com/webhooks/connect",
                    "events": [
                      "customer_integration.status_updated",
                      "session_completed"
                    ],
                    "is_active": true,
                    "created_at": "2026-09-01T12:00:00.000000Z",
                    "updated_at": "2026-09-01T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Validation failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "url": [
                      "This webhook URL is already registered for your account."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Not Found"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": ["Webhooks"],
        "operationId": "patchWebhookSubscription",
        "deprecated": true,
        "summary": "Updates a webhook",
        "description": "Identical to `PUT` on this same route.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "The registration id, as returned on creation."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "maxLength": 2048,
                    "description": "`https` address that will receive the events. We refuse internal or private-network addresses, and the same address cannot be registered twice in the same account."
                  },
                  "events": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "string",
                      "enum": [
                        "customer_integration.status_updated",
                        "customer_integration.deleted",
                        "oauth_started",
                        "oauth_saved",
                        "session_completed"
                      ]
                    },
                    "description": "Which events this address receives."
                  },
                  "is_active": {
                    "type": "boolean",
                    "default": true,
                    "description": "An inactive registration still exists and stops receiving."
                  }
                }
              },
              "example": {
                "is_active": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "webhook_subscription": {
                      "$ref": "#/components/schemas/WebhookSubscription"
                    }
                  }
                },
                "example": {
                  "webhook_subscription": {
                    "id": 12,
                    "url": "https://sua-app.com/webhooks/connect",
                    "events": [
                      "customer_integration.status_updated",
                      "session_completed"
                    ],
                    "is_active": true,
                    "created_at": "2026-09-01T12:00:00.000000Z",
                    "updated_at": "2026-09-01T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Validation failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "url": [
                      "This webhook URL is already registered for your account."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Not Found"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": ["Webhooks"],
        "operationId": "deleteWebhookSubscription",
        "deprecated": true,
        "summary": "Removes a webhook",
        "description": "Stops delivering to this address. Events already delivered are not affected.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer"
            },
            "description": "The registration id, as returned on creation."
          }
        ],
        "responses": {
          "200": {
            "description": "Removed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessMessage"
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "422": {
            "description": "Validation failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "url": [
                      "This webhook URL is already registered for your account."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "description": "Does not exist, or does not belong to your account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Not Found"
                }
              }
            }
          }
        }
      }
    },
    "/customers/integrations": {
      "get": {
        "tags": ["Customers"],
        "operationId": "listCustomersWithIntegrations",
        "summary": "Lists your customers with each one's connections",
        "description": "The same list as `GET /customers`, with connections embedded. Avoids one call per customer when you just want an overview.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Filters by customer name."
          },
          {
            "name": "integrations",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["expired", "none"]
            },
            "description": "`expired`: only customers with at least one `expired` integration. `none`: only customers with no integration. The response's `meta.total` is the filtered count."
          }
        ],
        "responses": {
          "200": {
            "description": "The customers and their connections.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomerWithIntegrations"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customer-integrations/{uuid}/update-status": {
      "post": {
        "tags": ["Customer Integrations"],
        "operationId": "updateCustomerIntegrationStatus",
        "summary": "Changes a connection's status",
        "description": "Marks the connection as active, expired, or revoked. Use it to reflect in Connect something you already know, for example, that your customer revoked access on the network side.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The connection's `uuid`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["status"],
                "properties": {
                  "status": {
                    "$ref": "#/components/schemas/IntegrationStatus"
                  }
                }
              },
              "example": {
                "status": "revoked"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Status updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "old_status",
                    "new_status",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "old_status": {
                      "$ref": "#/components/schemas/IntegrationStatus"
                    },
                    "new_status": {
                      "$ref": "#/components/schemas/IntegrationStatus"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": true,
                  "old_status": "active",
                  "new_status": "revoked",
                  "message": "Integration with id '2c94ccbe-54dd-4a28-8099-a2b248204329', 'My Page' status updated to 'revoked'"
                }
              }
            }
          },
          "400": {
            "description": "The change was not applied.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "Integration not found"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "422": {
            "description": "Status outside the vocabulary, or connection does not exist.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "status": ["The selected status is invalid."]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/customer-integrations/session-shared": {
      "post": {
        "tags": ["Customer Integrations"],
        "operationId": "createSharedIntegrationSession",
        "summary": "Creates a shared integration session",
        "description": "Variant of `POST /customer-integrations/session` for when **the same source account** will be linked to several of your customers at once. Instead of one session per customer, you list the customer + source id pairs and get a single link.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["redirect_url", "source_slug", "source_ids"],
                "properties": {
                  "redirect_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Where your customer returns when done."
                  },
                  "source_slug": {
                    "type": "string",
                    "description": "The integration slug, as in `GET /merchants/settings`."
                  },
                  "source_ids": {
                    "type": "array",
                    "minItems": 1,
                    "description": "One pair per customer of yours.",
                    "items": {
                      "type": "object",
                      "required": ["customer_uuid", "source_id"],
                      "properties": {
                        "customer_uuid": {
                          "type": "string",
                          "format": "uuid"
                        },
                        "source_id": {
                          "type": "string",
                          "description": "The source account id to link to that customer."
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "redirect_url": "https://sua-app.com/integracoes/pronto",
                "source_slug": "facebook_ads",
                "source_ids": [
                  {
                    "customer_uuid": "0d835ce8-d0a3-4763-a2ec-d01a605ac404",
                    "source_id": "act_1884348095855063"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The session, with the link for your customer to open.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "integration_session": {
                      "$ref": "#/components/schemas/IntegrationSession"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/NotYoursOrNotFound"
          },
          "422": {
            "description": "Validation failure. A `customer_uuid` that isn't yours also lands here.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "source_ids.0.customer_uuid": [
                      "The selected customer does not belong to this merchant."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/check-status": {
      "get": {
        "tags": ["Merchant"],
        "operationId": "getStatus",
        "summary": "Service status",
        "description": "Health check, unauthenticated and outside the rate limit. Responds **503** when a dependency is down. Use it for monitoring, not as part of a flow.",
        "security": [],
        "responses": {
          "200": {
            "description": "Everything up.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": ["ok", "degraded"]
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "checks": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string",
                        "enum": ["ok", "fail"]
                      }
                    }
                  }
                },
                "example": {
                  "status": "ok",
                  "timestamp": "2026-09-25T12:00:00+00:00",
                  "checks": {
                    "database": "ok",
                    "cache": "ok",
                    "queue": "ok"
                  }
                }
              }
            }
          },
          "503": {
            "description": "A dependency is down.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "timestamp": {
                      "type": "string"
                    },
                    "checks": {
                      "type": "object"
                    }
                  }
                },
                "example": {
                  "status": "degraded",
                  "timestamp": "2026-09-25T12:00:00+00:00",
                  "checks": {
                    "database": "ok",
                    "cache": "fail",
                    "queue": "ok"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/posts": {
      "get": {
        "tags": ["Posts"],
        "operationId": "listPosts",
        "summary": "Lists the customer's posts",
        "description": "All of the customer's posts, most recent first. Filters are optional and combine.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/PostsCustomerIntegration"
          },
          {
            "name": "external_reference",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["created", "publishing", "published", "failed"]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 15
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's posts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PostsPost"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/PostsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/PostsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": ["Posts"],
        "operationId": "createPost",
        "summary": "Publishes a post",
        "description": "Saves the post and queues the publishing. Responds `202` with the post in `created`. Track it via `GET /posts/{uuid}`.\n\nThe connection is checked now: nonexistent, inactive, or from another network is refused before saving. The token is checked at publishing; if refused, the post ends `failed`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/PostsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/PostsIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PostsCreateRequest"
              },
              "example": {
                "external_reference": "post-4410",
                "format": "feed",
                "caption": "New collection live",
                "media": [
                  {
                    "type": "image",
                    "url": "https://cdn.loja.com/colecao.jpg"
                  }
                ],
                "instagram": {
                  "first_comment": "#colecao"
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Post saved, publishing queued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["post"],
                  "properties": {
                    "post": {
                      "$ref": "#/components/schemas/PostsPost"
                    }
                  }
                },
                "example": {
                  "post": {
                    "uuid": "5f0c2a8e-7d1b-4c3e-9a4f-1b2c3d4e5f60",
                    "external_reference": "post-4410",
                    "integration_slug": "instagram_business",
                    "source_id": "17841468870601230",
                    "source_name": "Loja Exemplo",
                    "format": "feed",
                    "caption": "New collection live",
                    "status": "created",
                    "permalink": null,
                    "publishing": {
                      "status": "pending",
                      "external_id": null,
                      "error": null,
                      "published_at": null
                    },
                    "media": [
                      {
                        "position": 0,
                        "type": "image",
                        "url": "https://cdn.loja.com/colecao.jpg",
                        "alt_text": null,
                        "user_tags": null,
                        "publishing": {
                          "status": "pending",
                          "external_id": null,
                          "error": null
                        }
                      }
                    ],
                    "instagram": null,
                    "facebook": null,
                    "threads": null,
                    "linkedin": null,
                    "pinterest": null,
                    "youtube": null,
                    "created_at": "2026-10-19 14:00:00"
                  }
                }
              }
            }
          },
          "200": {
            "description": "Replay of the same `Idempotency-Key` with the same request: the already saved post, with `Idempotent-Replay: true`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["post"],
                  "properties": {
                    "post": {
                      "$ref": "#/components/schemas/PostsPost"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Another post with the same `external_reference` is publishing (`post_in_progress`) or has already been published (`post_already_published`) in this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostsError"
                },
                "example": {
                  "message": "A post with this external_reference is already being published to this account.",
                  "error_code": "post_in_progress",
                  "post_uuid": "5f0c2a8e-7d1b-4c3e-9a4f-1b2c3d4e5f60"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/PostsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/PostsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/posts/{uuid}": {
      "get": {
        "tags": ["Posts"],
        "operationId": "showPost",
        "summary": "A post and its publishing status",
        "description": "`status` goes from `created` to `publishing` and ends in `published` (with `permalink`) or `failed` (with `publishing.error`).",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The post",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["post"],
                  "properties": {
                    "post": {
                      "$ref": "#/components/schemas/PostsPost"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/PostsForbidden"
          },
          "404": {
            "description": "There is no post with that `uuid` for this customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/posts/pinterest/boards": {
      "get": {
        "tags": ["Posts"],
        "operationId": "listPinterestBoards",
        "summary": "The Pinterest account's boards",
        "description": "Read live from the network, all pages.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/PostsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/PostsSourceName"
          }
        ],
        "responses": {
          "200": {
            "description": "The boards",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["boards"],
                  "properties": {
                    "boards": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PostsPinterestBoard"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/PostsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/PostsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/PostsNetworkUnavailable"
          }
        }
      },
      "post": {
        "tags": ["Posts"],
        "operationId": "createPinterestBoard",
        "summary": "Creates a board in the Pinterest account",
        "description": "Creates it on the network and returns the board, without storing anything in Connect.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/PostsCustomerIntegration"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "source_name": {
                    "type": "string",
                    "maxLength": 255,
                    "description": "Required without `customer_integration`."
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 180
                  },
                  "description": {
                    "type": ["string", "null"],
                    "maxLength": 500
                  },
                  "privacy": {
                    "type": ["string", "null"],
                    "enum": ["PUBLIC", "PROTECTED", "SECRET", null]
                  }
                }
              },
              "example": {
                "name": "Summer collection",
                "privacy": "PUBLIC"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The created board",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["board"],
                  "properties": {
                    "board": {
                      "$ref": "#/components/schemas/PostsPinterestBoard"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/PostsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/PostsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/PostsNetworkUnavailable"
          }
        }
      }
    },
    "/posts/pinterest/boards/{board_id}/sections": {
      "get": {
        "tags": ["Posts"],
        "operationId": "listPinterestBoardSections",
        "summary": "A board's sections",
        "description": "Read live from the network.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "board_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d+$"
            }
          },
          {
            "$ref": "#/components/parameters/PostsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/PostsSourceName"
          }
        ],
        "responses": {
          "200": {
            "description": "The sections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["sections"],
                  "properties": {
                    "sections": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": ["id", "name"],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/PostsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/PostsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "description": "The board does not exist in this account (`board_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PostsError"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/PostsNetworkUnavailable"
          }
        }
      }
    },
    "/posts/youtube/categories": {
      "get": {
        "tags": ["Posts"],
        "operationId": "listYouTubeCategories",
        "summary": "The categories a YouTube video accepts",
        "description": "Only assignable categories. Cached by region and language.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/PostsCustomerIntegration"
          },
          {
            "$ref": "#/components/parameters/PostsSourceName"
          },
          {
            "name": "region_code",
            "in": "query",
            "required": false,
            "description": "Country, ISO 3166-1 alpha-2. Default `BR`.",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 2
            }
          },
          {
            "name": "hl",
            "in": "query",
            "required": false,
            "description": "Language of the titles, such as `pt-BR`.",
            "schema": {
              "type": "string",
              "maxLength": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The categories",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["categories"],
                  "properties": {
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "required": ["id", "title"],
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/PostsForbidden"
          },
          "422": {
            "$ref": "#/components/responses/PostsValidationError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/PostsNetworkUnavailable"
          }
        }
      }
    },
    "/media": {
      "get": {
        "tags": ["Media"],
        "operationId": "listMedia",
        "summary": "Lists the customer's media",
        "description": "Media still valid, most recent first.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["uploading", "ready"]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 15
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "The customer's media",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MediaMedia"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "422": {
            "description": "An invalid filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Media"],
        "operationId": "createMedia",
        "summary": "Uploads a file of up to 8 MB",
        "description": "The whole file goes in a single `multipart/form-data` request, in the `file` field. Responds `201` with the ready media and the `url`.\n\nThe cap is 8 MB or what the server accepts in one request, whichever is smaller. Above it the response is `413 media_too_large_for_single_upload`, and the file goes in parts via `POST /media/uploads`, which accepts any size up to 1 GB, including small files.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MediaIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["file"],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Up to 8 MB. The type is read from the content."
                  }
                }
              },
              "example": {
                "file": "(the contents of summer-4x5.jpg)"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The media, ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Replay of the same `Idempotency-Key` with the same file: the already stored media, with `Idempotent-Replay: true`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "413": {
            "description": "The file exceeds the single-upload cap. Send it in parts via `POST /media/uploads`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "too_large": {
                    "value": {
                      "message": "A single request takes files up to 8 MB: upload it in parts through POST /media/uploads.",
                      "error_code": "media_too_large_for_single_upload"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Too many requests, or a media limit reached. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "too_fast": {
                    "value": {
                      "message": "Too many requests. Please slow down.",
                      "error_code": "too_many_requests"
                    }
                  },
                  "too_many_open": {
                    "value": {
                      "message": "This customer has too many uploads open. Complete or let them expire before opening more.",
                      "error_code": "media_too_many_uploads"
                    }
                  },
                  "daily": {
                    "value": {
                      "message": "The daily upload volume of this account was reached. Try again tomorrow.",
                      "error_code": "media_daily_limit"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "An invalid field (`errors`) or a refusal (`error_code`).",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                },
                "examples": {
                  "type": {
                    "value": {
                      "message": "The file is not of a type media accepts (image/jpeg, image/png, image/webp, image/gif, video/mp4, video/quicktime). The type is read from the file, not its name.",
                      "error_code": "media_type_not_supported"
                    }
                  },
                  "key_reused": {
                    "value": {
                      "message": "This Idempotency-Key was already used with a different request body.",
                      "error_code": "idempotency_key_reused"
                    }
                  },
                  "content": {
                    "value": {
                      "message": "The file is not a well-formed image or video of the type its first bytes declare. Nothing was kept.",
                      "error_code": "media_content_invalid"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The `Idempotency-Key` was already used by media that has expired. Use another key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "expired": {
                    "value": {
                      "message": "There is no media with this uuid for this customer, or it expired.",
                      "error_code": "media_not_found"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "A request with the same `Idempotency-Key` is still storing the file. Retry shortly.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "in_progress": {
                    "value": {
                      "message": "A request with this Idempotency-Key is still storing the file. Try again in a moment.",
                      "error_code": "media_upload_in_progress"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/media/uploads": {
      "post": {
        "tags": ["Media"],
        "operationId": "openMediaUpload",
        "summary": "Opens an upload of a file in parts",
        "description": "For files above 8 MB, up to 1 GB. Responds with the media in `uploading` and, in `upload`, the size of each part and how many there are. Send each part via `PUT /media/uploads/{uuid}/parts/{n}` and close with `POST /media/uploads/{uuid}/complete` before `upload.expires_at`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MediaIdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["file_name", "size"],
                "properties": {
                  "file_name": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 1073741824,
                    "description": "The exact file size, in bytes."
                  }
                }
              },
              "example": {
                "file_name": "reels-verao.mp4",
                "size": 52428800
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The opened upload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "Replay of the same `Idempotency-Key` with the same request: the same upload, with `Idempotent-Replay: true`",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "429": {
            "description": "Too many requests, or a media limit reached. Wait before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "too_fast": {
                    "value": {
                      "message": "Too many requests. Please slow down.",
                      "error_code": "too_many_requests"
                    }
                  },
                  "too_many_open": {
                    "value": {
                      "message": "This customer has too many uploads open. Complete or let them expire before opening more.",
                      "error_code": "media_too_many_uploads"
                    }
                  },
                  "daily": {
                    "value": {
                      "message": "The daily upload volume of this account was reached. Try again tomorrow.",
                      "error_code": "media_daily_limit"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "An invalid field (`errors`) or a refusal (`error_code`).",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                },
                "examples": {
                  "key_reused": {
                    "value": {
                      "message": "This Idempotency-Key was already used with a different request body.",
                      "error_code": "idempotency_key_reused"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "The `Idempotency-Key` was already used by media that has expired. Use another key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "expired": {
                    "value": {
                      "message": "There is no media with this uuid for this customer, or it expired.",
                      "error_code": "media_not_found"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/media/uploads/{uuid}": {
      "get": {
        "tags": ["Media"],
        "operationId": "showMediaUpload",
        "summary": "The status of an upload in parts",
        "description": "`received_parts` says which parts have already arrived, so you can resume an interrupted upload without sending everything again.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The upload",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media", "received_parts"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    },
                    "received_parts": {
                      "type": "array",
                      "items": {
                        "type": "integer"
                      },
                      "example": [1, 2, 4]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/MediaNotFound"
          }
        }
      }
    },
    "/media/uploads/{uuid}/parts/{part}": {
      "put": {
        "tags": ["Media"],
        "operationId": "putMediaUploadPart",
        "summary": "Uploads one part of the file",
        "description": "The body is the raw content of the part (`application/octet-stream`), with exactly `upload.part_size` bytes, or the remainder in the last one. Part 1 goes first: the file type is read from it, and an unaccepted type is refused before anything is stored. After part 1, the others can go in any order and concurrently. Resending a part replaces the previous one. `Content-Length` is required and must be the exact part size: it is checked before the body is read. An image is at most 30 MB.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "part",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 99999
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/octet-stream": {
              "schema": {
                "type": "string",
                "format": "binary"
              },
              "example": "(bytes 1 to 8388608 of the file, in part 1)"
            }
          }
        },
        "responses": {
          "204": {
            "description": "The part was stored"
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/MediaNotFound"
          },
          "409": {
            "description": "The part arrived out of turn.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "part_1": {
                    "value": {
                      "message": "Send part 1 before the others: the type of the file is read from it.",
                      "error_code": "media_part_one_first"
                    }
                  },
                  "completed": {
                    "value": {
                      "message": "This upload was already completed.",
                      "error_code": "media_already_completed"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "The part is not valid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "part_out_of_range": {
                    "value": {
                      "message": "Part 4 is outside 1..3.",
                      "error_code": "media_part_out_of_range"
                    }
                  },
                  "wrong_size": {
                    "value": {
                      "message": "Part 1 should have 8388608 bytes and has 1000.",
                      "error_code": "media_part_size_mismatch"
                    }
                  },
                  "type": {
                    "value": {
                      "message": "The file is not of a type media accepts (image/jpeg, image/png, image/webp, image/gif, video/mp4, video/quicktime). The type is read from the file, not its name.",
                      "error_code": "media_type_not_supported"
                    }
                  },
                  "other_type": {
                    "value": {
                      "message": "Part 1 was sent again with a file of another type. Open a new upload for another file.",
                      "error_code": "media_type_changed"
                    }
                  },
                  "large_image": {
                    "value": {
                      "message": "An image may have at most 30 MB.",
                      "error_code": "media_image_too_large"
                    }
                  }
                }
              }
            }
          },
          "411": {
            "description": "Part without `Content-Length`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "no_size": {
                    "value": {
                      "message": "Send each part with a Content-Length equal to its size.",
                      "error_code": "media_part_length_required"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/media/uploads/{uuid}/complete": {
      "post": {
        "tags": ["Media"],
        "operationId": "completeMediaUpload",
        "summary": "Assembles the parts and makes the media ready",
        "description": "Responds `201` with the `ready` media and the `url`. Doesn't require `Idempotency-Key`: completing again responds `200` with the same media. Before it becomes ready, the whole file is checked: an image must end where its format says, and a video must be a sequence of MP4/MOV boxes from the first to the last byte. A file that fails is deleted and responds `422 media_content_invalid`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The media, ready",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    }
                  }
                }
              }
            }
          },
          "200": {
            "description": "The upload had already been completed: the same media",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/MediaNotFound"
          },
          "409": {
            "description": "Parts are missing. Send the missing ones and complete again.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "parts_missing": {
                    "value": {
                      "message": "Parts missing: 2, 3.",
                      "error_code": "media_parts_missing"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "The assembled file isn't what its first bytes declared. Nothing was stored.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "examples": {
                  "content": {
                    "value": {
                      "message": "The file is not a well-formed image or video of the type its first bytes declare. Nothing was kept.",
                      "error_code": "media_content_invalid"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/media/{uuid}": {
      "get": {
        "tags": ["Media"],
        "operationId": "showMedia",
        "summary": "A media item and its URL",
        "description": "One of the customer's media items. The `url` is the same on every read, until `expires_at`. Media that has already expired responds `404`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The media",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["media"],
                  "properties": {
                    "media": {
                      "$ref": "#/components/schemas/MediaMedia"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/MediaNotFound"
          }
        }
      }
    },
    "/merchants/media": {
      "get": {
        "tags": ["Media"],
        "operationId": "listMerchantMedia",
        "summary": "Lists the media of all your customers",
        "description": "Your account overview: the still-valid media of all your customers, most recent first, with just the API key, no `x-customer-token`. `customer` narrows the list.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MerchantCustomer"
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["uploading", "ready"]
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 15
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "The media",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MediaMedia"
                      }
                    },
                    "meta": {
                      "$ref": "#/components/schemas/PaginationMeta"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "The `customer` isn't yours.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "This action is unauthorized.",
                  "error_code": "forbidden"
                }
              }
            }
          },
          "422": {
            "description": "An invalid filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/toolkits": {
      "get": {
        "tags": ["Toolkits"],
        "operationId": "listToolkits",
        "summary": "The toolkit catalog",
        "description": "The apps Connect reaches via toolkit: each is described by a spec and executed by a generic engine, without the depth of a `GET /integrations` platform. The list is the same for every merchant and does not depend on the customer.\n\nEach item states the connection modes it accepts (`api_key`, `basic`, `oauth2`) and, for the first two, the fields the end customer types. An `oauth2` toolkit only connects with the merchant's own app, registered at `/merchants/credentials/{integration_slug}` with the toolkit's `slug`.\n\nA toolkit never reuses a platform's `slug`. What each one executes is in `GET /toolkits/{toolkit_slug}/tools`.\n\nIt is a complete list, no pagination.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "analytics",
                "communication",
                "crm",
                "developer_tools",
                "ecommerce",
                "email_marketing",
                "file_storage",
                "finance",
                "marketing",
                "productivity",
                "project_management",
                "scheduling",
                "support"
              ]
            },
            "description": "Only toolkits in this category."
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Text searched in the `slug`, name, and description, case-insensitive."
          }
        ],
        "responses": {
          "200": {
            "description": "The catalog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Toolkit"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "slug": "jira",
                      "name": "Jira",
                      "description": "Issues and projects of a Jira Cloud site.",
                      "category": "project_management",
                      "version": "2026-10-19",
                      "docs_url": "https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/",
                      "logo_url": "https://connect.reportei.com/img/toolkits/jira.svg",
                      "auth": [
                        {
                          "mode": "basic",
                          "merchant_credential_required": false,
                          "fields": {
                            "username": {
                              "label": "Atlassian account email",
                              "placeholder": "you@company.com"
                            },
                            "password": {
                              "label": "API token",
                              "placeholder": "Paste your API token"
                            }
                          },
                          "steps": [
                            "Sign in to id.atlassian.com with the account you are connecting and open Security, then API tokens.",
                            "Choose Create API token, the option without scopes, and set an expiration of up to one year.",
                            "Paste the token below together with the email of the same account."
                          ]
                        }
                      ],
                      "base_url_params": {
                        "site": {
                          "label": "Site name",
                          "placeholder": "your-company, from your-company.atlassian.net",
                          "format": "subdomain"
                        }
                      },
                      "tools_count": 3
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "422": {
            "description": "Validation: `category` not in the list or `search` longer than 100 characters.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "errors": {
                    "category": ["The selected category is invalid."]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/toolkits/{toolkit_slug}": {
      "get": {
        "tags": ["Toolkits"],
        "operationId": "getToolkit",
        "summary": "A toolkit",
        "description": "The same item as in `GET /toolkits`: the connection modes, the fields each one asks of the customer, and the host variables (`base_url_params`) the customer fills in when connecting, such as a Jira Cloud `site`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "toolkit_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The `slug` of an item from `GET /toolkits`."
          }
        ],
        "responses": {
          "200": {
            "description": "The toolkit",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["toolkit"],
                  "properties": {
                    "toolkit": {
                      "$ref": "#/components/schemas/Toolkit"
                    }
                  }
                },
                "example": {
                  "toolkit": {
                    "slug": "jira",
                    "name": "Jira",
                    "description": "Issues and projects of a Jira Cloud site.",
                    "category": "project_management",
                    "version": "2026-10-19",
                    "docs_url": "https://developer.atlassian.com/cloud/jira/platform/rest/v3/intro/",
                    "logo_url": "https://connect.reportei.com/img/toolkits/jira.svg",
                    "auth": [
                      {
                        "mode": "basic",
                        "merchant_credential_required": false,
                        "fields": {
                          "username": {
                            "label": "Atlassian account email",
                            "placeholder": "you@company.com"
                          },
                          "password": {
                            "label": "API token",
                            "placeholder": "Paste your API token"
                          }
                        },
                        "steps": [
                          "Sign in to id.atlassian.com with the account you are connecting and open Security, then API tokens.",
                          "Choose Create API token, the option without scopes, and set an expiration of up to one year.",
                          "Paste the token below together with the email of the same account."
                        ]
                      }
                    ],
                    "base_url_params": {
                      "site": {
                        "label": "Site name",
                        "placeholder": "your-company, from your-company.atlassian.net",
                        "format": "subdomain"
                      }
                    },
                    "tools_count": 3
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/ToolkitNotFound"
          }
        }
      }
    },
    "/toolkits/{toolkit_slug}/tools": {
      "get": {
        "tags": ["Toolkits"],
        "operationId": "listToolkitTools",
        "summary": "A toolkit's tools",
        "description": "What you can execute in this toolkit. Each tool's `input` is the JSON Schema of the `arguments` the execution receives: it is what you hand to an agent so it can pick the tool and fill in the call. The `method` says whether the tool reads (`GET`) or writes to the app.\n\nIt is a complete list, no pagination.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "toolkit_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The `slug` of an item from `GET /toolkits`."
          }
        ],
        "responses": {
          "200": {
            "description": "The tools",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Tool"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "slug": "jira_get_issue",
                      "toolkit_slug": "jira",
                      "name": "Get issue",
                      "description": "Returns one issue by id or key.",
                      "method": "GET",
                      "input": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": ["issueIdOrKey"],
                        "properties": {
                          "issueIdOrKey": {
                            "type": "string",
                            "description": "Issue id or key, for example KEY-123."
                          },
                          "fields": {
                            "type": "string",
                            "description": "Comma-separated field names to return. Omit it to return all navigable fields."
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/ToolkitNotFound"
          }
        }
      }
    },
    "/tools/{tool_slug}": {
      "get": {
        "tags": ["Toolkits"],
        "operationId": "getTool",
        "summary": "A tool",
        "description": "A tool by its global `slug`, with the toolkit it belongs to and the JSON Schema of its `arguments`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "tool_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The tool's global `slug`, already prefixed with the toolkit (`jira_get_issue`)."
          }
        ],
        "responses": {
          "200": {
            "description": "The tool",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["tool"],
                  "properties": {
                    "tool": {
                      "$ref": "#/components/schemas/Tool"
                    }
                  }
                },
                "example": {
                  "tool": {
                    "slug": "jira_get_issue",
                    "toolkit_slug": "jira",
                    "name": "Get issue",
                    "description": "Returns one issue by id or key.",
                    "method": "GET",
                    "input": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": ["issueIdOrKey"],
                      "properties": {
                        "issueIdOrKey": {
                          "type": "string",
                          "description": "Issue id or key, for example KEY-123."
                        },
                        "fields": {
                          "type": "string",
                          "description": "Comma-separated field names to return. Omit it to return all navigable fields."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/ToolNotFound"
          }
        }
      }
    },
    "/customer-toolkits": {
      "get": {
        "tags": ["Toolkits"],
        "operationId": "listCustomerToolkits",
        "summary": "The customer's toolkit connections",
        "description": "Each connection is an account of an app the customer linked through a toolkit, via the session or `POST /customer-toolkits`. The `uuid` is what a tool execution receives in `customer_toolkit`. No secret leaves here.\n\nIt is a complete list, no pagination.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The connections",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CustomerToolkit"
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "uuid": "7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e",
                      "toolkit": {
                        "slug": "jira",
                        "name": "Jira"
                      },
                      "source_id": "acme:5b10ac8d82e05b22cc7d4ef5",
                      "source_name": "Ana Lima",
                      "status": "active",
                      "base_url_params": {
                        "site": "acme"
                      },
                      "expires_at": null,
                      "created_at": "2026-10-19T12:00:00.000000Z",
                      "updated_at": "2026-10-19T12:00:00.000000Z"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "tags": ["Toolkits"],
        "operationId": "createCustomerToolkit",
        "summary": "Connects with a key, no UI",
        "description": "For the merchant that already has the customer's key: the same connection the session makes, without the form. Connect sends the credential to the app once, to identify the account, and only then stores it.\n\nOnly for `api_key` and `basic` modes. A toolkit that connects via OAuth goes through the session, with `toolkit_slug` in `POST /customer-integrations/session`. Reconnecting the same account replaces the stored credential and sets the connection back to `active`.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerToolkitRequest"
              },
              "examples": {
                "api_key": {
                  "summary": "A single-key toolkit",
                  "value": {
                    "toolkit_slug": "notion",
                    "key": "ntn_..."
                  }
                },
                "basic": {
                  "summary": "A username-and-password toolkit, on a host with a variable",
                  "value": {
                    "toolkit_slug": "jira",
                    "base_url_params": {
                      "site": "acme"
                    },
                    "username": "ana@acme.com",
                    "password": "ATATT3..."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Connected",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer_toolkit"],
                  "properties": {
                    "customer_toolkit": {
                      "$ref": "#/components/schemas/CustomerToolkit"
                    }
                  }
                },
                "example": {
                  "customer_toolkit": {
                    "uuid": "7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e",
                    "toolkit": {
                      "slug": "jira",
                      "name": "Jira"
                    },
                    "source_id": "acme:5b10ac8d82e05b22cc7d4ef5",
                    "source_name": "Ana Lima",
                    "status": "active",
                    "base_url_params": {
                      "site": "acme"
                    },
                    "expires_at": null,
                    "created_at": "2026-10-19T12:00:00.000000Z",
                    "updated_at": "2026-10-19T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "422": {
            "description": "Validation (the fields of the toolkit's auth mode and each host variable, which must be a single label), or a refusal with `error_code`: `toolkit_requires_session` (the toolkit only connects via OAuth), `toolkit_credential_invalid` (the app refused the credential, or did not identify the account), and `toolkit_host_param_invalid`.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                },
                "examples": {
                  "validation": {
                    "value": {
                      "errors": {
                        "base_url_params.site": [
                          "The base_url_params.site field format is invalid."
                        ]
                      }
                    }
                  },
                  "credential_refused": {
                    "value": {
                      "message": "The app did not accept this credential.",
                      "error_code": "toolkit_credential_invalid"
                    }
                  }
                }
              }
            }
          },
          "502": {
            "description": "The app did not respond, or responded with an error when identifying the account. The message is the app's or Connect's.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "The toolkit integration could not be reached.",
                  "error_code": "toolkit_integration_error"
                }
              }
            }
          }
        }
      }
    },
    "/customer-toolkits/{uuid}": {
      "parameters": [
        {
          "name": "uuid",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string",
            "format": "uuid"
          },
          "description": "The connection's `uuid`, from `GET /customer-toolkits` or from the session's `redirect_url`."
        }
      ],
      "get": {
        "tags": ["Toolkits"],
        "operationId": "getCustomerToolkit",
        "summary": "A toolkit connection",
        "description": "The connection by `uuid`. A connection of another customer, from the same merchant or not, responds 404.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "The connection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["customer_toolkit"],
                  "properties": {
                    "customer_toolkit": {
                      "$ref": "#/components/schemas/CustomerToolkit"
                    }
                  }
                },
                "example": {
                  "customer_toolkit": {
                    "uuid": "7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e",
                    "toolkit": {
                      "slug": "jira",
                      "name": "Jira"
                    },
                    "source_id": "acme:5b10ac8d82e05b22cc7d4ef5",
                    "source_name": "Ana Lima",
                    "status": "active",
                    "base_url_params": {
                      "site": "acme"
                    },
                    "expires_at": null,
                    "created_at": "2026-10-19T12:00:00.000000Z",
                    "updated_at": "2026-10-19T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/CustomerToolkitNotFound"
          }
        }
      },
      "delete": {
        "tags": ["Toolkits"],
        "operationId": "deleteCustomerToolkit",
        "summary": "Removes a toolkit connection",
        "description": "Deletes the connection and the credential stored with it. The app is not notified: the key or consent remain valid there, and the customer revokes them in the app itself if they want.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Removed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessMessage"
                },
                "example": {
                  "success": true,
                  "message": "Record successfully removed"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/CustomerToolkitNotFound"
          }
        }
      }
    },
    "/tools/{tool_slug}/execute": {
      "post": {
        "tags": ["Toolkits"],
        "operationId": "executeTool",
        "summary": "Executes a tool",
        "description": "Calls the app on the customer's account, once, without retry and without idempotency: Connect is a proxy, and a repeated `POST` is one more `POST` in the app. `arguments` is passed as-is; the tool's `input` in `GET /tools/{tool_slug}` is the contract the agent fills in, and what the app accepts is up to the app.\n\nThe response is the app's, status and body as they came, including errors: an app error arrives with its status and the `{ error, api_error }` envelope. Connect only speaks for itself when the app did not respond (504), when the integration failed (502), or when it refuses the call before making it (404, 409, 422). Every call Connect forwarded to the integration is logged; the execution `uuid` comes back in the `X-Toolkit-Execution-Id` header and, on 502 and 504, in `execution_id` in the body.\n\nAn OAuth token within one minute of expiring is refreshed before the call, one refresh per connection at a time. An app that refuses the credential does not change the connection's state: its 401 or 403 comes back as-is, and reconnecting is the merchant's decision.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "tool_slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The tool's global `slug`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ToolExecuteRequest"
              },
              "example": {
                "customer_toolkit": "7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e",
                "arguments": {
                  "issueIdOrKey": "KEY-123",
                  "fields": "summary,status"
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "The app's response, as it came: its status and body, in its `Content-Type`. The connection's credential never appears, even if the app echoes it.",
            "headers": {
              "X-Toolkit-Execution-Id": {
                "description": "The execution's `uuid`, for `GET /tools/executions/{uuid}`.",
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "X-Content-Type-Options": {
                "description": "Always `nosniff`: the body is the app's, in the `Content-Type` it sent, and the browser must not guess another.",
                "schema": {
                  "type": "string",
                  "enum": ["nosniff"]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "The app's body, untransformed."
                },
                "example": {
                  "id": "10001",
                  "key": "KEY-123",
                  "fields": {
                    "summary": "Fix the login"
                  }
                }
              }
            }
          },
          "3XX": {
            "description": "The app redirected. Connect doesn't follow the redirect, so the credential never goes to another host: it returns the app's status with the destination in `api_error.headers.location`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ToolkitAppError"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "description": "A Connect refusal, with `error_code` `tool_not_found` or `customer_toolkit_not_found`, or the app's own 404, with `api_error`.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/MessageError"
                    },
                    {
                      "$ref": "#/components/schemas/ToolkitAppError"
                    }
                  ]
                },
                "examples": {
                  "unknown_connection": {
                    "value": {
                      "message": "Customer toolkit '7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e' not found.",
                      "error_code": "customer_toolkit_not_found"
                    }
                  },
                  "from_app": {
                    "value": {
                      "error": "Request failed with status code 404",
                      "api_error": {
                        "status_code": 404,
                        "headers": {
                          "x-request-id": "6f1c0e2a"
                        },
                        "body": {
                          "errorMessages": [
                            "Issue does not exist or you do not have permission to see it."
                          ],
                          "errors": {}
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/CustomerToolkitExpired"
          },
          "422": {
            "description": "Validation (`customer_toolkit` missing, `arguments` not an object), the `tool_toolkit_mismatch` refusal (the tool doesn't belong to this connection's toolkit), the `tool_arguments_invalid` refusal (a path `{x}` missing, empty, `.` or `..`, or a query argument that is neither a scalar nor a list of scalars, with `execution_id`), or the app's own 422, with `api_error`.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/FormValidationError"
                    },
                    {
                      "$ref": "#/components/schemas/ToolkitExecutionError"
                    },
                    {
                      "$ref": "#/components/schemas/ToolkitAppError"
                    }
                  ]
                },
                "examples": {
                  "tool_from_another_toolkit": {
                    "value": {
                      "message": "Tool 'notion_search' does not belong to toolkit 'jira' of this customer toolkit.",
                      "error_code": "tool_toolkit_mismatch"
                    }
                  },
                  "invalid_argument": {
                    "value": {
                      "message": "Missing required argument 'page_id'",
                      "error_code": "tool_arguments_invalid",
                      "execution_id": "0d3c8b4a-2e1f-4c6d-9a7b-5e4f3a2b1c0d"
                    }
                  }
                }
              }
            }
          },
          "4XX": {
            "description": "Any other app error, with its status and the `{ error, api_error }` envelope. `api_error.headers` carries `retry-after`, `x-ratelimit-*` and `x-request-id` when the app sent them.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ToolkitAppError"
                },
                "example": {
                  "error": "Request failed with status code 404",
                  "api_error": {
                    "status_code": 404,
                    "headers": {
                      "x-request-id": "6f1c0e2a"
                    },
                    "body": {
                      "errorMessages": [
                        "Issue does not exist or you do not have permission to see it."
                      ],
                      "errors": {}
                    }
                  }
                }
              }
            }
          },
          "502": {
            "$ref": "#/components/responses/ToolkitIntegrationError"
          },
          "504": {
            "$ref": "#/components/responses/ToolkitTimeout"
          },
          "5XX": {
            "description": "A 5xx error from the app itself, with the `{ error, api_error }` envelope. A 500 without `api_error` comes from Connect, when the integration refuses the call it built: it shouldn't happen, and it gets logged.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ToolkitAppError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/tools/executions/{uuid}": {
      "get": {
        "tags": ["Toolkits"],
        "operationId": "getToolkitExecution",
        "summary": "An execution",
        "description": "The record of one of the customer's executions: what was asked of the app, what it responded and how long it took. Without the headers sent. Another customer's execution responds 404.",
        "security": [
          {
            "bearerAuth": [],
            "customerToken": []
          }
        ],
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The execution's `X-Toolkit-Execution-Id`."
          }
        ],
        "responses": {
          "200": {
            "description": "The execution",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["execution"],
                  "properties": {
                    "execution": {
                      "$ref": "#/components/schemas/ToolkitExecution"
                    }
                  }
                },
                "example": {
                  "execution": {
                    "uuid": "0d3c8b4a-2e1f-4c6d-9a7b-5e4f3a2b1c0d",
                    "tool_slug": "jira_get_issue",
                    "toolkit_slug": "jira",
                    "customer_toolkit": "7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e",
                    "method": "GET",
                    "url": "https://acme.atlassian.net/rest/api/3/issue/KEY-123",
                    "payload": {
                      "issueIdOrKey": "KEY-123"
                    },
                    "http_status": 200,
                    "response": {
                      "id": "10001",
                      "key": "KEY-123",
                      "fields": {
                        "summary": "Fix the login"
                      }
                    },
                    "error_message": null,
                    "duration_ms": 412,
                    "created_at": "2026-10-19T12:00:00.000000Z"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/CustomerAccessError"
          },
          "403": {
            "$ref": "#/components/responses/MerchantAccessDenied"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "404": {
            "$ref": "#/components/responses/ToolkitExecutionNotFound"
          }
        }
      }
    },
    "/merchants/tools/executions": {
      "get": {
        "tags": ["Toolkits"],
        "operationId": "listMerchantToolExecutions",
        "summary": "Lists tool executions across all your customers",
        "description": "The merchant overview: the `POST /tools/{tool_slug}/execute` audit rows of all customers, most recent first, with just the Bearer. `customer` and `customer_toolkit` are filters, never credentials: one that isn't yours responds 403. It's the same row as `GET /tools/executions/{uuid}`, with `customer_uuid` saying whose it is.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/MerchantCustomer"
          },
          {
            "name": "customer_toolkit",
            "in": "query",
            "required": false,
            "description": "Only this connection's executions.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "toolkit_slug",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 50
            }
          },
          {
            "name": "tool_slug",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "per_page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 15
            }
          },
          {
            "$ref": "#/components/parameters/Page"
          }
        ],
        "responses": {
          "200": {
            "description": "The executions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["data", "links", "meta"],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ToolkitExecution"
                      }
                    },
                    "links": {
                      "$ref": "#/components/schemas/AdsPageLinks"
                    },
                    "meta": {
                      "$ref": "#/components/schemas/AdsPageMeta"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "description": "The `customer` or the `customer_toolkit` isn't yours, or the connection doesn't belong to the given customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessageError"
                },
                "example": {
                  "message": "This action is unauthorized."
                }
              }
            }
          },
          "422": {
            "description": "An invalid filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                "example": {
                  "errors": {
                    "customer_toolkit": [
                      "The customer toolkit field must be a valid UUID."
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/llm/models": {
      "get": {
        "tags": ["LLM"],
        "operationId": "listLlmModels",
        "summary": "Lists the models the account can use",
        "description": "The models active and enabled for your account, only from providers where you registered your key (`POST /merchants/credentials/{provider}`), in the format of OpenAI's `GET /v1/models`, plus each one's price and limits. The `id` is what goes in `model` (and in `models`) in `POST /llm/chat/completions`.\n\nA call's `max_tokens` can't exceed the model's `max_output_tokens` or your account's cap.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "The enabled models",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": ["object", "data"],
                  "properties": {
                    "object": {
                      "type": "string",
                      "const": "list"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LlmModel"
                      }
                    }
                  }
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": "anthropic/claude-sonnet-5-5",
                      "object": "model",
                      "created": 1792670400,
                      "owned_by": "anthropic",
                      "context_window": 1000000,
                      "max_output_tokens": 128000,
                      "supports_tools": true,
                      "supports_vision": true,
                      "pricing": {
                        "input_per_mtok": 2,
                        "output_per_mtok": 10,
                        "long_context": null
                      }
                    },
                    {
                      "id": "openai/gpt-5.4-mini",
                      "object": "model",
                      "created": 1792670400,
                      "owned_by": "openai",
                      "context_window": 400000,
                      "max_output_tokens": 128000,
                      "supports_tools": true,
                      "supports_vision": true,
                      "pricing": {
                        "input_per_mtok": 0.75,
                        "output_per_mtok": 4.5,
                        "long_context": null
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/LlmForbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/llm/chat/completions": {
      "post": {
        "tags": ["LLM"],
        "operationId": "createLlmChatCompletion",
        "summary": "Generates a model response (OpenAI chat completions)",
        "description": "OpenAI's `POST /v1/chat/completions`, for OpenAI, Anthropic and Meta models. Same body, same response, same stream: the OpenAI SDK works without adaptation (see the LLM tag).\n\n**Before calling the model, Connect checks the call** and refuses, without fixing anything:\n\n| Rule | Refusal |\n|---|---|\n| the account was enabled | `403 llm_not_enabled` |\n| `model` is in `GET /llm/models` | `400 llm_model_not_allowed` |\n| `models`, if sent: at most 3, all in `GET /llm/models` | `400 llm_model_not_allowed` |\n| `max_tokens` (or `max_completion_tokens`) present, positive integer | `400 llm_max_tokens_required` |\n| that value doesn't exceed the account's cap or the `max_output_tokens` of any model in the call | `400 llm_max_tokens_exceeded` |\n| `n` absent or `1`; none of `audio`, `modalities`, `prediction`, `logprobs`, `top_logprobs`, `logit_bias` (empty, `null`, `false` or `0` count as absent) | `400 llm_unsupported_field` |\n| `tools` or `tool_choice` only if every model in the call has `supports_tools`; `image_url` only if every model has `supports_vision` (the `model` and each of `models`) | `400 llm_unsupported_field` |\n| body up to 1 MB | `413` |\n\n**`max_tokens` is required** on every call: it caps the call's cost.\n\n**Fallback.** `models` is an optional list of up to 3 models to try, in order, when the `model` model fails before sending the first token (provider error, limit or timeout). After the first token, the error goes to you. There's never a retry on the same model. The response says in `model` which model answered.\n\n**Stream.** With `stream: true`, the response is `text/event-stream`: one `data: {chunk}` line per piece and `data: [DONE]` at the end, as in OpenAI. The chunk with `usage` only comes if you ask for `stream_options: {\"include_usage\": true}`.\n\n**Without stream.** The response may start with whitespace while the model generates (it keeps the connection alive on long responses). Whitespace before the JSON is still valid JSON, and the OpenAI SDK reads it normally.\n\n**Concurrency.** Each account has a number of calls open at the same time. Above it, `429 llm_concurrency_limit`: wait for one to finish.\n\n**What v1 translates for Anthropic:** `system` and `developer`, text, `image_url`, `tools` and `tool_calls`, `tool_choice` `auto` and `none`, `stop`, `max_tokens`, stream and `usage`. On Anthropic, `temperature`, `top_p` and `top_k` are ignored; on Meta, `frequency_penalty` and `presence_penalty`. On OpenAI, only the fields of this API that the gateway supports go to the provider (`messages`, `temperature`, `top_p`, `frequency_penalty`, `presence_penalty`, `stop`, `seed`, `tools`, `tool_choice`, `parallel_tool_calls`, `response_format`, `reasoning_effort`, `user` and the token limits); others, such as `store`, `service_tier`, `metadata` and `web_search_options`, are dropped. `supports_tools` and `supports_vision` in `GET /llm/models` say what each model supports.\n\n**Error after the response started.** The `200` status goes out with the first token, or with the keepalive whitespace of a non-stream response. An error after that doesn't change the status: with `stream: true`, it arrives as a `data: {\"error\": {...}}` event (the same `LlmError`) and the stream ends **without** `data: [DONE]`; without stream, the `200` body is the error JSON, after the whitespace. Check `error` before reading `choices`. The OpenAI SDK raises an error in both cases.\n\n**Cost.** Connect records each call's tokens and cost, at the `GET /llm/models` price at the time.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LlmChatCompletionRequest"
              },
              "examples": {
                "stream": {
                  "summary": "With stream",
                  "value": {
                    "model": "anthropic/claude-sonnet-5-5",
                    "max_tokens": 1024,
                    "stream": true,
                    "messages": [
                      {
                        "role": "system",
                        "content": "You summarize marketing data in English."
                      },
                      {
                        "role": "user",
                        "content": "Summarize the account's week."
                      }
                    ]
                  }
                },
                "fallback_tools": {
                  "summary": "With fallback and tools",
                  "value": {
                    "model": "openai/gpt-5.4-mini",
                    "models": ["anthropic/claude-haiku-5-5"],
                    "max_tokens": 512,
                    "messages": [
                      {
                        "role": "user",
                        "content": "What was yesterday's reach?"
                      }
                    ],
                    "tools": [
                      {
                        "type": "function",
                        "function": {
                          "name": "get_reach",
                          "description": "Account reach on a given day",
                          "parameters": {
                            "type": "object",
                            "properties": {
                              "date": {
                                "type": "string",
                                "format": "date"
                              }
                            },
                            "required": ["date"]
                          }
                        }
                      }
                    ],
                    "tool_choice": "auto"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The model's response: JSON without stream, `text/event-stream` with `stream: true`. An error after the response started also goes out with `200`: see \"Error after the response started\" above.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/LlmChatCompletion"
                    },
                    {
                      "$ref": "#/components/schemas/LlmError"
                    }
                  ]
                },
                "example": {
                  "id": "chatcmpl-9f2c4e1a",
                  "object": "chat.completion",
                  "created": 1792670400,
                  "model": "anthropic/claude-sonnet-5-5",
                  "choices": [
                    {
                      "index": 0,
                      "message": {
                        "role": "assistant",
                        "content": "This week, reach rose 12%."
                      },
                      "finish_reason": "stop"
                    }
                  ],
                  "usage": {
                    "prompt_tokens": 42,
                    "completion_tokens": 11,
                    "total_tokens": 53
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "`data: ` lines with one `LlmChatCompletionChunk` in JSON each, separated by a blank line, ending in `data: [DONE]`. If generation fails midway, the last event is `data: {\"error\": {...}}` (an `LlmError`) and no `data: [DONE]` comes.",
                  "contentMediaType": "text/event-stream",
                  "x-chunk": {
                    "$ref": "#/components/schemas/LlmChatCompletionChunk"
                  }
                },
                "example": "data: {\"id\":\"chatcmpl-9f2c4e1a\",\"object\":\"chat.completion.chunk\",\"created\":1792670400,\"model\":\"anthropic/claude-sonnet-5-5\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"This week\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-9f2c4e1a\",\"object\":\"chat.completion.chunk\",\"created\":1792670400,\"model\":\"anthropic/claude-sonnet-5-5\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\", reach rose 12%.\"},\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n"
              }
            }
          },
          "400": {
            "description": "The call was refused before reaching the model. `error.code`:\n\n- `llm_model_not_allowed`, `llm_max_tokens_required`, `llm_max_tokens_exceeded`: the rules in the table above;\n- `llm_credential_missing`: the account hasn't registered the provider key for a model in the call (the `model` or one of `models`);\n- `llm_provider_credential_invalid`: the provider refused the key registered by the account (provider 401). Replace it with `PUT /merchants/credentials/{provider}`. A provider 403, which usually comes with a valid key (no access to the model), arrives as `llm_provider_error`;\n- `llm_unsupported_field`: a field from the table above, `tools` or `image_url` on a model in the call without `supports_tools` or `supports_vision`, or something the chosen model doesn't support (on Anthropic: JSON `response_format`, audio or file parts, `tools` that aren't `function`);\n- `llm_invalid_request`: the body isn't a JSON object, or `messages` doesn't have the OpenAI shape, or some content has no translation for the model;\n- `llm_provider_error`: the provider refused the request. Comes with the provider's status and message (usually `400`; other `4XX` below).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmError"
                },
                "example": {
                  "error": {
                    "message": "`max_tokens` is above the limit of 4096 for this account and model.",
                    "type": "invalid_request_error",
                    "code": "llm_max_tokens_exceeded"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthenticated"
          },
          "403": {
            "$ref": "#/components/responses/LlmForbidden"
          },
          "413": {
            "description": "The body exceeds 1 MB (`llm_request_too_large`). A much larger body may be refused earlier, by the web server, with no JSON body.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmError"
                },
                "example": {
                  "error": {
                    "message": "The request body is above the limit of 1024 KB.",
                    "type": "invalid_request_error",
                    "code": "llm_request_too_large"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Account request limit (`{\"message\"}`, as in the rest of the API) or concurrent calls above the account's limit (`llm_concurrency_limit`). Wait for a call to finish and try again.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/LlmError"
                    },
                    {
                      "$ref": "#/components/schemas/MessageError"
                    }
                  ]
                },
                "example": {
                  "error": {
                    "message": "Too many concurrent requests for this account.",
                    "type": "rate_limit_error",
                    "code": "llm_concurrency_limit"
                  }
                }
              }
            }
          },
          "4XX": {
            "description": "The provider refused the request with another client status (for example `404` or `422`): `llm_provider_error`, with the provider's status and message. Fix the request before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmError"
                },
                "example": {
                  "error": {
                    "message": "The model provider rejected the request.",
                    "type": "not_found_error",
                    "code": "llm_provider_error"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Our failure handling the call (`llm_internal_error`). You can retry; if it persists, contact support.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmError"
                },
                "example": {
                  "error": {
                    "message": "The request could not be completed.",
                    "type": "api_error",
                    "code": "llm_internal_error"
                  }
                }
              }
            }
          },
          "502": {
            "description": "The model didn't respond (`llm_upstream_error`): the provider failed or is down and no model from `models` was left to try, or the provider refused Connect's credential. It's not a problem with your call: try again later.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmError"
                },
                "example": {
                  "error": {
                    "message": "The model provider failed to answer.",
                    "type": "api_error",
                    "code": "llm_upstream_error"
                  }
                }
              }
            }
          },
          "503": {
            "description": "The gateway is unavailable on this server (`llm_offload_not_configured`). It's not a problem with your call: contact support.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmError"
                },
                "example": {
                  "error": {
                    "message": "LLM offload is not configured on this server, see AGENTS.md",
                    "type": "api_error",
                    "code": "llm_offload_not_configured"
                  }
                }
              }
            }
          },
          "504": {
            "description": "The model took too long (`llm_timeout`): 30s to the first token, 60s without a new token or 300s in total.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LlmError"
                },
                "example": {
                  "error": {
                    "message": "The model took too long to answer.",
                    "type": "api_error",
                    "code": "llm_timeout"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "customer_integration.status_updated": {
      "post": {
        "tags": ["Webhooks"],
        "summary": "A connection changed status",
        "description": "The connection expired, was revoked or started working again. `previous_attributes.status` carries the previous status.",
        "parameters": [
          {
            "name": "Connect-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix>,v1=<hex>`, with an extra `v1` for the 24 hours following a secret rotation.",
            "example": "t=1791300000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_01k7a9x1c3e5g7j9k1m3p5r7t9",
                "object": "event",
                "type": "customer_integration.status_updated",
                "api_version": "v1",
                "created": 1791300000,
                "livemode": true,
                "data": {
                  "object": {
                    "uuid": "5d1c3b9a-2e7f-4c1d-8a6b-0f3e9d2c7b14",
                    "source_id": "17841400000000000",
                    "source_name": "conta_exemplo",
                    "status": "expired",
                    "integration": {
                      "name": "Instagram Business",
                      "slug": "instagram_business"
                    }
                  },
                  "previous_attributes": {
                    "status": "active"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Any other response, or none within 10 seconds, counts as a failure and the event is resent."
          },
          "410": {
            "description": "Disables the endpoint immediately."
          }
        }
      }
    },
    "customer_integration.deleted": {
      "post": {
        "tags": ["Webhooks"],
        "summary": "A connection was removed",
        "description": "`data.object` is the connection as it was before being removed.",
        "parameters": [
          {
            "name": "Connect-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix>,v1=<hex>`, with an extra `v1` for the 24 hours following a secret rotation.",
            "example": "t=1791300000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_01k7a9x1c3e5g7j9k1m3p5r7t9",
                "object": "event",
                "type": "customer_integration.deleted",
                "api_version": "v1",
                "created": 1791300000,
                "livemode": true,
                "data": {
                  "object": {
                    "uuid": "5d1c3b9a-2e7f-4c1d-8a6b-0f3e9d2c7b14",
                    "source_id": "17841400000000000",
                    "source_name": "conta_exemplo",
                    "status": "active",
                    "integration": {
                      "name": "Instagram Business",
                      "slug": "instagram_business"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Any other response, or none within 10 seconds, counts as a failure and the event is resent."
          },
          "410": {
            "description": "Disables the endpoint immediately."
          }
        }
      }
    },
    "integration_session.oauth_started": {
      "post": {
        "tags": ["Webhooks"],
        "summary": "The customer started authorizing a platform",
        "description": "The customer opened a platform's authorization within the integration session.",
        "parameters": [
          {
            "name": "Connect-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix>,v1=<hex>`, with an extra `v1` for the 24 hours following a secret rotation.",
            "example": "t=1791300000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_01k7a9x1c3e5g7j9k1m3p5r7t9",
                "object": "event",
                "type": "integration_session.oauth_started",
                "api_version": "v1",
                "created": 1791300000,
                "livemode": true,
                "data": {
                  "object": {
                    "uuid": "c1b2a3d4-0000-4000-8000-000000000001",
                    "customer_uuid": "7f3a9c2e-1b4d-4e8f-a6c0-2d5b8e1f3a79",
                    "integration_slug": "instagram_business"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Any other response, or none within 10 seconds, counts as a failure and the event is resent."
          },
          "410": {
            "description": "Disables the endpoint immediately."
          }
        }
      }
    },
    "integration_session.oauth_saved": {
      "post": {
        "tags": ["Webhooks"],
        "summary": "The customer finished authorizing an account",
        "description": "An account was connected within the integration session. `integration_uuid` is the `uuid` of the created connection.",
        "parameters": [
          {
            "name": "Connect-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix>,v1=<hex>`, with an extra `v1` for the 24 hours following a secret rotation.",
            "example": "t=1791300000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_01k7a9x1c3e5g7j9k1m3p5r7t9",
                "object": "event",
                "type": "integration_session.oauth_saved",
                "api_version": "v1",
                "created": 1791300000,
                "livemode": true,
                "data": {
                  "object": {
                    "uuid": "c1b2a3d4-0000-4000-8000-000000000001",
                    "customer_uuid": "7f3a9c2e-1b4d-4e8f-a6c0-2d5b8e1f3a79",
                    "integration_uuid": "5d1c3b9a-2e7f-4c1d-8a6b-0f3e9d2c7b14",
                    "integration_slug": "instagram_business",
                    "source_name": "conta_exemplo",
                    "status": "active"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Any other response, or none within 10 seconds, counts as a failure and the event is resent."
          },
          "410": {
            "description": "Disables the endpoint immediately."
          }
        }
      }
    },
    "integration_session.completed": {
      "post": {
        "tags": ["Webhooks"],
        "summary": "The customer finished the integration session",
        "description": "The customer closed the session after connecting what they wanted.",
        "parameters": [
          {
            "name": "Connect-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "`t=<unix>,v1=<hex>`, with an extra `v1` for the 24 hours following a secret rotation.",
            "example": "t=1791300000,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "evt_01k7a9x1c3e5g7j9k1m3p5r7t9",
                "object": "event",
                "type": "integration_session.completed",
                "api_version": "v1",
                "created": 1791300000,
                "livemode": true,
                "data": {
                  "object": {
                    "uuid": "c1b2a3d4-0000-4000-8000-000000000001",
                    "customer_uuid": "7f3a9c2e-1b4d-4e8f-a6c0-2d5b8e1f3a79"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "2XX": {
            "description": "Received. Any other response, or none within 10 seconds, counts as a failure and the event is resent."
          },
          "410": {
            "description": "Disables the endpoint immediately."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "The merchant's API key. Goes on every request, except the connection DELETE."
      },
      "customerToken": {
        "type": "apiKey",
        "in": "header",
        "name": "x-customer-token",
        "description": "The `api_token` returned when the customer is created. Restricts the call to that customer."
      }
    },
    "parameters": {
      "MediaIdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Your key, unique per file (up to 255 characters). Generate it once, before the first attempt, and resend the same one on every retry.\n\n- Same key and same request: `200` with the stored media and the `Idempotent-Replay: true` header, without storing again.\n- Same key with a different request: `422 idempotency_key_reused`.",
        "schema": {
          "type": "string",
          "maxLength": 255,
          "example": "media-8812"
        }
      },
      "WebhookEndpointUuid": {
        "name": "uuid",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string",
          "format": "uuid"
        },
        "description": "The endpoint's `id`, as returned on creation."
      },
      "Page": {
        "name": "page",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        }
      },
      "PerPage": {
        "name": "per_page",
        "in": "query",
        "required": false,
        "description": "The API doesn't enforce a maximum. Request reasonable pages.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 15
        }
      },
      "SortBy": {
        "name": "sortBy",
        "in": "query",
        "required": false,
        "description": "Column name. The value `rand` sorts randomly.",
        "schema": {
          "type": "string"
        }
      },
      "Descending": {
        "name": "descending",
        "in": "query",
        "required": false,
        "schema": {
          "type": "boolean",
          "default": false
        }
      },
      "CustomerUuid": {
        "name": "uuid",
        "in": "path",
        "required": true,
        "description": "The customer's `uuid`.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "IntegrationUuid": {
        "name": "uuid",
        "in": "path",
        "required": true,
        "description": "The `uuid` of the customer's connection.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "AdsCustomerIntegration": {
        "name": "customer_integration",
        "in": "query",
        "required": true,
        "description": "The connection's `uuid`. Identifies the ad account and the integration. Goes **always in the query**, on every ads route; in the body it's ignored.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "AdsObjectId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "The object's `id`, the numeric one the ad platform gave it (on Meta, the same as in Ads Manager), which works for any object in the account; or the Connect `uuid`, which works for the ones Connect stores.",
        "schema": {
          "type": "string",
          "example": "120250000000000001"
        }
      },
      "AdsIdempotencyKeyRequired": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Your key, unique per operation (up to 255 characters). **Always in the header, never in the body.** Generate it once, before the first attempt, and resend the same one on every retry: a new key on each attempt creates everything again.\n\n- Same key and same request: returns `200` with the first response's body and the `Idempotent-Replay: true` header, without touching the integration.\n- Same key with a different request: `422 idempotency_key_reused`.\n- Same key while the first one is still running: `409 operation_in_progress`, with `Retry-After`.\n- Same key after a failure: **resumes**. What the first attempt already created is reused, not created again.",
        "schema": {
          "type": "string",
          "maxLength": 255,
          "example": "order-8812-ad-1"
        }
      },
      "AdsIdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Optional here. With it, repeating the call returns the first response instead of writing again. Same `Idempotency-Key` rules as for creations. **Always in the header.**",
        "schema": {
          "type": "string",
          "maxLength": 255,
          "example": "order-8812-ad-1"
        }
      },
      "AdsSource": {
        "name": "source",
        "in": "query",
        "required": false,
        "description": "`connect` (default) reads from Connect's database: what Connect created or has already written in this account, like `GET /posts`. `external` reads the account live from the integration, including what was created outside Connect.\n\nAn account that already had campaigns before Connect **lists empty** with `connect` until the first write through Connect. This is expected: use `external` to see what exists in the account.",
        "schema": {
          "type": "string",
          "enum": ["connect", "external"],
          "default": "connect"
        }
      },
      "AdsRefresh": {
        "name": "refresh",
        "in": "query",
        "required": false,
        "description": "With `source=connect`, re-reads this response's objects from the integration and updates `status`, `effective_status`, `issues`, `name` and `synced_at` (an object that disappeared gets `deleted_at`). With `source=external`, bypasses the 120 s cache.",
        "schema": {
          "type": "boolean"
        }
      },
      "AdsEffectiveStatus": {
        "name": "effective_status",
        "in": "query",
        "required": false,
        "description": "Filters by the last `effective_status` Connect saw, such as `pending_review`, `disapproved` or `with_issues`. Only with `source=connect`.",
        "schema": {
          "type": "string",
          "enum": [
            "active",
            "paused",
            "deleted",
            "archived",
            "in_process",
            "with_issues",
            "campaign_paused",
            "adset_paused",
            "disapproved",
            "pending_review",
            "preapproved",
            "pending_billing_info"
          ]
        }
      },
      "MerchantCustomer": {
        "name": "customer",
        "in": "query",
        "required": false,
        "description": "The `uuid` of one of your customers. Without it, the response includes all customers.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "MerchantCustomerIntegration": {
        "name": "customer_integration",
        "in": "query",
        "required": false,
        "description": "The `uuid` of a connection of one of your customers, to narrow to its account only. With `customer`, the connection must belong to that customer.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "MerchantAdsRefresh": {
        "name": "refresh",
        "in": "query",
        "required": false,
        "description": "Re-reads this response's objects from the integration and updates `status`, `effective_status`, `issues`, `name` and `synced_at` (an object that disappeared gets `deleted_at`). Requires `customer_integration`, the connection through which the account is read.",
        "schema": {
          "type": "boolean"
        }
      },
      "AdsPerPage": {
        "name": "per_page",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 15
        }
      },
      "PostsCustomerIntegration": {
        "name": "customer_integration",
        "in": "query",
        "required": false,
        "description": "The connection's `uuid`. Identifies the account. Always goes in the query; in the body it's ignored. Alternative to naming the account: sending both is refused with `422`.",
        "schema": {
          "type": "string",
          "format": "uuid"
        }
      },
      "PostsSourceName": {
        "name": "source_name",
        "in": "query",
        "required": false,
        "description": "The connected account's name (the connection's `source_name`). Required without `customer_integration`.",
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      },
      "PostsIdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Your key, unique per post (up to 255 characters). Generate it once, before the first attempt, and resend the same one on every retry.\n\n- Same key and same request: `200` with the stored post and the `Idempotent-Replay: true` header, without publishing again.\n- Same key with a different request (body or connection): `422 idempotency_key_reused`.",
        "schema": {
          "type": "string",
          "maxLength": 255,
          "example": "post-4410"
        }
      }
    },
    "schemas": {
      "MediaMedia": {
        "type": "object",
        "required": [
          "uuid",
          "customer_uuid",
          "status",
          "type",
          "mime_type",
          "name",
          "size_bytes",
          "url",
          "expires_at",
          "upload",
          "created_at"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "customer_uuid": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": ["uploading", "ready"],
            "description": "`uploading` while an upload in parts hasn't been completed; `ready` when the file is stored and has a `url`."
          },
          "type": {
            "type": ["string", "null"],
            "enum": ["image", "video", null],
            "description": "Read from the file. In an upload in parts, it only exists after part 1."
          },
          "mime_type": {
            "type": ["string", "null"],
            "enum": [
              "image/jpeg",
              "image/png",
              "image/webp",
              "image/gif",
              "video/mp4",
              "video/quicktime",
              null
            ]
          },
          "name": {
            "type": "string",
            "description": "The name the file was uploaded with."
          },
          "size_bytes": {
            "type": "integer"
          },
          "url": {
            "type": ["string", "null"],
            "format": "uri",
            "description": "Where the file is read, until `expires_at`, on Connect's public domain. Only exists with `status` `ready`, and is the same on every read. Anyone with the link can read the file: treat it as a secret until you publish.",
            "example": "https://file.connect.reportei.com/media/2f0c.../8b1e....jpg"
          },
          "expires_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "When the URL stops being valid and the file is deleted: 30 days after the media becomes ready."
          },
          "upload": {
            "type": ["object", "null"],
            "description": "The upload in parts that is still open. `null` for a single-request upload and after completion.",
            "required": ["part_size", "parts", "expires_at"],
            "properties": {
              "part_size": {
                "type": "integer",
                "description": "Bytes per part. The last one carries the remainder."
              },
              "parts": {
                "type": "integer",
                "description": "How many parts the file has, numbered from 1."
              },
              "expires_at": {
                "type": "string",
                "format": "date-time",
                "description": "Until when the upload can be completed. After that, the parts are discarded."
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookEventType": {
        "type": "string",
        "enum": [
          "customer_integration.status_updated",
          "customer_integration.deleted",
          "integration_session.oauth_started",
          "integration_session.oauth_saved",
          "integration_session.completed"
        ],
        "description": "An event type. The exact list your account can subscribe to comes in `available_events`, in `GET /webhooks/endpoints`."
      },
      "WebhookEndpoint": {
        "type": "object",
        "description": "An address in your account that receives events, with its health state.",
        "required": ["id", "url", "events", "active", "consecutive_failures"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": ["string", "null"]
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "active": {
            "type": "boolean",
            "description": "An inactive endpoint still exists and stops receiving."
          },
          "disabled_at": {
            "type": ["string", "null"],
            "description": "When it was disabled.",
            "example": "2026-10-13 12:00:00"
          },
          "disabled_reason": {
            "type": ["string", "null"],
            "enum": ["failures", "gone", "manual", null],
            "description": "`failures`: 72 hours failing nonstop. `gone`: the address responded 410. `manual`: disabled by you."
          },
          "consecutive_failures": {
            "type": "integer",
            "description": "Consecutive events that exhausted their attempts. Resets to zero on the first successful delivery."
          },
          "first_failure_at": {
            "type": ["string", "null"],
            "description": "Start of the current failure streak. Null while the endpoint is healthy.",
            "example": "2026-10-13 12:00:00"
          },
          "last_failure_at": {
            "type": ["string", "null"],
            "description": "Last failed attempt.",
            "example": "2026-10-13 12:00:00"
          },
          "last_success_at": {
            "type": ["string", "null"],
            "description": "Last successful delivery.",
            "example": "2026-10-13 12:00:00"
          },
          "created_at": {
            "type": ["string", "null"],
            "description": "Creation.",
            "example": "2026-10-13 12:00:00"
          },
          "updated_at": {
            "type": ["string", "null"],
            "description": "Last change.",
            "example": "2026-10-13 12:00:00"
          },
          "secret": {
            "type": "string",
            "description": "Present only on creation and rotation. Signs the deliveries: see the Webhooks section.",
            "example": "whsec_q8X0m3VbT1sYwJ4nK6pZr2uLc9hE5aGf7dNtR0oIyMk"
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "description": "An attempt to deliver an event to an endpoint.",
        "required": ["id", "attempt", "status"],
        "properties": {
          "id": {
            "type": "string",
            "description": "With the `dlv_` prefix."
          },
          "event_id": {
            "type": ["string", "null"],
            "description": "The `id` of the delivered event. Null on a test send."
          },
          "event_type": {
            "type": ["string", "null"]
          },
          "attempt": {
            "type": "integer",
            "description": "Attempt number. Also increases between one manual resend and the next."
          },
          "status": {
            "type": "string",
            "enum": ["pending", "succeeded", "failed", "exhausted"],
            "description": "`pending`: scheduled. `failed`: failed and another attempt is scheduled. `exhausted`: failed and there are no more attempts."
          },
          "response_status": {
            "type": ["integer", "null"],
            "description": "The HTTP status your address responded with."
          },
          "response_excerpt": {
            "type": ["string", "null"],
            "description": "Up to 1024 bytes of the body your address responded with."
          },
          "error": {
            "type": ["string", "null"],
            "description": "When there was no usable response: `timeout`, `connection`, `redirect`, `unsafe_address` (the domain doesn't resolve or points to a private network) or `endpoint_disabled`."
          },
          "duration_ms": {
            "type": ["integer", "null"]
          },
          "next_attempt_at": {
            "type": ["string", "null"],
            "description": "When a pending attempt will be made.",
            "example": "2026-10-13 12:00:00"
          },
          "created_at": {
            "type": ["string", "null"],
            "description": "Creation.",
            "example": "2026-10-13 12:00:00"
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "description": "The body of every delivery. `data.object` is the resource as its `GET` returns it, at the time of the event.",
        "required": [
          "id",
          "object",
          "type",
          "api_version",
          "created",
          "livemode",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "With the `evt_` prefix. Stable across resends: use it to deduplicate."
          },
          "object": {
            "type": "string",
            "const": "event"
          },
          "type": {
            "type": "string"
          },
          "api_version": {
            "type": "string",
            "const": "v1"
          },
          "created": {
            "type": "integer",
            "description": "Unix timestamp of when the event happened."
          },
          "livemode": {
            "type": "boolean",
            "description": "`false` only on test sends."
          },
          "data": {
            "type": "object",
            "required": ["object"],
            "properties": {
              "object": {
                "type": ["object", "null"],
                "description": "The resource. Null on a test when the account had no event of that type in the last 30 days."
              },
              "previous_attributes": {
                "type": "object",
                "description": "On `customer_integration.status_updated`: the previous `status`."
              },
              "error": {
                "type": "object",
                "description": "On `customer_integration.status_updated`, when the change came from a token verification failure: the error returned by the platform."
              }
            }
          }
        }
      },
      "MerchantSettings": {
        "type": "object",
        "required": [
          "uuid",
          "name",
          "app_url",
          "redirect_url",
          "logo_url",
          "trial_ends_at",
          "is_paying",
          "created_at",
          "updated_at",
          "total_customers",
          "available_integrations"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "app_url": {
            "type": "string"
          },
          "redirect_url": {
            "type": "string"
          },
          "logo_url": {
            "type": ["string", "null"]
          },
          "trial_ends_at": {
            "type": ["string", "null"],
            "description": "ISO-8601. Differs from `created_at`/`updated_at`, which come in `Y-m-d H:i:s` format."
          },
          "is_paying": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "examples": ["2026-09-02 17:07:26"]
          },
          "updated_at": {
            "type": "string",
            "examples": ["2026-09-02 17:07:26"]
          },
          "rate_limit_per_minute": {
            "type": "string",
            "description": "Absent when the account has no limits configuration. String, not number."
          },
          "rate_limit_per_second": {
            "type": "string"
          },
          "total_customers": {
            "type": "integer"
          },
          "available_integrations": {
            "type": "array",
            "description": "What the merchant's plan enables.",
            "items": {
              "type": "object",
              "required": ["name", "slug"],
              "properties": {
                "name": {
                  "type": "string"
                },
                "slug": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Customer": {
        "type": "object",
        "required": [
          "uuid",
          "name",
          "created_at",
          "updated_at",
          "trial_ends_at",
          "is_paying",
          "merchant"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "examples": ["2026-09-02 17:07:34"]
          },
          "updated_at": {
            "type": "string",
            "examples": ["2026-09-02 17:07:34"]
          },
          "trial_ends_at": {
            "type": ["string", "null"],
            "examples": ["2026-09-16 17:07:34"],
            "description": "Legacy: only merchants still billed per paying customer use it. For every other merchant the customer is created as paying and this never changes."
          },
          "is_paying": {
            "type": "boolean",
            "description": "Legacy: only merchants still billed per paying customer use it. For every other merchant the customer is created as paying and this never changes."
          },
          "merchant": {
            "type": "string",
            "description": "Merchant name, not an object."
          }
        }
      },
      "CustomerCreated": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Customer"
          },
          {
            "type": "object",
            "required": ["api_token"],
            "properties": {
              "api_token": {
                "type": "string",
                "description": "64 hexadecimal characters. The value of this customer's `x-customer-token` header. **Returned only here, and unrecoverable.**"
              }
            }
          }
        ]
      },
      "CustomerWithIntegrations": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Customer"
          },
          {
            "type": "object",
            "required": ["integrations"],
            "properties": {
              "integrations": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": ["uuid", "integration", "name", "slug", "status"],
                  "properties": {
                    "uuid": {
                      "type": "string",
                      "format": "uuid",
                      "description": "This is the uuid the metrics endpoints ask for."
                    },
                    "integration": {
                      "type": ["string", "null"],
                      "description": "Platform name."
                    },
                    "name": {
                      "type": "string",
                      "description": "Connected account name."
                    },
                    "slug": {
                      "type": ["string", "null"]
                    },
                    "status": {
                      "$ref": "#/components/schemas/IntegrationStatus"
                    },
                    "icon": {
                      "type": ["object", "null"],
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "color": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "CustomerIntegration": {
        "type": "object",
        "required": [
          "uuid",
          "source_id",
          "source_name",
          "status",
          "created_at",
          "updated_at",
          "integration"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "source_id": {
            "type": "string",
            "description": "Account identifier on the source platform."
          },
          "source_name": {
            "type": "string",
            "description": "Connected account name."
          },
          "status": {
            "$ref": "#/components/schemas/IntegrationStatus"
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          },
          "currency": {
            "type": "string",
            "description": "Present only on ad platforms that report currency."
          },
          "email": {
            "type": ["string", "null"]
          },
          "profile_picture_url": {
            "type": ["string", "null"],
            "format": "uri",
            "description": "The account's profile picture, ready to use in an <img>. Filled for Facebook Pages and for Meta Ads accounts, which use the picture of the Page they advertise. It's null on other platforms and in the first moments after integrating, while the picture is fetched."
          },
          "integration": {
            "type": "object",
            "required": ["name", "slug"],
            "properties": {
              "name": {
                "type": "string"
              },
              "slug": {
                "type": "string"
              }
            }
          }
        }
      },
      "IntegrationStatus": {
        "type": "string",
        "enum": [
          "active",
          "expired",
          "revoked",
          "synchronizing",
          "synchronization_error"
        ],
        "description": "Only `active` produces metrics. `expired` and `revoked` require the customer to reauthorize through a new session."
      },
      "IntegrationSessionRequest": {
        "type": "object",
        "properties": {
          "redirect_url": {
            "type": "string",
            "format": "uri",
            "description": "Where to send the customer at the end of authorization. Only `http` and `https`."
          },
          "locale": {
            "type": "string",
            "enum": ["pt_BR", "en", "es", "fr"],
            "description": "Language of the authorization screen."
          },
          "expires_in_minutes": {
            "type": "integer",
            "minimum": 1,
            "default": 5
          },
          "close_on_finish": {
            "type": "boolean",
            "default": false,
            "description": "Closes the tab when finished, instead of redirecting."
          },
          "enable_multi_account_selection": {
            "type": "boolean",
            "default": false
          },
          "limit_reached_url": {
            "type": "string",
            "format": "uri",
            "description": "Only `http` and `https`."
          },
          "limits": {
            "type": "array",
            "description": "Restrictions applied during authorization. An unsupported name isn't refused here: it fails later, inside the screen.",
            "items": {
              "$ref": "#/components/schemas/ResourceLimit"
            }
          },
          "toolkit_slug": {
            "type": "string",
            "description": "Opens the session on a toolkit (`slug` from `GET /toolkits`) instead of the platform catalog: the screen is the toolkit's credential form, or the app's consent when it connects via OAuth. Doesn't accept `source_slug` alongside. A toolkit with `oauth2` mode only connects through consent with your app registered for it in `POST /merchants/credentials/{toolkit_slug}` (the `/merchants/credentials` route, with the toolkit slug in place of `integration_slug`): without that registration, an OAuth-only toolkit is refused with 422 `toolkit_credential_missing`, and a toolkit with both modes shows the key form. When done, the customer returns to the `redirect_url` with `?customer_toolkit={uuid}`."
          },
          "source_slug": {
            "type": "string",
            "description": "Opens the session directly on a platform. Only takes effect together with `source_ids`."
          },
          "source_ids": {
            "type": "array",
            "description": "Already known accounts, to reuse authorization across customers of the same merchant.",
            "items": {
              "type": "object",
              "required": ["customer_uuid", "source_id"],
              "properties": {
                "customer_uuid": {
                  "type": "string",
                  "format": "uuid"
                },
                "source_id": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ResourceLimit": {
        "type": "object",
        "required": ["name", "value"],
        "properties": {
          "name": {
            "type": "string",
            "enum": [
              "integration_count",
              "same_type_integration",
              "same_integration_across_customers",
              "available_integrations"
            ]
          },
          "value": {
            "description": "An integer for the first three; an array of slugs for `available_integrations`.",
            "oneOf": [
              {
                "type": "integer",
                "minimum": 1
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          }
        }
      },
      "IntegrationSession": {
        "type": "object",
        "required": [
          "session_uuid",
          "session_link",
          "expires_at",
          "merchant",
          "merchant_uuid",
          "customer",
          "customer_uuid",
          "close_on_finish",
          "enable_multi_account_selection"
        ],
        "properties": {
          "session_uuid": {
            "type": "string",
            "format": "uuid"
          },
          "session_link": {
            "type": "string",
            "format": "uri",
            "description": "The URL to send the customer to. It's the only field your application needs to use."
          },
          "expires_at": {
            "type": "string",
            "description": "ISO-8601."
          },
          "merchant": {
            "type": "string"
          },
          "merchant_uuid": {
            "type": "string",
            "format": "uuid"
          },
          "customer": {
            "type": "string"
          },
          "customer_uuid": {
            "type": "string",
            "format": "uuid"
          },
          "redirect_url": {
            "type": ["string", "null"]
          },
          "close_on_finish": {
            "type": "boolean"
          },
          "locale": {
            "type": ["string", "null"]
          },
          "limits": {
            "type": ["array", "null"],
            "items": {
              "$ref": "#/components/schemas/ResourceLimit"
            }
          },
          "limit_reached_url": {
            "type": ["string", "null"]
          },
          "enable_multi_account_selection": {
            "type": "boolean"
          },
          "toolkit_slug": {
            "type": "string",
            "description": "Present only in a toolkit session."
          },
          "source_slug": {
            "type": "string",
            "description": "Present only when sent together with `source_ids`."
          },
          "source_ids": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "MetricsRequest": {
        "type": "object",
        "required": ["start", "end", "metrics"],
        "description": "Send `customer_integration` or `customer_integration_uuids`: one of the two is required.",
        "properties": {
          "customer_integration": {
            "type": "string",
            "format": "uuid",
            "description": "One connection. `uuid` from `/customers/settings`."
          },
          "customer_integration_uuids": {
            "type": "array",
            "description": "Multiple connections in the same call. All belonging to the token's customer.",
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "start": {
            "type": "string",
            "format": "date",
            "description": "Must be less than or equal to `end`."
          },
          "end": {
            "type": "string",
            "format": "date"
          },
          "comparison_start": {
            "type": "string",
            "format": "date",
            "description": "Comparison period. Only considered if `comparison_end` is also sent."
          },
          "comparison_end": {
            "type": "string",
            "format": "date"
          },
          "client_timezone": {
            "type": "string",
            "default": "America/Sao_Paulo",
            "description": "Timezone identifier, such as `America/Sao_Paulo`."
          },
          "metrics": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/MetricRequestItem"
            }
          }
        }
      },
      "MetricRequestItem": {
        "type": "object",
        "required": ["id", "reference_key", "component", "metrics"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "**Must be a uuid.** It's the key under which the result comes back, so generate one per requested metric."
          },
          "reference_key": {
            "type": "string",
            "description": "The metric's identifier on the platform, such as `ig:story_replies`. Find the available ones in Connect Explorer.",
            "examples": ["ig:story_replies", "ig:followers_gender"]
          },
          "component": {
            "type": "string",
            "description": "Result format. Determines the shape of the returned value.",
            "examples": ["number_v1", "chart_v1", "datatable_v1"]
          },
          "metrics": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "string"
            },
            "description": "The values requested within that metric."
          },
          "dimensions": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Result breakdown."
          },
          "entity_id": {
            "type": "string"
          },
          "entity_type": {
            "type": "string"
          }
        }
      },
      "MetricFailure": {
        "type": "object",
        "description": "Replaces the result of a metric that failed on its own. The request stays 200: the other metrics in the batch come normally.",
        "required": ["message", "type"],
        "properties": {
          "message": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "invalid_metrics_combination",
              "no_data_in_period",
              "internal_error",
              "expired_token"
            ]
          }
        }
      },
      "PaginationMeta": {
        "type": "object",
        "description": "There are no `links`. `sortBy` and `descending` echo the parameters sent.",
        "required": ["current_page", "last_page", "path", "per_page", "total"],
        "properties": {
          "current_page": {
            "type": "integer"
          },
          "from": {
            "type": ["integer", "null"]
          },
          "last_page": {
            "type": "integer"
          },
          "path": {
            "type": "string"
          },
          "per_page": {
            "type": ["integer", "string"]
          },
          "to": {
            "type": ["integer", "null"]
          },
          "total": {
            "type": "integer"
          },
          "sortBy": {
            "type": ["string", "null"]
          },
          "descending": {
            "type": ["boolean", "string"]
          }
        }
      },
      "SuccessMessage": {
        "type": "object",
        "required": ["success", "message"],
        "properties": {
          "success": {
            "type": "boolean",
            "const": true
          },
          "message": {
            "type": "string"
          }
        }
      },
      "FailureMessage": {
        "type": "object",
        "required": ["success", "message"],
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "message": {
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "MessageError": {
        "type": "object",
        "required": ["message", "error_code"],
        "properties": {
          "message": {
            "type": "string"
          },
          "error_code": {
            "type": "string",
            "description": "Stable identifier of the refusal. Every error response has one. Branch and translate on it, not on the message.",
            "example": "ads_object_not_found"
          }
        }
      },
      "FormValidationError": {
        "type": "object",
        "description": "The most common validation envelope: a map of field to list of messages.",
        "required": ["message", "error_code", "errors"],
        "properties": {
          "message": {
            "type": "string",
            "example": "The given data was invalid."
          },
          "error_code": {
            "type": "string",
            "example": "validation_error"
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "supported_values": {
            "type": "object",
            "description": "Present when a refused field is an enum: lists, for each failed field, what was accepted. A nested field responds under its prefix: `targeting.genders` shows up as `targeting`.",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "MetricsValidationError": {
        "type": "object",
        "description": "The other 422 envelope, used by the metrics endpoints' refusals.",
        "required": ["message", "error_code"],
        "properties": {
          "message": {
            "type": "string"
          },
          "error_code": {
            "type": "string",
            "description": "Stable identifier of the refusal: `validation_error`, `integration_expired` (expired connection), `trial_history_limit` or `trial_metrics_limit`.",
            "example": "validation_error"
          },
          "extra": {
            "description": "Context of the refusal. For an expired connection, carries `integration_status`.",
            "type": ["object", "null"],
            "additionalProperties": true
          },
          "max_history_days": {
            "type": "integer",
            "description": "Only on `trial_history_limit`: how many days back the trial reads."
          },
          "oldest_start": {
            "type": "string",
            "format": "date",
            "description": "Only on `trial_history_limit`: the oldest `start` accepted."
          },
          "max_metrics": {
            "type": "integer",
            "description": "Only on `trial_metrics_limit`: how many `metrics` items are accepted per request."
          }
        }
      },
      "DiscoveryListMeta": {
        "type": "object",
        "required": ["cached", "cached_at"],
        "properties": {
          "cached": {
            "type": "boolean",
            "description": "Whether this response came from Connect's cache. Discovery is the module's longest cache (600 s), and `refresh=true` bypasses it."
          },
          "cached_at": {
            "type": ["string", "null"],
            "description": "When the read was fetched from the integration. A newly published post only appears after this."
          }
        }
      },
      "Page": {
        "type": "object",
        "description": "A Facebook Page the token manages. The `id` is an ad's `creative.page_id`.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": ["string", "null"]
          },
          "picture_url": {
            "type": ["string", "null"]
          },
          "can_post": {
            "type": "boolean",
            "description": "Whether the token can post as this Page."
          },
          "instagram_account_id": {
            "type": ["string", "null"],
            "description": "The Instagram account linked to this Page, when there is one. It's the `creative.instagram_account_id`."
          }
        }
      },
      "InstagramAccount": {
        "type": "object",
        "description": "An Instagram account the ad account can use.",
        "properties": {
          "id": {
            "type": "string"
          },
          "username": {
            "type": ["string", "null"]
          }
        }
      },
      "Post": {
        "type": "object",
        "description": "Organic content an ad can boost. Both sources arrive in the same shape, but **only a `source: instagram` post can go in `creative.source_post_id`**.",
        "properties": {
          "id": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": ["instagram", "facebook"]
          },
          "type": {
            "type": ["string", "null"],
            "description": "`image`, `video`, `carousel_album`, … as the integration classifies it."
          },
          "caption": {
            "type": ["string", "null"]
          },
          "permalink": {
            "type": ["string", "null"]
          },
          "thumbnail_url": {
            "type": ["string", "null"]
          },
          "published_at": {
            "type": ["string", "null"]
          }
        }
      },
      "Pixel": {
        "type": "object",
        "description": "A pixel of the ad account. The `id` goes in an ad set's `adset.facebook_ads.promoted_object.pixel_id`.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": ["string", "null"]
          },
          "last_fired_at": {
            "type": ["string", "null"]
          },
          "created_at": {
            "type": ["string", "null"]
          },
          "is_unavailable": {
            "type": "boolean"
          }
        }
      },
      "PixelEvent": {
        "type": "object",
        "description": "An event the pixel recorded in the last 90 days, with the period's count.",
        "properties": {
          "event_name": {
            "type": ["string", "null"]
          },
          "count": {
            "type": ["integer", "null"]
          }
        }
      },
      "CustomConversion": {
        "type": "object",
        "description": "A custom conversion. The `id` goes in `adset.facebook_ads.promoted_object.custom_conversion_id`.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": ["string", "null"]
          },
          "event_type": {
            "type": ["string", "null"],
            "description": "Always lowercase, like every enum in this API."
          },
          "pixel_id": {
            "type": ["string", "null"]
          },
          "is_unavailable": {
            "type": "boolean"
          }
        }
      },
      "Audience": {
        "type": "object",
        "description": "A custom audience of the account. The `id` goes in `targeting.custom_audiences`.",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": ["string", "null"]
          },
          "subtype": {
            "type": ["string", "null"]
          },
          "approximate_size": {
            "type": "object",
            "properties": {
              "lower": {
                "type": ["integer", "null"]
              },
              "upper": {
                "type": ["integer", "null"]
              }
            }
          }
        }
      },
      "TargetingResult": {
        "type": "object",
        "description": "A targeting search result, in the same shape for all three types: the integration responds in three different formats and identifies places by `key` instead of `id`.\n\n**Where each result is used:** `interest` and `behavior` go in `targeting.interests`. Geo is different: only **country** fits in `targeting.countries`; city, region and neighborhood go in through `facebook_ads.targeting.raw.geo_locations` (`cities`, `regions`, …), and the `subtype` says which.",
        "properties": {
          "id": {
            "type": "string",
            "description": "The id the targeting expects. For geo, it's the integration's `key`."
          },
          "name": {
            "type": ["string", "null"]
          },
          "type": {
            "type": "string",
            "enum": ["interest", "geo", "behavior"],
            "description": "The search type that produced the result."
          },
          "subtype": {
            "type": ["string", "null"],
            "description": "Only in geo: `country`, `region`, `city`, `neighborhood`, `zip`. Without it the result isn't usable, because each goes in a different field."
          },
          "path": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The category hierarchy, from most general to most specific. Empty in geo."
          },
          "description": {
            "type": ["string", "null"]
          },
          "country_code": {
            "type": ["string", "null"],
            "description": "Geo only."
          },
          "audience_size": {
            "type": ["object", "null"],
            "description": "The range the integration estimates. It's a range, not a number, and geo doesn't have one.",
            "properties": {
              "lower": {
                "type": ["integer", "null"]
              },
              "upper": {
                "type": ["integer", "null"]
              }
            }
          }
        }
      },
      "CustomConversionCreateRequest": {
        "type": "object",
        "required": ["name", "pixel_id", "rule"],
        "description": "A custom conversion is defined by the **rule** that decides when it fires, and the rule is what you send. One of the two forms at a time.\n\nThe URL rule is the one verified against a real account. The event rule exists in the contract, but the integration refuses it on some pixels. That refusal reaches you as `ads_integration_error`, instead of being guessed here.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "pixel_id": {
            "type": "string",
            "description": "Required: the integration refuses the creation without the pixel behind the rule."
          },
          "rule": {
            "type": "object",
            "description": "Exactly one of the two keys.",
            "oneOf": [
              {
                "required": ["url_contains"],
                "not": {
                  "required": ["event"]
                }
              },
              {
                "required": ["event"],
                "not": {
                  "required": ["url_contains"]
                }
              }
            ],
            "properties": {
              "url_contains": {
                "type": "string",
                "maxLength": 255,
                "description": "Fires when the visited address contains this fragment."
              },
              "event": {
                "type": "string",
                "maxLength": 255,
                "description": "Fires when the pixel reports this event."
              }
            }
          },
          "event_type": {
            "type": "string",
            "maxLength": 64,
            "enum": [
              "add_payment_info",
              "add_to_cart",
              "add_to_wishlist",
              "complete_registration",
              "contact",
              "content_view",
              "customize_product",
              "donate",
              "find_location",
              "initiated_checkout",
              "lead",
              "other",
              "purchase",
              "schedule",
              "search",
              "start_trial",
              "submit_application",
              "subscribe"
            ],
            "description": "The conversion category, from `custom_event_types` in `GET /ads/options`. The integration accepts a closed set, so a value outside it is refused with `422` and the list, instead of refused by the integration with no explanation. Omitted, the integration receives `OTHER`."
          }
        }
      },
      "WebhookSubscription": {
        "type": "object",
        "description": "An address in your account that receives events. `merchant_id` and the URL's deduplication key never leave here.",
        "required": ["id", "url", "events", "is_active"],
        "properties": {
          "id": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "is_active": {
            "type": "boolean"
          },
          "created_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "updated_at": {
            "type": ["string", "null"],
            "format": "date-time"
          }
        }
      },
      "MerchantCredential": {
        "type": "object",
        "description": "The merchant's Meta app for an integration. The `client_secret` never leaves here.",
        "required": [
          "integration",
          "client_id",
          "callback_url",
          "active_connections"
        ],
        "properties": {
          "integration": {
            "type": "string",
            "description": "The integration slug: `facebook_ads`, `facebook`, `instagram_business`, `instagram`, or that of an OAuth toolkit."
          },
          "client_id": {
            "type": "string"
          },
          "redirect_url": {
            "type": ["string", "null"],
            "format": "uri",
            "description": "Callback on the merchant's domain, when registered. Null: Meta redirects straight to the `callback_url`."
          },
          "scopes": {
            "type": ["array", "null"],
            "items": {
              "type": "string"
            },
            "description": "The permission list that replaces the default one. Null: the default applies."
          },
          "callback_url": {
            "type": "string",
            "format": "uri",
            "description": "The address that must be in the Meta app's \"Valid OAuth Redirect URIs\"; for `instagram`, in the Instagram app's \"Business login settings\"."
          },
          "active_connections": {
            "type": "integer",
            "description": "Active connections issued by this app."
          },
          "created_at": {
            "type": ["string", "null"],
            "format": "date-time"
          },
          "updated_at": {
            "type": ["string", "null"],
            "format": "date-time"
          }
        }
      },
      "MerchantLlmCredentialInput": {
        "type": "object",
        "required": ["api_key"],
        "properties": {
          "api_key": {
            "type": "string",
            "minLength": 20,
            "maxLength": 512,
            "description": "Your API key at the provider (`openai`, `anthropic` or `meta`). Stored encrypted and never returned."
          }
        }
      },
      "MerchantLlmCredential": {
        "type": "object",
        "description": "Your API key at an LLM provider. The key never leaves here, only its last characters.",
        "required": ["integration", "api_key_hint", "created_at", "updated_at"],
        "properties": {
          "integration": {
            "type": "string",
            "enum": ["openai", "anthropic", "meta"],
            "description": "The provider."
          },
          "api_key_hint": {
            "type": "string",
            "description": "The key's last 4 characters, so you know which one is registered.",
            "examples": ["...AbCd"]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Integration": {
        "type": "object",
        "description": "A platform in the Connect catalog.",
        "required": [
          "id",
          "name",
          "slug",
          "type",
          "color",
          "icon",
          "enabled",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string",
            "description": "The identifier used in `available_integrations`, in sessions, and in `GET /metrics/{integration_slug}`."
          },
          "type": {
            "type": "integer",
            "description": "Internal platform code. Of no use to the merchant."
          },
          "color": {
            "type": "string",
            "description": "Brand color, in hexadecimal."
          },
          "icon": {
            "type": "object",
            "required": ["name", "color"],
            "properties": {
              "name": {
                "type": "string"
              },
              "color": {
                "type": "string"
              }
            }
          },
          "enabled": {
            "type": "boolean",
            "description": "`false` is a platform Connect doesn't offer to any merchant yet."
          },
          "created_at": {
            "type": "string",
            "examples": ["2024-09-13 14:12:56"]
          },
          "updated_at": {
            "type": "string",
            "examples": ["2024-09-13 14:12:56"]
          }
        }
      },
      "MetricDefinition": {
        "type": "object",
        "description": "A metric the platform offers. The first five fields are exactly a MetricRequestItem: copy them into `metrics[]` of `/metrics/get-data`. The rest describes the metric and can be ignored.",
        "required": [
          "id",
          "reference_key",
          "component",
          "metrics",
          "dimensions",
          "references"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Generated on each response. Use it as the requested item's `id`, or generate your own."
          },
          "reference_key": {
            "type": "string",
            "examples": ["fb_ads:spend", "fb_ads:insights_by_campaign"]
          },
          "component": {
            "type": "string",
            "description": "The default format of this metric's result.",
            "examples": ["number_v1", "chart_v1", "datatable_v1"]
          },
          "metrics": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The values the metric returns by default. Any key from `meta.setup.metrics` can replace them."
          },
          "dimensions": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "object",
                  "required": ["field"],
                  "properties": {
                    "field": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              ]
            },
            "description": "The default breakdown. Tables bring `{\"field\": ...}` objects; send them as they came. Any key from `meta.setup.dimensions` can replace them."
          },
          "references": {
            "type": "object",
            "description": "How the metric presents itself to a person, in the requested language.",
            "properties": {
              "title": {
                "type": ["string", "null"]
              },
              "description": {
                "type": ["string", "null"]
              },
              "tags": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "additionalProperties": true
      },
      "MetricDefinitionsSetup": {
        "type": "object",
        "description": "Everything the platform accepts in `metrics` and `dimensions`, keyed by the value to send. `label` is the readable name, in the requested language.",
        "required": ["metrics", "dimensions"],
        "properties": {
          "metrics": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          },
          "dimensions": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                }
              },
              "additionalProperties": true
            }
          }
        }
      },
      "AdsError": {
        "type": "object",
        "description": "The ads module's single error envelope. Branch on `error_code`, never on the message.",
        "required": ["message", "error_code"],
        "properties": {
          "message": {
            "type": "string"
          },
          "error_code": {
            "type": "string",
            "example": "validation_error",
            "description": "`validation_error`, `forbidden`, `idempotency_key_required`, `idempotency_key_invalid`, `idempotency_key_reused`, `operation_in_progress`, `budget_level_mismatch`, `boosted_creative_not_replaceable`, `ads_connection_expired`, `ads_unsupported_integration`, `ads_object_not_found`, `ads_video_not_ready`, `ads_integration_error`, or the refusal code the integration returned, in lowercase."
          },
          "errors": {
            "type": "object",
            "description": "Only in `validation_error`: field → messages.",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "supported_values": {
            "type": "object",
            "description": "Only in `validation_error`, when a refused field is an enum: what was accepted.",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "integration_error": {
            "type": ["object", "null"],
            "description": "The integration's raw error, when the refusal came from it.",
            "properties": {
              "integration": {
                "type": "string",
                "example": "meta_ads"
              },
              "code": {
                "type": ["integer", "null"]
              },
              "subcode": {
                "type": ["integer", "null"]
              },
              "user_message": {
                "type": ["string", "null"]
              }
            }
          },
          "integration_status": {
            "type": "string",
            "description": "In `ads_connection_expired`: the connection's new status.",
            "example": "expired"
          },
          "created": {
            "type": "array",
            "description": "What the operation created and **couldn't** undo, for you to remove. Everything is created paused, so it doesn't spend.",
            "items": {
              "type": "object",
              "properties": {
                "level": {
                  "type": "string",
                  "enum": ["campaign", "adset", "ad"]
                },
                "id": {
                  "type": "string"
                }
              }
            }
          },
          "video_id": {
            "type": "string",
            "description": "In `ads_video_not_ready`: the already uploaded video. Repeat the call with the same `Idempotency-Key`: the video is reused."
          },
          "budget_level": {
            "type": "string",
            "enum": ["campaign", "adset"],
            "description": "In `budget_level_mismatch`: where this campaign's budget lives."
          },
          "retry_after": {
            "type": "integer",
            "description": "In `operation_in_progress`: seconds until you can retry."
          }
        }
      },
      "AdsBudget": {
        "type": ["object", "null"],
        "description": "Budget in the **ad account's currency**, never in cents: `50` is fifty reais in a BRL account.",
        "properties": {
          "amount": {
            "type": "number"
          },
          "type": {
            "type": "string",
            "enum": ["daily", "lifetime"]
          },
          "level": {
            "type": "string",
            "enum": ["campaign", "adset"],
            "description": "Where the budget lives. Read-only."
          },
          "currency": {
            "type": ["string", "null"],
            "example": "BRL"
          }
        }
      },
      "AdsBudgetInput": {
        "type": ["object", "null"],
        "description": "Budget in the **ad account's currency**, never in cents. The level is where it sits: on the campaign it's CBO, on the ad set it's ABO. In `facebook_ads` it can sit on either one, never on both.",
        "required": ["amount"],
        "properties": {
          "amount": {
            "type": "number",
            "exclusiveMinimum": 0,
            "example": 50
          },
          "type": {
            "type": "string",
            "enum": ["daily", "lifetime"],
            "default": "daily",
            "description": "`lifetime` requires `schedule.end` on the ad set."
          }
        }
      },
      "AdsCampaign": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The object's id on the ad platform (on Meta, the same as in Ads Manager)."
          },
          "uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The Connect id. `null` when the object isn't in the Connect database (only with `source=external`)."
          },
          "customer_uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The customer that owns the account. `null` when the object isn't in the Connect database (only with `source=external`)."
          },
          "customer_integration_uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The connection through which Connect last reached the account. `null` when the object isn't in the Connect database, or when that connection was deleted."
          },
          "origin": {
            "type": ["string", "null"],
            "enum": ["created", "imported", null],
            "description": "`created`: Connect created it. `imported`: it was created elsewhere and entered the database on the first write through Connect."
          },
          "synced_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "The last time Connect checked this object at the integration. Database reads show the last known state; `refresh=true` updates it."
          },
          "deleted_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "Deleted by Connect, or found to be deleted. Only shows up with `include_deleted=true`."
          },
          "name": {
            "type": ["string", "null"]
          },
          "status": {
            "type": ["string", "null"],
            "enum": ["active", "paused", null]
          },
          "effective_status": {
            "type": ["string", "null"],
            "enum": [
              "active",
              "paused",
              "deleted",
              "archived",
              "in_process",
              "with_issues",
              "campaign_paused",
              "adset_paused",
              "disapproved",
              "pending_review",
              "preapproved",
              "pending_billing_info",
              null
            ],
            "description": "The status the platform actually applies, combining the object's own, that of the levels above, and review: `pending_review` under review, `disapproved` rejected, `with_issues` with problems (the reason comes in `issues`)."
          },
          "issues": {
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AdsIssue"
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "Why the platform is holding the object: delivery problems at any level and, on an ad, the review rejection reason. Empty list when there's nothing to report. `null` when the object's state wasn't read."
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudget"
          },
          "adsets_count": {
            "type": ["integer", "null"]
          },
          "facebook_ads": {
            "type": "object",
            "properties": {
              "objective": {
                "type": ["string", "null"]
              },
              "spend_cap": {
                "type": ["number", "null"]
              },
              "bid_strategy": {
                "type": ["string", "null"]
              }
            }
          },
          "created_at": {
            "type": ["string", "null"]
          },
          "updated_at": {
            "type": ["string", "null"]
          }
        }
      },
      "AdsAdset": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The object's id on the ad platform (on Meta, the same as in Ads Manager)."
          },
          "uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The Connect id. `null` when the object isn't in the Connect database (only with `source=external`)."
          },
          "customer_uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The customer that owns the account. `null` when the object isn't in the Connect database (only with `source=external`)."
          },
          "customer_integration_uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The connection through which Connect last reached the account. `null` when the object isn't in the Connect database, or when that connection was deleted."
          },
          "origin": {
            "type": ["string", "null"],
            "enum": ["created", "imported", null],
            "description": "`created`: Connect created it. `imported`: it was created elsewhere and entered the database on the first write through Connect."
          },
          "synced_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "The last time Connect checked this object at the integration. Database reads show the last known state; `refresh=true` updates it."
          },
          "deleted_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "Deleted by Connect, or found to be deleted. Only shows up with `include_deleted=true`."
          },
          "campaign_id": {
            "type": ["string", "null"]
          },
          "name": {
            "type": ["string", "null"]
          },
          "status": {
            "type": ["string", "null"],
            "enum": ["active", "paused", null]
          },
          "effective_status": {
            "type": ["string", "null"],
            "enum": [
              "active",
              "paused",
              "deleted",
              "archived",
              "in_process",
              "with_issues",
              "campaign_paused",
              "adset_paused",
              "disapproved",
              "pending_review",
              "preapproved",
              "pending_billing_info",
              null
            ],
            "description": "The status the platform actually applies, combining the object's own, that of the levels above, and review: `pending_review` under review, `disapproved` rejected, `with_issues` with problems (the reason comes in `issues`)."
          },
          "issues": {
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AdsIssue"
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "Why the platform is holding the object: delivery problems at any level and, on an ad, the review rejection reason. Empty list when there's nothing to report. `null` when the object's state wasn't read."
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudget"
          },
          "schedule": {
            "type": ["object", "null"],
            "properties": {
              "start": {
                "type": ["string", "null"]
              },
              "end": {
                "type": ["string", "null"]
              }
            }
          },
          "targeting": {
            "type": ["object", "null"],
            "properties": {
              "countries": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "age_min": {
                "type": ["integer", "null"]
              },
              "age_max": {
                "type": ["integer", "null"]
              },
              "genders": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "facebook_ads": {
            "type": "object",
            "properties": {
              "optimization_goal": {
                "type": ["string", "null"]
              },
              "billing_event": {
                "type": ["string", "null"]
              },
              "bid_strategy": {
                "type": ["string", "null"]
              },
              "bid_amount": {
                "type": ["number", "null"]
              },
              "placements": {
                "type": ["object", "null"],
                "additionalProperties": true
              },
              "targeting": {
                "type": ["object", "null"],
                "properties": {
                  "interests": {
                    "type": "array"
                  },
                  "custom_audiences": {
                    "type": "array"
                  },
                  "excluded_custom_audiences": {
                    "type": "array"
                  },
                  "advantage_audience": {
                    "type": ["boolean", "null"]
                  },
                  "raw": {
                    "type": "object",
                    "additionalProperties": true
                  }
                }
              }
            }
          },
          "created_at": {
            "type": ["string", "null"]
          },
          "updated_at": {
            "type": ["string", "null"]
          }
        }
      },
      "AdsAd": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The object's id on the ad platform (on Meta, the same as in Ads Manager)."
          },
          "uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The Connect id. `null` when the object isn't in the Connect database (only with `source=external`)."
          },
          "customer_uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The customer that owns the account. `null` when the object isn't in the Connect database (only with `source=external`)."
          },
          "customer_integration_uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The connection through which Connect last reached the account. `null` when the object isn't in the Connect database, or when that connection was deleted."
          },
          "origin": {
            "type": ["string", "null"],
            "enum": ["created", "imported", null],
            "description": "`created`: Connect created it. `imported`: it was created elsewhere and entered the database on the first write through Connect."
          },
          "synced_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "The last time Connect checked this object at the integration. Database reads show the last known state; `refresh=true` updates it."
          },
          "deleted_at": {
            "type": ["string", "null"],
            "format": "date-time",
            "description": "Deleted by Connect, or found to be deleted. Only shows up with `include_deleted=true`."
          },
          "campaign_id": {
            "type": ["string", "null"]
          },
          "adset_id": {
            "type": ["string", "null"]
          },
          "name": {
            "type": ["string", "null"]
          },
          "status": {
            "type": ["string", "null"],
            "enum": ["active", "paused", null]
          },
          "effective_status": {
            "type": ["string", "null"],
            "enum": [
              "active",
              "paused",
              "deleted",
              "archived",
              "in_process",
              "with_issues",
              "campaign_paused",
              "adset_paused",
              "disapproved",
              "pending_review",
              "preapproved",
              "pending_billing_info",
              null
            ],
            "description": "The status the platform actually applies, combining the object's own, that of the levels above, and review: `pending_review` under review, `disapproved` rejected, `with_issues` with problems (the reason comes in `issues`)."
          },
          "issues": {
            "oneOf": [
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/AdsIssue"
                }
              },
              {
                "type": "null"
              }
            ],
            "description": "Why the platform is holding the object: delivery problems at any level and, on an ad, the review rejection reason. Empty list when there's nothing to report. `null` when the object's state wasn't read."
          },
          "format": {
            "type": ["string", "null"],
            "enum": ["image", "video", "post", null],
            "description": "`post` is a boost."
          },
          "headline": {
            "type": ["string", "null"]
          },
          "body": {
            "type": ["string", "null"]
          },
          "description": {
            "type": ["string", "null"]
          },
          "link_url": {
            "type": ["string", "null"]
          },
          "call_to_action": {
            "type": ["string", "null"]
          },
          "thumbnail_url": {
            "type": ["string", "null"]
          },
          "facebook_ads": {
            "type": "object",
            "properties": {
              "creative_id": {
                "type": ["string", "null"]
              },
              "page_id": {
                "type": ["string", "null"]
              },
              "instagram_account_id": {
                "type": ["string", "null"]
              },
              "post_id": {
                "type": ["string", "null"]
              }
            }
          },
          "created_at": {
            "type": ["string", "null"]
          },
          "updated_at": {
            "type": ["string", "null"]
          }
        }
      },
      "AdsPageMeta": {
        "type": "object",
        "description": "The standard pagination of Connect resources. With `source=external`, the integration paginates by cursor and doesn't report the total: `total` and `last_page` don't come, and `links.next` is `null` on the last page.",
        "required": ["current_page", "path", "per_page"],
        "properties": {
          "current_page": {
            "type": "integer"
          },
          "from": {
            "type": ["integer", "null"]
          },
          "last_page": {
            "type": "integer"
          },
          "links": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "url": {
                  "type": ["string", "null"]
                },
                "label": {
                  "type": "string"
                },
                "active": {
                  "type": "boolean"
                }
              }
            }
          },
          "path": {
            "type": "string"
          },
          "per_page": {
            "type": "integer"
          },
          "to": {
            "type": ["integer", "null"]
          },
          "total": {
            "type": "integer"
          }
        }
      },
      "AdsIssue": {
        "type": "object",
        "required": ["code", "message"],
        "properties": {
          "code": {
            "type": ["string", "null"],
            "description": "The problem code on the platform. `ad_review` when it comes from the ad review."
          },
          "message": {
            "type": ["string", "null"]
          }
        }
      },
      "MerchantStats": {
        "type": "object",
        "required": [
          "customers",
          "customer_integrations",
          "expired_customer_integrations",
          "posts",
          "ads"
        ],
        "properties": {
          "customers": {
            "type": "integer",
            "description": "Customers in the account."
          },
          "customer_integrations": {
            "type": "integer",
            "description": "Your customers' connections, in any status."
          },
          "expired_customer_integrations": {
            "type": "integer",
            "description": "Your customers' connections with status `expired`: the customer needs to authorize the network again."
          },
          "posts": {
            "type": "object",
            "required": ["total", "published", "failed"],
            "properties": {
              "total": {
                "type": "integer",
                "description": "Posts requested through the API, in any status."
              },
              "published": {
                "type": "integer"
              },
              "failed": {
                "type": "integer"
              }
            }
          },
          "ads": {
            "type": "object",
            "required": ["total", "failed"],
            "properties": {
              "total": {
                "type": "integer",
                "description": "Ads Connect created, deleted ones included."
              },
              "failed": {
                "type": "integer",
                "description": "Ad creations (`POST /ads`, `/ads/boost`, `/ads/{id}/duplicate`) that failed. An ad that failed doesn't exist in the account, so it doesn't count in `total`."
              }
            }
          }
        }
      },
      "AdsPageLinks": {
        "type": "object",
        "properties": {
          "first": {
            "type": ["string", "null"]
          },
          "last": {
            "type": ["string", "null"]
          },
          "prev": {
            "type": ["string", "null"]
          },
          "next": {
            "type": ["string", "null"]
          }
        }
      },
      "AdsCampaignInput": {
        "type": "object",
        "required": ["name", "facebook_ads"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"],
            "default": "paused"
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudgetInput"
          },
          "facebook_ads": {
            "type": "object",
            "required": ["objective"],
            "additionalProperties": false,
            "properties": {
              "objective": {
                "type": "string",
                "enum": [
                  "awareness",
                  "traffic",
                  "engagement",
                  "leads",
                  "app_promotion",
                  "sales"
                ],
                "description": "Required on create. Doesn't change afterwards."
              },
              "special_ad_categories": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Required for credit, employment, housing, and politics."
              },
              "spend_cap": {
                "type": ["number", "null"],
                "description": "The campaign's spending limit, in the account's currency. `null` removes it."
              }
            }
          }
        }
      },
      "AdsCampaignUpdate": {
        "type": "object",
        "description": "Only what is sent changes. At least one field.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"]
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudgetInput"
          },
          "facebook_ads": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "spend_cap": {
                "type": ["number", "null"],
                "description": "The campaign's spending limit, in the account's currency. `null` removes it."
              }
            }
          }
        }
      },
      "AdsAdsetInput": {
        "type": "object",
        "required": ["campaign_id", "name", "targeting", "facebook_ads"],
        "properties": {
          "campaign_id": {
            "type": "string",
            "description": "The campaign, by its `id` or by the Connect `uuid`."
          },
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"],
            "default": "paused"
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudgetInput"
          },
          "schedule": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "start": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "end": {
                "type": ["string", "null"],
                "format": "date-time"
              }
            }
          },
          "targeting": {
            "type": "object",
            "additionalProperties": false,
            "description": "What every ads integration understands. The rest of the targeting goes in `facebook_ads.targeting`.",
            "properties": {
              "countries": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 2
                },
                "example": ["BR"]
              },
              "age_min": {
                "type": ["integer", "null"],
                "minimum": 13,
                "maximum": 65
              },
              "age_max": {
                "type": ["integer", "null"],
                "minimum": 13,
                "maximum": 65
              },
              "genders": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": ["all", "male", "female"]
                }
              }
            }
          },
          "facebook_ads": {
            "type": "object",
            "required": ["optimization_goal", "billing_event"],
            "additionalProperties": false,
            "properties": {
              "optimization_goal": {
                "type": "string",
                "description": "Required on create. Values in `GET /ads/options`."
              },
              "billing_event": {
                "type": "string",
                "description": "Required on create."
              },
              "bid_strategy": {
                "type": "string",
                "enum": ["lowest_cost", "bid_cap", "cost_cap"]
              },
              "bid_amount": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Requires `bid_strategy`."
              },
              "placements": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "publisher_platforms": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "facebook_positions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "instagram_positions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "targeting": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "interests": {
                    "type": "array"
                  },
                  "custom_audiences": {
                    "type": "array"
                  },
                  "excluded_custom_audiences": {
                    "type": "array"
                  },
                  "advantage_audience": {
                    "type": ["boolean", "null"]
                  },
                  "raw": {
                    "type": "object",
                    "description": "Meta targeting spec for what Connect doesn't model. Modeled fields always win."
                  }
                }
              },
              "promoted_object": {
                "type": "object",
                "description": "Create only. Pixel, page, or custom conversion must belong to the connection's account."
              },
              "destination_type": {
                "type": "string",
                "description": "Create only."
              },
              "attribution_spec": {
                "type": "array",
                "description": "Create only."
              }
            }
          }
        }
      },
      "AdsAdsetUpdate": {
        "type": "object",
        "description": "Only what is sent changes. A partial targeting is merged with the current one.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"]
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudgetInput"
          },
          "schedule": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "start": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "end": {
                "type": ["string", "null"],
                "format": "date-time"
              }
            }
          },
          "targeting": {
            "type": "object",
            "additionalProperties": false,
            "description": "What every ads integration understands. The rest of the targeting goes in `facebook_ads.targeting`.",
            "properties": {
              "countries": {
                "type": "array",
                "items": {
                  "type": "string",
                  "minLength": 2,
                  "maxLength": 2
                },
                "example": ["BR"]
              },
              "age_min": {
                "type": ["integer", "null"],
                "minimum": 13,
                "maximum": 65
              },
              "age_max": {
                "type": ["integer", "null"],
                "minimum": 13,
                "maximum": 65
              },
              "genders": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": ["all", "male", "female"]
                }
              }
            }
          },
          "facebook_ads": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "optimization_goal": {
                "type": "string",
                "description": "Required on create. Values in `GET /ads/options`."
              },
              "billing_event": {
                "type": "string",
                "description": "Required on create."
              },
              "bid_strategy": {
                "type": "string",
                "enum": ["lowest_cost", "bid_cap", "cost_cap"]
              },
              "bid_amount": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Requires `bid_strategy`."
              },
              "placements": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "publisher_platforms": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "facebook_positions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "instagram_positions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "targeting": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "interests": {
                    "type": "array"
                  },
                  "custom_audiences": {
                    "type": "array"
                  },
                  "excluded_custom_audiences": {
                    "type": "array"
                  },
                  "advantage_audience": {
                    "type": ["boolean", "null"]
                  },
                  "raw": {
                    "type": "object",
                    "description": "Meta targeting spec for what Connect doesn't model. Modeled fields always win."
                  }
                }
              }
            }
          }
        }
      },
      "AdsAdInput": {
        "type": "object",
        "required": ["format", "link_url", "media", "facebook_ads"],
        "additionalProperties": false,
        "properties": {
          "format": {
            "type": "string",
            "enum": ["image", "video"]
          },
          "headline": {
            "type": "string",
            "maxLength": 255
          },
          "body": {
            "type": "string",
            "maxLength": 2000
          },
          "description": {
            "type": "string",
            "maxLength": 255
          },
          "link_url": {
            "type": "string",
            "format": "uri"
          },
          "call_to_action": {
            "type": "string",
            "description": "Values in `GET /ads/options`."
          },
          "media": {
            "type": "array",
            "minItems": 1,
            "maxItems": 2,
            "description": "One file for all placements, or two: the feed version and the story version of the same creative, each with `placements`. With two, each file is referenced by what the account already has (`hash` or `id`, from `POST /ads/facebook_ads/media`), never by `url`.",
            "items": {
              "type": "object",
              "required": ["type"],
              "additionalProperties": false,
              "description": "An image by `url` or `hash`; a video by `url` or `id`, with `thumbnail_url`.",
              "properties": {
                "type": {
                  "type": "string",
                  "enum": ["image", "video"]
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "hash": {
                  "type": "string",
                  "description": "Image already uploaded to the account."
                },
                "id": {
                  "type": "string",
                  "description": "Video already uploaded to the account."
                },
                "thumbnail_url": {
                  "type": "string",
                  "format": "uri"
                },
                "placements": {
                  "type": "array",
                  "minItems": 1,
                  "maxItems": 1,
                  "items": {
                    "type": "string",
                    "enum": ["feed", "story"]
                  },
                  "description": "Only with two files: `feed` (Facebook and Instagram Feed) or `story` (Stories and Reels)."
                }
              }
            }
          },
          "facebook_ads": {
            "type": "object",
            "required": ["page_id"],
            "additionalProperties": false,
            "properties": {
              "page_id": {
                "type": "string",
                "description": "Must be a page of the connection's account."
              },
              "instagram_account_id": {
                "type": "string"
              },
              "url_tags": {
                "type": "string"
              },
              "tracking_specs": {
                "type": "array"
              }
            }
          }
        }
      },
      "AdsBoostAdInput": {
        "type": "object",
        "required": ["post_id", "facebook_ads"],
        "additionalProperties": false,
        "description": "The creative comes from the post. Texts and media aren't part of a boost.",
        "properties": {
          "post_id": {
            "type": "string",
            "description": "The post to boost, from `GET /ads/facebook_ads/posts`."
          },
          "link_url": {
            "type": "string",
            "format": "uri"
          },
          "call_to_action": {
            "type": "string"
          },
          "facebook_ads": {
            "type": "object",
            "required": ["instagram_account_id"],
            "additionalProperties": false,
            "properties": {
              "instagram_account_id": {
                "type": "string",
                "description": "The account that owns the post. Post ownership is proven through it."
              },
              "page_id": {
                "type": "string"
              },
              "url_tags": {
                "type": "string"
              },
              "tracking_specs": {
                "type": "array"
              }
            }
          }
        }
      },
      "AdsTreeRequest": {
        "type": "object",
        "required": ["name", "adset", "ad"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "description": "The ad's name, and that of the created levels that don't have one."
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"],
            "default": "paused",
            "description": "The tree's final state. Everything is created paused and activated in the last step."
          },
          "campaign": {
            "description": "`{\"id\": …}` uses an existing campaign; without `id`, describes the one to be created. Forbidden when `adset.id` is sent.",
            "oneOf": [
              {
                "type": "object",
                "required": ["id"],
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "budget": {
                    "$ref": "#/components/schemas/AdsBudgetInput"
                  },
                  "facebook_ads": {
                    "type": "object",
                    "required": ["objective"],
                    "additionalProperties": false,
                    "properties": {
                      "objective": {
                        "type": "string",
                        "enum": [
                          "awareness",
                          "traffic",
                          "engagement",
                          "leads",
                          "app_promotion",
                          "sales"
                        ],
                        "description": "Required on create. Doesn't change afterwards."
                      },
                      "special_ad_categories": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Required for credit, employment, housing, and politics."
                      },
                      "spend_cap": {
                        "type": ["number", "null"],
                        "description": "The campaign's spending limit, in the account's currency. `null` removes it."
                      }
                    }
                  }
                }
              }
            ]
          },
          "adset": {
            "description": "`{\"id\": …}` uses an existing ad set; without `id`, describes the one to be created.",
            "oneOf": [
              {
                "type": "object",
                "required": ["id"],
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "budget": {
                    "$ref": "#/components/schemas/AdsBudgetInput"
                  },
                  "schedule": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "start": {
                        "type": ["string", "null"],
                        "format": "date-time"
                      },
                      "end": {
                        "type": ["string", "null"],
                        "format": "date-time"
                      }
                    }
                  },
                  "targeting": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "What every ads integration understands. The rest of the targeting goes in `facebook_ads.targeting`.",
                    "properties": {
                      "countries": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 2,
                          "maxLength": 2
                        },
                        "example": ["BR"]
                      },
                      "age_min": {
                        "type": ["integer", "null"],
                        "minimum": 13,
                        "maximum": 65
                      },
                      "age_max": {
                        "type": ["integer", "null"],
                        "minimum": 13,
                        "maximum": 65
                      },
                      "genders": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": ["all", "male", "female"]
                        }
                      }
                    }
                  },
                  "facebook_ads": {
                    "type": "object",
                    "required": ["optimization_goal", "billing_event"],
                    "additionalProperties": false,
                    "properties": {
                      "optimization_goal": {
                        "type": "string",
                        "description": "Required on create. Values in `GET /ads/options`."
                      },
                      "billing_event": {
                        "type": "string",
                        "description": "Required on create."
                      },
                      "bid_strategy": {
                        "type": "string",
                        "enum": ["lowest_cost", "bid_cap", "cost_cap"]
                      },
                      "bid_amount": {
                        "type": "number",
                        "exclusiveMinimum": 0,
                        "description": "Requires `bid_strategy`."
                      },
                      "placements": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "publisher_platforms": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "facebook_positions": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "instagram_positions": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "targeting": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "interests": {
                            "type": "array"
                          },
                          "custom_audiences": {
                            "type": "array"
                          },
                          "excluded_custom_audiences": {
                            "type": "array"
                          },
                          "advantage_audience": {
                            "type": ["boolean", "null"]
                          },
                          "raw": {
                            "type": "object",
                            "description": "Meta targeting spec for what Connect doesn't model. Modeled fields always win."
                          }
                        }
                      },
                      "promoted_object": {
                        "type": "object",
                        "description": "Create only. Pixel, page, or custom conversion must belong to the connection's account."
                      },
                      "destination_type": {
                        "type": "string",
                        "description": "Create only."
                      },
                      "attribution_spec": {
                        "type": "array",
                        "description": "Create only."
                      }
                    }
                  }
                }
              }
            ]
          },
          "ad": {
            "$ref": "#/components/schemas/AdsAdInput"
          }
        }
      },
      "AdsBoostRequest": {
        "type": "object",
        "required": ["name", "adset", "ad"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "description": "The ad's name, and that of the created levels that don't have one."
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"],
            "default": "paused",
            "description": "The tree's final state. Everything is created paused and activated in the last step."
          },
          "campaign": {
            "description": "`{\"id\": …}` uses an existing campaign; without `id`, describes the one to be created. Forbidden when `adset.id` is sent.",
            "oneOf": [
              {
                "type": "object",
                "required": ["id"],
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "budget": {
                    "$ref": "#/components/schemas/AdsBudgetInput"
                  },
                  "facebook_ads": {
                    "type": "object",
                    "required": ["objective"],
                    "additionalProperties": false,
                    "properties": {
                      "objective": {
                        "type": "string",
                        "enum": [
                          "awareness",
                          "traffic",
                          "engagement",
                          "leads",
                          "app_promotion",
                          "sales"
                        ],
                        "description": "Required on create. Doesn't change afterwards."
                      },
                      "special_ad_categories": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        },
                        "description": "Required for credit, employment, housing, and politics."
                      },
                      "spend_cap": {
                        "type": ["number", "null"],
                        "description": "The campaign's spending limit, in the account's currency. `null` removes it."
                      }
                    }
                  }
                }
              }
            ]
          },
          "adset": {
            "description": "`{\"id\": …}` uses an existing ad set; without `id`, describes the one to be created.",
            "oneOf": [
              {
                "type": "object",
                "required": ["id"],
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "budget": {
                    "$ref": "#/components/schemas/AdsBudgetInput"
                  },
                  "schedule": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "start": {
                        "type": ["string", "null"],
                        "format": "date-time"
                      },
                      "end": {
                        "type": ["string", "null"],
                        "format": "date-time"
                      }
                    }
                  },
                  "targeting": {
                    "type": "object",
                    "additionalProperties": false,
                    "description": "What every ads integration understands. The rest of the targeting goes in `facebook_ads.targeting`.",
                    "properties": {
                      "countries": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 2,
                          "maxLength": 2
                        },
                        "example": ["BR"]
                      },
                      "age_min": {
                        "type": ["integer", "null"],
                        "minimum": 13,
                        "maximum": 65
                      },
                      "age_max": {
                        "type": ["integer", "null"],
                        "minimum": 13,
                        "maximum": 65
                      },
                      "genders": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": ["all", "male", "female"]
                        }
                      }
                    }
                  },
                  "facebook_ads": {
                    "type": "object",
                    "required": ["optimization_goal", "billing_event"],
                    "additionalProperties": false,
                    "properties": {
                      "optimization_goal": {
                        "type": "string",
                        "description": "Required on create. Values in `GET /ads/options`."
                      },
                      "billing_event": {
                        "type": "string",
                        "description": "Required on create."
                      },
                      "bid_strategy": {
                        "type": "string",
                        "enum": ["lowest_cost", "bid_cap", "cost_cap"]
                      },
                      "bid_amount": {
                        "type": "number",
                        "exclusiveMinimum": 0,
                        "description": "Requires `bid_strategy`."
                      },
                      "placements": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "publisher_platforms": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "facebook_positions": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "instagram_positions": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "targeting": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                          "interests": {
                            "type": "array"
                          },
                          "custom_audiences": {
                            "type": "array"
                          },
                          "excluded_custom_audiences": {
                            "type": "array"
                          },
                          "advantage_audience": {
                            "type": ["boolean", "null"]
                          },
                          "raw": {
                            "type": "object",
                            "description": "Meta targeting spec for what Connect doesn't model. Modeled fields always win."
                          }
                        }
                      },
                      "promoted_object": {
                        "type": "object",
                        "description": "Create only. Pixel, page, or custom conversion must belong to the connection's account."
                      },
                      "destination_type": {
                        "type": "string",
                        "description": "Create only."
                      },
                      "attribution_spec": {
                        "type": "array",
                        "description": "Create only."
                      }
                    }
                  }
                }
              }
            ]
          },
          "ad": {
            "$ref": "#/components/schemas/AdsBoostAdInput"
          }
        }
      },
      "AdsAdUpdate": {
        "type": "object",
        "description": "Only what is sent changes. Changing a text swaps the creative and sends the ad back to review. `headline` and `description` accept `null` to clear.",
        "properties": {
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": ["active", "paused"]
          },
          "headline": {
            "type": ["string", "null"]
          },
          "body": {
            "type": "string"
          },
          "description": {
            "type": ["string", "null"]
          },
          "link_url": {
            "type": "string",
            "format": "uri"
          },
          "call_to_action": {
            "type": "string"
          }
        }
      },
      "AdsDuplicateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "description": "Without a name, the integration assigns one. The copy is always created paused."
          }
        }
      },
      "AdsValidation": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "results": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "level": {
                      "type": "string",
                      "enum": ["campaign", "adset", "ad"]
                    },
                    "status": {
                      "type": "string",
                      "enum": ["validated", "skipped"],
                      "description": "`skipped`: the level depends on a parent that doesn't exist at the integration yet, and is only validated on the real creation."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "AdsCampaignDuplicateRequest": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "status": {
            "type": "string",
            "enum": ["paused", "active"],
            "description": "Default `paused`."
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudgetInput"
          }
        }
      },
      "AdsAdsetDuplicateRequest": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255
          },
          "status": {
            "type": "string",
            "enum": ["paused", "active"],
            "description": "Default `paused`."
          },
          "campaign_id": {
            "type": "string",
            "description": "The target campaign, by `id` or `uuid`. Without it, the copy stays in the source's campaign."
          },
          "budget": {
            "$ref": "#/components/schemas/AdsBudgetInput"
          },
          "schedule": {
            "type": "object",
            "properties": {
              "start": {
                "type": ["string", "null"],
                "format": "date-time"
              },
              "end": {
                "type": ["string", "null"],
                "format": "date-time"
              }
            }
          }
        }
      },
      "AdsDeleted": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "deleted": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "AdsOptions": {
        "type": "object",
        "required": ["data"],
        "properties": {
          "data": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "integration_slug": {
                "type": "string"
              },
              "budget": {
                "type": "object",
                "additionalProperties": true,
                "description": "Which levels the budget can sit on, and of which types."
              },
              "common": {
                "type": "object",
                "additionalProperties": true,
                "description": "The values of the fields every ads integration has."
              },
              "facebook_ads": {
                "type": "object",
                "additionalProperties": true,
                "description": "This integration's block, level by level: the accepted fields and the values for each."
              }
            }
          }
        }
      },
      "PostsPublishing": {
        "type": "object",
        "description": "The publishing state. `error` is filled in when it failed.",
        "required": ["status", "external_id", "error"],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "processing",
              "ready",
              "publishing",
              "published",
              "partially_published",
              "failed"
            ]
          },
          "external_id": {
            "type": ["string", "null"],
            "description": "The id the network gave the post or the media."
          },
          "error": {
            "type": ["object", "null"],
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": ["string", "null"]
              }
            }
          },
          "published_at": {
            "type": ["string", "null"],
            "description": "Post only. `Y-m-d H:i:s`."
          }
        }
      },
      "PostsMedia": {
        "type": "object",
        "required": [
          "position",
          "type",
          "url",
          "alt_text",
          "user_tags",
          "publishing"
        ],
        "properties": {
          "position": {
            "type": "integer"
          },
          "type": {
            "type": "string",
            "enum": ["image", "video", "document"]
          },
          "url": {
            "type": "string"
          },
          "alt_text": {
            "type": ["string", "null"]
          },
          "user_tags": {
            "type": ["array", "null"],
            "description": "Instagram only. Up to 20 per media. On an image, `x` and `y` (from 0 to 1) go together or not at all (without them, the tag sits in the center). On a video, without `x` and `y`. A carousel from an account connected through Instagram Login doesn't accept tags.",
            "items": {
              "type": "object",
              "required": ["username"],
              "properties": {
                "username": {
                  "type": "string",
                  "maxLength": 30,
                  "description": "Without `@`. Letters, numbers, periods, and underscores."
                },
                "x": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "y": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                }
              }
            }
          },
          "publishing": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PostsPublishing"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "PostsPost": {
        "type": "object",
        "required": [
          "uuid",
          "external_reference",
          "integration_slug",
          "source_id",
          "source_name",
          "format",
          "caption",
          "status",
          "permalink",
          "publishing",
          "media",
          "created_at"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "customer_uuid": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "The customer that owns the post."
          },
          "external_reference": {
            "type": "string"
          },
          "integration_slug": {
            "type": "string",
            "description": "The integration of the connection that published. By name, `instagram` and `instagram_business` are the same network: the active connection found is used."
          },
          "source_id": {
            "type": "string"
          },
          "source_name": {
            "type": "string"
          },
          "format": {
            "type": "string",
            "enum": ["feed", "reels", "story", "shorts"]
          },
          "caption": {
            "type": ["string", "null"]
          },
          "status": {
            "type": "string",
            "enum": ["created", "publishing", "published", "failed"]
          },
          "permalink": {
            "type": ["string", "null"]
          },
          "publishing": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PostsPublishing"
              },
              {
                "type": "null"
              }
            ]
          },
          "media": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PostsMedia"
            }
          },
          "instagram": {
            "type": ["object", "null"],
            "description": "Instagram options (`instagram` and `instagram_business`). Feed: `collaborators`, `location_id`, `first_comment`, `comments_disabled`. Reels: the feed ones plus `share_to_feed`, `cover_url`, `audio_id`, `audio_volume`, `video_volume`, `trial_graduation_strategy`. Story: `collaborators`.",
            "properties": {
              "collaborators": {
                "type": "array",
                "maxItems": 5,
                "items": {
                  "type": "string",
                  "maxLength": 30
                }
              },
              "location_id": {
                "type": "string",
                "maxLength": 100
              },
              "share_to_feed": {
                "type": "boolean"
              },
              "cover_url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "audio_id": {
                "type": "string",
                "maxLength": 100
              },
              "audio_volume": {
                "type": "integer",
                "minimum": 0
              },
              "video_volume": {
                "type": "integer",
                "minimum": 0
              },
              "trial_graduation_strategy": {
                "type": "string",
                "enum": ["MANUAL", "SS_PERFORMANCE"]
              },
              "first_comment": {
                "type": "string",
                "maxLength": 2200
              },
              "comments_disabled": {
                "type": "boolean"
              }
            }
          },
          "facebook": {
            "type": ["object", "null"],
            "description": "Facebook (Page) options. Feed: `link` (a post with a link carries no media). Reels: `title` and `cover_url` (cover; if the network refuses the image, the reel goes out with the cover it picks).",
            "properties": {
              "link": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "title": {
                "type": "string",
                "maxLength": 255
              },
              "cover_url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              }
            }
          },
          "threads": {
            "type": ["object", "null"],
            "description": "Threads options, feed only. `link_attachment` goes on a text-only post.",
            "properties": {
              "reply_control": {
                "type": "string",
                "enum": [
                  "everyone",
                  "accounts_you_follow",
                  "mentioned_only",
                  "parent_post_author_only",
                  "followers_only"
                ]
              },
              "link_attachment": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "topic_tag": {
                "type": "string",
                "maxLength": 50,
                "description": "No periods and no `&`."
              },
              "first_comment": {
                "type": "string",
                "maxLength": 500
              }
            }
          },
          "linkedin": {
            "type": ["object", "null"],
            "description": "LinkedIn options (`linkedin` and `linkedin_personal`), feed only. `title` goes only on a single video or document, and is required on a document.",
            "properties": {
              "title": {
                "type": "string",
                "maxLength": 255
              }
            }
          },
          "pinterest": {
            "type": ["object", "null"],
            "description": "Opções do Pinterest. `board_id` é obrigatório. `cover_url` é obrigatória em pin de vídeo e recusada em pin de imagem. Os ids de board e seção vêm de `GET /posts/pinterest/boards`. O `alt_text` da mídia vai até 500 caracteres; no carrossel, só a primeira mídia leva `alt_text`.",
            "properties": {
              "board_id": {
                "type": "string",
                "pattern": "^\\d+$",
                "maxLength": 50
              },
              "board_section_id": {
                "type": "string",
                "pattern": "^\\d+$",
                "maxLength": 50
              },
              "title": {
                "type": "string",
                "maxLength": 100
              },
              "link": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "cover_url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              }
            }
          },
          "youtube": {
            "type": ["object", "null"],
            "description": "YouTube options, Shorts only. `title` and `privacy_status` are required. `category_id` comes from `GET /posts/youtube/categories`. The tags together go up to 500 characters, counted the way YouTube shows them.",
            "properties": {
              "title": {
                "type": "string",
                "maxLength": 100,
                "description": "No `<` and `>`."
              },
              "privacy_status": {
                "type": "string",
                "enum": ["public", "unlisted", "private"]
              },
              "category_id": {
                "type": "string",
                "pattern": "^\\d+$",
                "maxLength": 20
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 500,
                  "description": "No `<`, `>`, or commas."
                }
              },
              "made_for_kids": {
                "type": "boolean"
              },
              "notify_subscribers": {
                "type": "boolean"
              }
            }
          },
          "created_at": {
            "type": "string",
            "description": "`Y-m-d H:i:s`."
          }
        }
      },
      "PostsCreateRequest": {
        "type": "object",
        "description": "Sem `customer_integration` na query, `integration_slug` e `source_name` são obrigatórios. Com ele, não mande nenhum dos dois.\n\nPor rede:\n\n- **Instagram** (`instagram`, `instagram_business`): `feed` (1 imagem, ou carrossel de 2 a 10 imagens e vídeos; um vídeo sozinho vai como `reels`), `reels` (1 vídeo), `story` (1 mídia, sem legenda). Legenda até 2200 caracteres, 30 hashtags e 20 menções.\n- **Facebook** (`facebook`, Página): `feed` (texto, link ou até 10 fotos; vídeo vai como `reels`), `reels` (1 vídeo), `story` (1 mídia, sem legenda).\n- **Threads** (`threads`): só `feed`, texto ou até 20 mídias. Legenda até 500 caracteres.\n- **LinkedIn** (`linkedin`, `linkedin_personal`): só `feed`, texto, de 2 a 20 imagens, ou 1 vídeo, ou 1 documento. Legenda até 3000 caracteres.\n- **Pinterest** (`pinterest`): só `feed`, 1 imagem, 1 vídeo ou carrossel de 2 a 5 imagens. Legenda até 800 caracteres.\n- **YouTube** (`youtube`): só `shorts`, 1 vídeo sem `alt_text`. Descrição até 5000 bytes.\n\nO bloco de opções de uma rede só é aceito para ela, e só com os campos do formato enviado. Documento só no LinkedIn.",
        "required": ["external_reference", "format"],
        "properties": {
          "integration_slug": {
            "type": "string",
            "enum": [
              "instagram",
              "instagram_business",
              "facebook",
              "threads",
              "linkedin",
              "linkedin_personal",
              "pinterest",
              "youtube"
            ]
          },
          "source_name": {
            "type": "string",
            "maxLength": 255
          },
          "source_id": {
            "type": ["string", "null"],
            "maxLength": 255,
            "description": "Disambiguates the account when it's connected and active under more than one login of the network (e.g. `instagram` and `instagram_business`). Without it, that case is refused with `integration_ambiguous`."
          },
          "external_reference": {
            "type": "string",
            "maxLength": 100,
            "description": "The post's id in your system."
          },
          "format": {
            "type": "string",
            "enum": ["feed", "reels", "story", "shorts"]
          },
          "caption": {
            "type": ["string", "null"],
            "description": "Per-network limit above. Stories carry no caption."
          },
          "media": {
            "type": "array",
            "description": "Required, except for text feed posts on Facebook, Threads, and LinkedIn.",
            "items": {
              "type": "object",
              "required": ["type", "url"],
              "properties": {
                "type": {
                  "type": "string",
                  "enum": ["image", "video", "document"]
                },
                "url": {
                  "type": "string",
                  "format": "uri",
                  "maxLength": 2048,
                  "description": "`https://`, public, downloadable by the network."
                },
                "alt_text": {
                  "type": ["string", "null"],
                  "maxLength": 1000
                },
                "user_tags": {
                  "type": ["array", "null"],
                  "description": "Instagram only. Up to 20 per media. On an image, `x` and `y` (from 0 to 1) go together or not at all (without them, the tag sits in the center). On a video, without `x` and `y`. A carousel from an account connected through Instagram Login doesn't accept tags.",
                  "items": {
                    "type": "object",
                    "required": ["username"],
                    "properties": {
                      "username": {
                        "type": "string",
                        "maxLength": 30,
                        "description": "Without `@`. Letters, numbers, periods, and underscores."
                      },
                      "x": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                      },
                      "y": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                      }
                    }
                  }
                }
              }
            }
          },
          "instagram": {
            "type": "object",
            "description": "Instagram options (`instagram` and `instagram_business`). Feed: `collaborators`, `location_id`, `first_comment`, `comments_disabled`. Reels: the feed ones plus `share_to_feed`, `cover_url`, `audio_id`, `audio_volume`, `video_volume`, `trial_graduation_strategy`. Story: `collaborators`.",
            "properties": {
              "collaborators": {
                "type": "array",
                "maxItems": 5,
                "items": {
                  "type": "string",
                  "maxLength": 30
                }
              },
              "location_id": {
                "type": "string",
                "maxLength": 100
              },
              "share_to_feed": {
                "type": "boolean"
              },
              "cover_url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "audio_id": {
                "type": "string",
                "maxLength": 100
              },
              "audio_volume": {
                "type": "integer",
                "minimum": 0
              },
              "video_volume": {
                "type": "integer",
                "minimum": 0
              },
              "trial_graduation_strategy": {
                "type": "string",
                "enum": ["MANUAL", "SS_PERFORMANCE"]
              },
              "first_comment": {
                "type": "string",
                "maxLength": 2200
              },
              "comments_disabled": {
                "type": "boolean"
              }
            }
          },
          "facebook": {
            "type": "object",
            "description": "Facebook (Page) options. Feed: `link` (a post with a link carries no media). Reels: `title` and `cover_url` (cover; if the network refuses the image, the reel goes out with the cover it picks).",
            "properties": {
              "link": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "title": {
                "type": "string",
                "maxLength": 255
              },
              "cover_url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              }
            }
          },
          "threads": {
            "type": "object",
            "description": "Threads options, feed only. `link_attachment` goes on a text-only post.",
            "properties": {
              "reply_control": {
                "type": "string",
                "enum": [
                  "everyone",
                  "accounts_you_follow",
                  "mentioned_only",
                  "parent_post_author_only",
                  "followers_only"
                ]
              },
              "link_attachment": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "topic_tag": {
                "type": "string",
                "maxLength": 50,
                "description": "No periods and no `&`."
              },
              "first_comment": {
                "type": "string",
                "maxLength": 500
              }
            }
          },
          "linkedin": {
            "type": "object",
            "description": "LinkedIn options (`linkedin` and `linkedin_personal`), feed only. `title` goes only on a single video or document, and is required on a document.",
            "properties": {
              "title": {
                "type": "string",
                "maxLength": 255
              }
            }
          },
          "pinterest": {
            "type": "object",
            "description": "Opções do Pinterest. `board_id` é obrigatório. `cover_url` é obrigatória em pin de vídeo e recusada em pin de imagem. Os ids de board e seção vêm de `GET /posts/pinterest/boards`. O `alt_text` da mídia vai até 500 caracteres; no carrossel, só a primeira mídia leva `alt_text`.",
            "properties": {
              "board_id": {
                "type": "string",
                "pattern": "^\\d+$",
                "maxLength": 50
              },
              "board_section_id": {
                "type": "string",
                "pattern": "^\\d+$",
                "maxLength": 50
              },
              "title": {
                "type": "string",
                "maxLength": 100
              },
              "link": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              },
              "cover_url": {
                "type": "string",
                "format": "uri",
                "maxLength": 2048
              }
            }
          },
          "youtube": {
            "type": "object",
            "description": "YouTube options, Shorts only. `title` and `privacy_status` are required. `category_id` comes from `GET /posts/youtube/categories`. The tags together go up to 500 characters, counted the way YouTube shows them.",
            "properties": {
              "title": {
                "type": "string",
                "maxLength": 100,
                "description": "No `<` and `>`."
              },
              "privacy_status": {
                "type": "string",
                "enum": ["public", "unlisted", "private"]
              },
              "category_id": {
                "type": "string",
                "pattern": "^\\d+$",
                "maxLength": 20
              },
              "tags": {
                "type": "array",
                "items": {
                  "type": "string",
                  "maxLength": 500,
                  "description": "No `<`, `>`, or commas."
                }
              },
              "made_for_kids": {
                "type": "boolean"
              },
              "notify_subscribers": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "PostsError": {
        "type": "object",
        "description": "The posts module's business refusals. Branch on `error_code`.",
        "required": ["message", "error_code"],
        "properties": {
          "message": {
            "type": "string"
          },
          "error_code": {
            "type": "string",
            "description": "`idempotency_key_reused`, `integration_not_found`, `integration_ambiguous` (more than one active connection with that name: use `customer_integration`), `integration_inactive`, `carousel_tags_not_supported`, `post_in_progress`, `post_already_published`, `integration_token_invalid` (reconnect the account), `board_not_found`, `network_refused`, `network_unavailable`."
          },
          "post_uuid": {
            "type": "string",
            "format": "uuid",
            "description": "Only on `409`: the post that already holds that `external_reference` in the account."
          }
        }
      },
      "PostsPinterestBoard": {
        "type": "object",
        "required": ["id", "name", "description", "privacy"],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": ["string", "null"]
          },
          "privacy": {
            "type": ["string", "null"]
          }
        }
      },
      "ToolkitFormField": {
        "type": "object",
        "required": ["label"],
        "properties": {
          "label": {
            "type": "string"
          },
          "placeholder": {
            "type": "string"
          }
        }
      },
      "ToolkitAuth": {
        "type": "object",
        "description": "A toolkit connection mode. In `api_key` and `basic`, `fields` says what the end customer types (`key`, or `username` and `password`) and `steps` where they find it in the app. In `oauth2` there's no field: the connection goes through consent in the app, with the merchant's own app.",
        "required": ["mode", "merchant_credential_required"],
        "properties": {
          "mode": {
            "type": "string",
            "enum": ["api_key", "basic", "oauth2"]
          },
          "merchant_credential_required": {
            "type": "boolean",
            "description": "`true` only in `oauth2`: connecting through this mode requires your app registered for the toolkit at `POST /merchants/credentials/{integration_slug}`, with the toolkit slug in place of `integration_slug`."
          },
          "fields": {
            "type": "object",
            "description": "The fields the end customer types, by name: `key`, or `username` and `password`. Only in `api_key` and `basic`.",
            "additionalProperties": {
              "$ref": "#/components/schemas/ToolkitFormField"
            }
          },
          "steps": {
            "type": "array",
            "description": "Where the end customer finds the credential in the app, step by step. Only in `api_key` and `basic`.",
            "items": {
              "type": "string"
            }
          },
          "scopes": {
            "type": "array",
            "description": "The scopes requested at consent. The merchant credential can replace the list. Only in `oauth2`.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Toolkit": {
        "type": "object",
        "required": [
          "slug",
          "name",
          "description",
          "category",
          "version",
          "docs_url",
          "logo_url",
          "auth",
          "base_url_params",
          "tools_count"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "description": "The toolkit identifier, the one the integration session and `/merchants/credentials/{integration_slug}` receive."
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "category": {
            "type": "string",
            "enum": [
              "analytics",
              "communication",
              "crm",
              "developer_tools",
              "ecommerce",
              "email_marketing",
              "file_storage",
              "finance",
              "marketing",
              "productivity",
              "project_management",
              "scheduling",
              "support"
            ]
          },
          "version": {
            "type": "string",
            "description": "The date of the spec's last change, as `YYYY-MM-DD`.",
            "example": "2026-10-19"
          },
          "docs_url": {
            "type": "string",
            "description": "The app's official documentation the spec was written from."
          },
          "logo_url": {
            "type": ["string", "null"],
            "format": "uri",
            "description": "The app's official logo, served by Connect at `/img/toolkits/{toolkit_slug}.svg`, or `.png` when the brand only publishes the icon as PNG, for the merchant's catalog. `null` when the app has no logo; the session screen shows the name's initial in that case.",
            "example": "https://connect.reportei.com/img/toolkits/jira.svg"
          },
          "auth": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ToolkitAuth"
            }
          },
          "base_url_params": {
            "type": "object",
            "description": "The host variables the end customer fills in when connecting, by name. Empty for most apps.",
            "additionalProperties": {
              "type": "object",
              "required": ["label", "format"],
              "properties": {
                "label": {
                  "type": "string"
                },
                "placeholder": {
                  "type": "string"
                },
                "format": {
                  "type": "string",
                  "enum": ["subdomain"]
                }
              }
            }
          },
          "tools_count": {
            "type": "integer"
          }
        }
      },
      "Tool": {
        "type": "object",
        "required": [
          "slug",
          "toolkit_slug",
          "name",
          "description",
          "method",
          "input"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "description": "Global, already with the toolkit prefix."
          },
          "toolkit_slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "description": "What the tool does and what the app expects, written for an agent to pick the right tool."
          },
          "method": {
            "type": "string",
            "enum": ["GET", "POST", "PUT", "PATCH", "DELETE"],
            "description": "The call's verb in the app. `GET` reads; the others write."
          },
          "input": {
            "type": "object",
            "description": "JSON Schema of the execution's `arguments`: an object with `properties`, `required`, and `additionalProperties: false`.",
            "additionalProperties": true
          }
        }
      },
      "CustomerToolkitRequest": {
        "type": "object",
        "required": ["toolkit_slug"],
        "description": "The fields depend on the toolkit's auth mode, in `auth[].fields` of `GET /toolkits/{toolkit_slug}`: `key` for `api_key`; `username` and `password` for `basic`. `base_url_params` takes one entry per `base_url_params` variable of the toolkit.",
        "properties": {
          "toolkit_slug": {
            "type": "string",
            "description": "An enabled toolkit with an `api_key` or `basic` mode."
          },
          "key": {
            "type": "string",
            "maxLength": 2048,
            "description": "The end customer's API key. Only in `api_key` mode."
          },
          "username": {
            "type": "string",
            "maxLength": 255,
            "description": "The first part of the credential (an email, in Jira). Only in `basic` mode."
          },
          "password": {
            "type": "string",
            "maxLength": 2048,
            "description": "The second part of the credential (the API token, in Jira). Only in `basic` mode."
          },
          "base_url_params": {
            "type": "object",
            "description": "Each host variable's value, by name. A single subdomain label: `^[a-z0-9][a-z0-9-]{0,62}$`.",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "CustomerToolkit": {
        "type": "object",
        "description": "An app account linked through a toolkit. The stored credential never shows up.",
        "required": [
          "uuid",
          "toolkit",
          "source_id",
          "source_name",
          "status",
          "base_url_params",
          "expires_at",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "toolkit": {
            "type": "object",
            "required": ["slug", "name"],
            "properties": {
              "slug": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "source_id": {
            "type": "string",
            "description": "The account's identifier in the app, prefixed by the host variable's value when there is one (`acme:5b10ac8d`)."
          },
          "source_name": {
            "type": "string",
            "description": "The account name, as the app identified it."
          },
          "status": {
            "type": "string",
            "enum": ["active", "expired"],
            "description": "`expired`: the merchant credential that authorized it was changed or removed, or the app refused to renew the token. Reconnecting brings it back to `active`."
          },
          "base_url_params": {
            "type": "object",
            "description": "The host variables filled in on the connection. Empty when the host is fixed.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "expires_at": {
            "type": ["string", "null"],
            "description": "When the token expires, in ISO-8601. Null when the app didn't report a validity, and always in `api_key` and `basic` modes."
          },
          "created_at": {
            "type": "string"
          },
          "updated_at": {
            "type": "string"
          }
        }
      },
      "ToolExecuteRequest": {
        "type": "object",
        "required": ["customer_toolkit"],
        "properties": {
          "customer_toolkit": {
            "type": "string",
            "format": "uuid",
            "description": "The customer's connection, from `GET /customer-toolkits`. Must belong to the tool's toolkit and be `active`."
          },
          "arguments": {
            "type": "object",
            "additionalProperties": true,
            "description": "The tool's arguments, per its `input`. An object up to 64 KB; it goes to the app as it came."
          }
        }
      },
      "ToolkitAppError": {
        "type": "object",
        "description": "An app error, relayed with its status.",
        "required": ["error", "api_error"],
        "properties": {
          "error": {
            "type": "string"
          },
          "api_error": {
            "type": "object",
            "required": ["status_code", "headers", "body"],
            "properties": {
              "status_code": {
                "type": "integer"
              },
              "headers": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                },
                "description": "`retry-after`, `x-ratelimit-limit`, `x-ratelimit-remaining`, `x-ratelimit-reset`, `x-request-id` and, on a redirect, `location`, when the app sent them."
              },
              "body": {
                "description": "The app's error body, as it came."
              }
            }
          }
        }
      },
      "ToolkitExecution": {
        "type": "object",
        "required": [
          "uuid",
          "tool_slug",
          "toolkit_slug",
          "customer_toolkit",
          "customer_uuid",
          "method",
          "url",
          "payload",
          "http_status",
          "response",
          "error_message",
          "duration_ms",
          "created_at"
        ],
        "properties": {
          "uuid": {
            "type": "string",
            "format": "uuid"
          },
          "tool_slug": {
            "type": "string"
          },
          "toolkit_slug": {
            "type": "string"
          },
          "customer_toolkit": {
            "type": ["string", "null"],
            "format": "uuid",
            "description": "Null when the connection has already been removed."
          },
          "customer_uuid": {
            "type": "string",
            "format": "uuid",
            "description": "The execution's customer, which `GET /merchants/tools/executions` needs to report."
          },
          "method": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "The URL reached in the app, without the query string."
          },
          "payload": {
            "type": ["object", "null"],
            "additionalProperties": true,
            "description": "The `arguments` sent, decoded: a nested `{}` comes back as `[]`."
          },
          "http_status": {
            "type": ["integer", "null"],
            "description": "The status the app responded with. Null when the app didn't respond."
          },
          "response": {
            "type": ["object", "array", "null"],
            "additionalProperties": true,
            "description": "The app's body, decoded, when it's JSON up to 64 KB: a nested `{}` comes back as `[]`. Above that, or when it isn't JSON, `{ truncated, body }` with the text cut at 64 KB. Null when the app didn't respond. The connection's credential never shows up."
          },
          "error_message": {
            "type": ["string", "null"],
            "description": "When the app didn't respond: Connect's sentence (the app didn't respond in time, the integration failed) or the refused argument. Null when the app responded."
          },
          "duration_ms": {
            "type": ["integer", "null"]
          },
          "created_at": {
            "type": "string"
          }
        }
      },
      "ToolkitExecutionError": {
        "type": "object",
        "required": ["message", "error_code"],
        "properties": {
          "message": {
            "type": "string"
          },
          "error_code": {
            "type": "string",
            "description": "Stable identifier of the refusal. Branch on it, not on the message.",
            "example": "toolkit_timeout"
          },
          "execution_id": {
            "type": "string",
            "format": "uuid",
            "description": "The execution record at `GET /tools/executions/{uuid}`, present when the call was actually made."
          }
        }
      },
      "LlmModel": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "owned_by",
          "context_window",
          "max_output_tokens",
          "supports_tools",
          "supports_vision",
          "pricing"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The `model` value. Always `{provider}/{model}`.",
            "examples": ["anthropic/claude-sonnet-5-5"]
          },
          "object": {
            "type": "string",
            "const": "model"
          },
          "created": {
            "type": "integer",
            "description": "When the model entered the Connect catalog, in Unix seconds."
          },
          "owned_by": {
            "type": "string",
            "enum": ["openai", "anthropic", "meta"],
            "description": "The provider."
          },
          "context_window": {
            "type": "integer",
            "description": "Input and output tokens that fit in one call."
          },
          "max_output_tokens": {
            "type": "integer",
            "description": "The largest `max_tokens` the model accepts."
          },
          "supports_tools": {
            "type": "boolean",
            "description": "Whether the model handles `tools` and returns `tool_calls` in this API."
          },
          "supports_vision": {
            "type": "boolean",
            "description": "Whether the model accepts `image_url` in messages."
          },
          "pricing": {
            "type": "object",
            "description": "The price in dollars per 1 million tokens. Each call's cost is recorded with the price at that time.",
            "required": ["input_per_mtok", "output_per_mtok", "long_context"],
            "properties": {
              "input_per_mtok": {
                "type": "number"
              },
              "output_per_mtok": {
                "type": "number"
              },
              "long_context": {
                "type": ["object", "null"],
                "description": "The long-prompt tier, when the provider charges more above an input size. A call with more than `above_input_tokens` input tokens is charged in full, input and output, at these prices. `null` when the model has a single price.",
                "required": [
                  "above_input_tokens",
                  "input_per_mtok",
                  "output_per_mtok"
                ],
                "properties": {
                  "above_input_tokens": {
                    "type": "integer"
                  },
                  "input_per_mtok": {
                    "type": "number"
                  },
                  "output_per_mtok": {
                    "type": "number"
                  }
                }
              }
            }
          }
        }
      },
      "LlmError": {
        "type": "object",
        "description": "The OpenAI API error format. Branch on `error.code`.",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["message", "type", "code"],
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "invalid_request_error",
                  "permission_error",
                  "not_found_error",
                  "rate_limit_error",
                  "api_error"
                ]
              },
              "code": {
                "type": "string",
                "description": "`llm_not_enabled`, `llm_credential_missing`, `llm_provider_credential_invalid`, `llm_model_not_allowed`, `llm_max_tokens_required`, `llm_max_tokens_exceeded`, `llm_unsupported_field`, `llm_invalid_request`, `llm_request_too_large`, `llm_provider_error`, `llm_concurrency_limit`, `llm_internal_error`, `llm_upstream_error`, `llm_offload_not_configured`, `llm_timeout`."
              }
            }
          }
        }
      },
      "LlmChatCompletionRequest": {
        "type": "object",
        "description": "The body of OpenAI's `POST /v1/chat/completions`. The fields below are the ones the gateway checks or handles; the body goes to the model exactly as sent.",
        "required": ["model", "messages"],
        "properties": {
          "model": {
            "type": "string",
            "description": "The `id` of a model from `GET /llm/models`.",
            "examples": ["anthropic/claude-sonnet-5-5"]
          },
          "models": {
            "type": "array",
            "maxItems": 3,
            "items": {
              "type": "string"
            },
            "description": "Fallback: up to 3 models from `GET /llm/models`, tried in order if `model` fails before the first token."
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "description": "The conversation, as in OpenAI. `role`: `system`, `developer`, `user`, `assistant`, or `tool`. `content`: text, or `text` and `image_url` parts.",
            "items": {
              "type": "object",
              "required": ["role"],
              "properties": {
                "role": {
                  "type": "string",
                  "enum": ["system", "developer", "user", "assistant", "tool"]
                },
                "content": {
                  "type": ["string", "array", "null"]
                },
                "tool_calls": {
                  "type": "array",
                  "items": {
                    "type": "object"
                  }
                },
                "tool_call_id": {
                  "type": "string"
                }
              }
            }
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "Required (or `max_completion_tokens`). Up to the account cap and the `max_output_tokens` of each model in the call."
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "The same as `max_tokens`, under OpenAI's new name. If you send both, both are checked."
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "stream_options": {
            "type": "object",
            "properties": {
              "include_usage": {
                "type": "boolean"
              }
            }
          },
          "temperature": {
            "type": "number"
          },
          "stop": {
            "type": ["string", "array"],
            "items": {
              "type": "string"
            }
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Functions the model can call, as in OpenAI. Only on models with `supports_tools`: if a model in the call doesn't have it, the response is `400 llm_unsupported_field`."
          },
          "tool_choice": {
            "type": ["string", "object"],
            "description": "`auto` or `none` on all models."
          },
          "n": {
            "type": "integer",
            "const": 1,
            "description": "Only `1`."
          }
        }
      },
      "LlmChatCompletion": {
        "type": "object",
        "description": "The non-streamed response, in OpenAI's `chat.completion` format.",
        "required": ["id", "object", "created", "model", "choices"],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string",
            "description": "The model that responded: `model`, or one of `models` if there was a fallback."
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string",
                      "const": "assistant"
                    },
                    "content": {
                      "type": ["string", "null"]
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "finish_reason": {
                  "type": ["string", "null"],
                  "enum": [
                    "stop",
                    "length",
                    "tool_calls",
                    "content_filter",
                    null
                  ]
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/LlmUsage"
          }
        }
      },
      "LlmChatCompletionChunk": {
        "type": "object",
        "description": "A stream event, in OpenAI's `chat.completion.chunk` format.",
        "required": ["id", "object", "created", "model", "choices"],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "chat.completion.chunk"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "delta": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "type": ["string", "null"]
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "finish_reason": {
                  "type": ["string", "null"]
                }
              }
            }
          },
          "usage": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/LlmUsage"
              },
              {
                "type": "null"
              }
            ],
            "description": "Only in the last chunk, and only with `stream_options.include_usage`."
          }
        }
      },
      "LlmUsage": {
        "type": "object",
        "required": ["prompt_tokens", "completion_tokens", "total_tokens"],
        "properties": {
          "prompt_tokens": {
            "type": "integer"
          },
          "completion_tokens": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          }
        }
      }
    },
    "responses": {
      "MediaNotFound": {
        "description": "There is no media with that `uuid` for this customer, or it has already expired.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "examples": {
              "not_found": {
                "value": {
                  "message": "There is no media with this uuid for this customer, or it expired.",
                  "error_code": "media_not_found"
                }
              }
            }
          }
        }
      },
      "Unauthenticated": {
        "description": "API key missing, invalid, or malformed in the header",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Unauthenticated."
            }
          }
        }
      },
      "MerchantAccessDenied": {
        "description": "The key is valid, but the account's access is suspended due to billing",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Merchant trial ended"
            }
          }
        }
      },
      "NotYoursOrNotFound": {
        "description": "The resource doesn't exist or doesn't belong to your account. The API doesn't distinguish the two cases, which is why it doesn't return 404.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "This action is unauthorized."
            }
          }
        }
      },
      "CustomerTokenError": {
        "description": "Problem with the `x-customer-token`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "examples": {
              "missing": {
                "value": {
                  "message": "Missing Customer Token",
                  "error_code": "missing_customer_token"
                }
              },
              "invalid": {
                "value": {
                  "message": "Invalid Customer Token",
                  "error_code": "unauthorized"
                }
              },
              "from_another_merchant": {
                "value": {
                  "message": "Merchant doesnt have access to this resource",
                  "error_code": "unauthorized"
                }
              }
            }
          }
        }
      },
      "CustomerAccessError": {
        "description": "Problem with the `x-customer-token`, or customer without access",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "examples": {
              "missing": {
                "value": {
                  "message": "Missing Customer Token",
                  "error_code": "missing_customer_token"
                }
              },
              "invalid": {
                "value": {
                  "message": "Invalid Customer Token",
                  "error_code": "unauthorized"
                }
              },
              "trial_ended": {
                "summary": "The customer is past the 14 days and isn't marked as paying",
                "value": {
                  "message": "Customer trial ended, mark them as paying to continue using resource",
                  "error_code": "customer_trial_ended"
                }
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "Account request limit exceeded. Retry with backoff.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Too many requests. Please slow down.",
              "error_code": "too_many_requests"
            }
          }
        }
      },
      "MetricsRateLimited": {
        "description": "Request limit exceeded. On top of the account rate limit, a merchant on trial has a metrics quota: 60 per minute and 200 per day, counted per connection read (a request with `customer_integration_uuids` counts once per connection). The trial quota responds with `error_code` `trial_quota_exceeded` and the `Retry-After` header, in seconds, and in the body `window` (`minute` or `day`), `limit`, and `retry_after`. A refused request, whether by the quota, by body validation (422), or by access (403), doesn't use up quota.",
        "headers": {
          "Retry-After": {
            "description": "Seconds until the quota resets. Only comes with the trial quota.",
            "schema": {
              "type": "integer"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "examples": {
              "account_rate_limit": {
                "value": {
                  "message": "Too many requests. Please slow down.",
                  "error_code": "too_many_requests"
                }
              },
              "trial_daily_quota": {
                "value": {
                  "message": "Trial limit: up to 200 metrics requests per day. Subscribe to a plan to read more.",
                  "error_code": "trial_quota_exceeded",
                  "window": "day",
                  "limit": 200,
                  "retry_after": 43200
                }
              },
              "trial_per_minute_quota": {
                "value": {
                  "message": "Trial limit: up to 60 metrics requests per minute.",
                  "error_code": "trial_quota_exceeded",
                  "window": "minute",
                  "limit": 60,
                  "retry_after": 42
                }
              }
            }
          }
        }
      },
      "AdsForbidden": {
        "description": "The given connection doesn't belong to this customer.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AdsError"
            },
            "example": {
              "message": "This action is unauthorized.",
              "error_code": "forbidden"
            }
          }
        }
      },
      "AdsValidationError": {
        "description": "The request was refused before reaching the integration: an invalid field (`validation_error`, with `errors` and `supported_values`), the `Idempotency-Key` missing or reused, the connection expired (`ads_connection_expired`) or outside the ads integrations (`ads_unsupported_integration`). A business refusal from the integration itself can also arrive as 422, with `integration_error`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AdsError"
            },
            "example": {
              "message": "The given data was invalid.",
              "error_code": "validation_error",
              "errors": {
                "campaign.facebook_ads.objective": [
                  "The selected campaign.facebook_ads.objective is invalid."
                ]
              },
              "supported_values": {
                "campaign.facebook_ads.objective": [
                  "awareness",
                  "traffic",
                  "engagement",
                  "leads",
                  "app_promotion",
                  "sales"
                ]
              }
            }
          }
        }
      },
      "AdsObjectNotFound": {
        "description": "The object doesn't exist in this connection's ad account, or the `uuid` isn't for an object Connect stores. An id from another account the token can reach is refused here, and the response doesn't confirm it exists elsewhere.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AdsError"
            },
            "example": {
              "message": "Not Found",
              "error_code": "ads_object_not_found"
            }
          }
        }
      },
      "AdsConflict": {
        "description": "`operation_in_progress`: the same `Idempotency-Key` is still running (`Retry-After` says when to retry). `budget_level_mismatch`: this campaign's budget lives at the other level. `ads_video_not_ready`: the integration is still processing the video; retry with the same key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AdsError"
            },
            "example": {
              "message": "The budget of this campaign lives on the adset; send it there instead.",
              "error_code": "budget_level_mismatch",
              "budget_level": "adset"
            }
          }
        }
      },
      "AdsIntegrationRefused": {
        "description": "The integration refused the operation. The status is the one it returned, and `integration_error` carries its code.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AdsError"
            },
            "example": {
              "message": "You can't use ad set budget with campaign budget.",
              "error_code": "ads_integration_error",
              "integration_error": {
                "integration": "meta_ads",
                "code": 100,
                "subcode": 4834002,
                "user_message": "You can't use ad set budget with campaign budget."
              }
            }
          }
        }
      },
      "AdsIntegrationUnavailable": {
        "description": "The integration didn't respond, or responded with an error of its own. With no status to mirror, it's **502**. Retrying with the same `Idempotency-Key` resumes where it stopped.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/AdsError"
            },
            "example": {
              "message": "The ads integration could not be reached",
              "error_code": "ads_integration_error",
              "integration_error": {
                "integration": "meta_ads",
                "code": null,
                "subcode": null,
                "user_message": null
              }
            }
          }
        }
      },
      "PostsForbidden": {
        "description": "The given connection doesn't belong to this customer.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "This action is unauthorized."
            }
          }
        }
      },
      "PostsValidationError": {
        "description": "An invalid field (`errors`, field by field) or a business refusal (`error_code`).",
        "content": {
          "application/json": {
            "schema": {
              "anyOf": [
                {
                  "$ref": "#/components/schemas/FormValidationError"
                },
                {
                  "$ref": "#/components/schemas/PostsError"
                }
              ]
            },
            "examples": {
              "field": {
                "value": {
                  "message": "The given data was invalid.",
                  "error_code": "validation_error",
                  "errors": {
                    "customer_integration": [
                      "Send customer_integration or integration_slug and source_name, not both."
                    ]
                  }
                }
              },
              "refusal": {
                "value": {
                  "message": "The integration for this source_name is not active.",
                  "error_code": "integration_inactive"
                }
              }
            }
          }
        }
      },
      "PostsNetworkUnavailable": {
        "description": "The network didn't respond. Try again later.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/PostsError"
            },
            "example": {
              "message": "The network is unavailable, try again later.",
              "error_code": "network_unavailable"
            }
          }
        }
      },
      "ToolkitNotFound": {
        "description": "No enabled toolkit has that `slug`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Toolkit 'nope' not found.",
              "error_code": "toolkit_not_found"
            }
          }
        }
      },
      "ToolNotFound": {
        "description": "No enabled toolkit has a tool with that `slug`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Tool 'nope_list' not found.",
              "error_code": "tool_not_found"
            }
          }
        }
      },
      "CustomerToolkitNotFound": {
        "description": "The connection doesn't exist or doesn't belong to this customer. The API doesn't distinguish the two cases.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Customer toolkit '7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e' not found.",
              "error_code": "customer_toolkit_not_found"
            }
          }
        }
      },
      "CustomerToolkitExpired": {
        "description": "The connection is no longer usable: `customer_toolkit_expired` (the merchant credential that authorized it changed, or the app refused to renew the token; reconnecting is the way) or `customer_toolkit_refreshing` (another call is renewing the token right now; retry right after).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Customer toolkit '7c2a1d3e-5f6b-4a8c-9d0e-1f2a3b4c5d6e' is expired. Reconnect it.",
              "error_code": "customer_toolkit_expired"
            }
          }
        }
      },
      "ToolkitExecutionNotFound": {
        "description": "The execution doesn't exist or doesn't belong to this customer.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/MessageError"
            },
            "example": {
              "message": "Execution '0d3c8b4a-2e1f-4c6d-9a7b-5e4f3a2b1c0d' not found.",
              "error_code": "toolkit_execution_not_found"
            }
          }
        }
      },
      "ToolkitIntegrationError": {
        "description": "The integration failed without a response from the app. `execution_id` identifies the record, when the call was actually made.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ToolkitExecutionError"
            },
            "example": {
              "message": "The toolkit integration failed.",
              "error_code": "toolkit_integration_error",
              "execution_id": "0d3c8b4a-2e1f-4c6d-9a7b-5e4f3a2b1c0d"
            }
          }
        }
      },
      "ToolkitTimeout": {
        "description": "The app didn't respond within 25 seconds, or the integration didn't respond within 30. The call may have reached the app: a tool that writes shouldn't be retried blindly.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ToolkitExecutionError"
            },
            "example": {
              "message": "The app did not answer in time.",
              "error_code": "toolkit_timeout",
              "execution_id": "0d3c8b4a-2e1f-4c6d-9a7b-5e4f3a2b1c0d"
            }
          }
        }
      },
      "LlmForbidden": {
        "description": "The account can't use the gateway: `llm_not_enabled` (support turned the gateway off for it) or `merchant_access_denied` (pending payment, in the `{\"message\", \"error_code\"}` format of the rest of the API).",
        "content": {
          "application/json": {
            "schema": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/LlmError"
                },
                {
                  "type": "object",
                  "required": ["message", "error_code"],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "error_code": {
                      "type": "string",
                      "const": "merchant_access_denied"
                    }
                  }
                }
              ]
            },
            "example": {
              "error": {
                "message": "The LLM gateway is not enabled for this account. Contact support to enable it.",
                "type": "permission_error",
                "code": "llm_not_enabled"
              }
            }
          }
        }
      }
    }
  }
}
