{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/converly-io/json-schema/converly-io-create-destination-body-schema.json",
  "title": "CreateDestinationBody",
  "description": "Meta paste-token connect, or same-candidate Meta retry using attempt_id. Provide either credentials or attempt_id, never both. Does NOT support `google-ads` or `google-analytics`: both connect through POST /destinations/oauth-handoffs (a `google-analytics` body here answers 400 unsupported_destination).",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/converly-io-openapi.yml#/components/schemas/CreateDestinationBody",
  "anyOf": [
    {
      "type": "object",
      "properties": {
        "destination_type": {
          "type": "string",
          "enum": [
            "meta"
          ]
        },
        "site_id": {
          "type": "string",
          "description": "The site (prefixed site_… id) whose connections this call reads or changes. Required for account-wide keys on accounts with more than one site (otherwise 400 site_id_required, listing the sites). A site-scoped token uses its bound site."
        },
        "credentials": {
          "$ref": "#/$defs/MetaCredentials"
        }
      },
      "required": [
        "destination_type",
        "credentials"
      ],
      "additionalProperties": false
    },
    {
      "type": "object",
      "properties": {
        "destination_type": {
          "type": "string",
          "enum": [
            "meta"
          ]
        },
        "site_id": {
          "type": "string",
          "description": "The site (prefixed site_… id) whose connections this call reads or changes. Required for account-wide keys on accounts with more than one site (otherwise 400 site_id_required, listing the sites). A site-scoped token uses its bound site."
        },
        "attempt_id": {
          "type": "string",
          "format": "uuid",
          "description": "Public attempt_id from a prior Meta reconnect result. Recheck its saved candidate under the same authenticated site; omit credentials."
        }
      },
      "required": [
        "destination_type",
        "attempt_id"
      ],
      "additionalProperties": false
    }
  ],
  "$defs": {
    "MetaCredentials": {
      "type": "object",
      "properties": {
        "access_token": {
          "type": "string",
          "minLength": 20,
          "description": "Meta Graph API access token. ≥20 chars."
        },
        "meta_pixel_id": {
          "type": "string",
          "pattern": "^\\d+$",
          "description": "Meta pixel id — numeric string."
        }
      },
      "required": [
        "access_token",
        "meta_pixel_id"
      ]
    }
  }
}