{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/infiniteaudience-ai/json-schema/infiniteaudience-ai-continuous-purchase-control-command-schema.json",
  "title": "ContinuousPurchaseControlCommand",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/infiniteaudience-ai-integrations-api-openapi.yml#/components/schemas/ContinuousPurchaseControlCommand",
  "oneOf": [
    {
      "type": "object",
      "required": [
        "action",
        "scopes",
        "max_records_per_period",
        "max_charge_cents_per_period"
      ],
      "properties": {
        "action": {
          "type": "string",
          "const": "preview"
        },
        "scopes": {
          "type": "array",
          "minItems": 1,
          "maxItems": 50,
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/ContinuousPurchaseScope"
              },
              {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string",
                    "enum": [
                      "hubspot",
                      "klaviyo"
                    ]
                  }
                }
              }
            ]
          }
        },
        "max_records_per_period": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100000000
        },
        "max_charge_cents_per_period": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "expires_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "required": [
        "action",
        "scopes",
        "max_records_per_period",
        "max_charge_cents_per_period",
        "request_id",
        "expected_revision",
        "billing_terms_fingerprint"
      ],
      "properties": {
        "action": {
          "type": "string",
          "const": "approve"
        },
        "scopes": {
          "type": "array",
          "minItems": 1,
          "maxItems": 50,
          "items": {
            "allOf": [
              {
                "$ref": "#/$defs/ContinuousPurchaseScope"
              },
              {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string",
                    "enum": [
                      "hubspot",
                      "klaviyo"
                    ]
                  }
                }
              }
            ]
          }
        },
        "max_records_per_period": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100000000
        },
        "max_charge_cents_per_period": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "expires_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "request_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 240
        },
        "expected_revision": {
          "type": [
            "string",
            "null"
          ]
        },
        "billing_terms_fingerprint": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "additionalProperties": false
    }
  ],
  "$defs": {
    "ContinuousPurchaseScope": {
      "type": "object",
      "required": [
        "provider",
        "connection_id",
        "selected_fields"
      ],
      "properties": {
        "provider": {
          "type": "string",
          "enum": [
            "shopify",
            "hubspot",
            "klaviyo"
          ]
        },
        "connection_id": {
          "type": "string",
          "minLength": 1,
          "maxLength": 240
        },
        "selected_fields": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}