{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tokportal-com/json-schema/tokportal-com-create-bundle-request-schema.json",
  "title": "CreateBundleRequest",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tokportal-com-openapi.json#/components/schemas/CreateBundleRequest",
  "type": "object",
  "required": [
    "bundle_type"
  ],
  "properties": {
    "bundle_type": {
      "type": "string",
      "enum": [
        "account_only",
        "account_and_videos",
        "videos_only"
      ]
    },
    "platform": {
      "type": "string",
      "enum": [
        "tiktok",
        "instagram"
      ],
      "default": "tiktok",
      "description": "TikTok or Instagram only. YouTube is priced in getCreditCosts but cannot be ordered: a YouTube bundle is rejected with YOUTUBE_DELAYED."
    },
    "country": {
      "type": "string",
      "minLength": 2,
      "maxLength": 5,
      "description": "Country code exactly as returned by listCountries. Most are ISO-3166-1 alpha-2 (FR, DE, BR), but two are not: the United States is \"USA\" and the United Kingdom is \"UK\". The aliases \"US\" and \"GB\" are accepted and resolved to those. A full country name such as \"United States\" is rejected. Required unless bundle_type is videos_only."
    },
    "title": {
      "type": "string",
      "maxLength": 200
    },
    "videos_quantity": {
      "type": "integer",
      "minimum": 0,
      "maximum": 500,
      "default": 0,
      "description": "Minimum 5 for a new videos_only bundle on an existing account. Zero is allowed for account-only creation. To buy 1-4 additional slots, use addBundleVideoSlots on an eligible active bundle; completed bundles cannot receive more slots."
    },
    "edits_quantity": {
      "type": "integer",
      "minimum": 0,
      "maximum": 500,
      "default": 0
    },
    "wants_niche_warming": {
      "type": "boolean",
      "default": false,
      "deprecated": true,
      "description": "Legacy — kept only for accounts being re-created after a refund; use Advanced Niche Warming (wants_advanced_warming)."
    },
    "wants_deep_warming": {
      "type": "boolean",
      "default": false,
      "deprecated": true,
      "description": "Legacy — kept only for accounts being re-created after a refund; use Advanced Niche Warming (wants_advanced_warming)."
    },
    "wants_advanced_warming": {
      "type": "boolean",
      "default": false,
      "description": "Advanced Niche Warming, the warming product: niche-target (search-term) based warming with recorded proof and a data report. MANDATORY whenever you send advanced_warming_terms or advanced_warming_terms_count — TokPortal never infers it, and sending targets without it is rejected with ADVANCED_WARMING_FLAG_REQUIRED rather than charged and dropped. The standard rate is 5 credits per target (per target, never per day); GET /credit-costs returns the effective rate. TikTok and Instagram only. Provide advanced_warming_terms now, or advanced_warming_terms_count to configure the targets later."
    },
    "advanced_warming_terms": {
      "type": "array",
      "minItems": 3,
      "maxItems": 30,
      "x-item-count-multiple-of": 3,
      "items": {
        "type": "string",
        "minLength": 2,
        "maxLength": 50
      },
      "description": "3-30 niche targets (search terms), count a multiple of 3, each 2-50 characters. REQUIRES wants_advanced_warming: true in the same body (ADVANCED_WARMING_FLAG_REQUIRED otherwise). Every term must survive cleanup intact: entries are trimmed and compared case-insensitively, and if any is dropped as a duplicate or for its length the call fails with ADVANCED_WARMING_TERMS_REJECTED listing what was dropped — TokPortal will not quietly deliver, or bill, fewer targets than you asked for. Send this list OR advanced_warming_terms_count, not both: a count that disagrees with the list length fails with ADVANCED_WARMING_COUNT_MISMATCH."
    },
    "advanced_warming_terms_count": {
      "type": "integer",
      "minimum": 3,
      "maximum": 30,
      "multipleOf": 3,
      "x-value-multiple-of": 3,
      "description": "Number of niche targets to purchase (3-30, multiples of 3; standard rate 5 credits each; GET /credit-costs returns the effective rate); the alternative to advanced_warming_terms when the targets are not decided yet. REQUIRES wants_advanced_warming: true in the same body (ADVANCED_WARMING_FLAG_REQUIRED otherwise). Do not send it alongside advanced_warming_terms unless it equals that list's length — a disagreement fails with ADVANCED_WARMING_COUNT_MISMATCH instead of one quantity silently winning. Configure the targets later via PUT /bundles/{id}/warming-terms — but BEFORE publishing: publishBundle refuses a bundle whose warming has no targets (ADVANCED_WARMING_NOT_CONFIGURED), because a warming that can never start also stops the bundle from ever completing. A purchase left unconfigured is not refunded."
    },
    "niche_warming_instructions": {
      "type": "string",
      "maxLength": 2000,
      "deprecated": true,
      "description": "Legacy — kept only for accounts being re-created after a refund; use Advanced Niche Warming (wants_advanced_warming)."
    },
    "auto_finalize_videos": {
      "type": "boolean",
      "default": true,
      "description": "Defaults to true: delivered videos are approved automatically and count as final. Set false to hold each delivered video for your manual review (approve or request corrections). Changeable later via updateBundle."
    },
    "account_id": {
      "type": "string",
      "format": "uuid",
      "description": "The single delivered account a videos_only bundle posts to. Required for videos_only bundles, forbidden otherwise. One bundle targets exactly one account — to post across several accounts, create one bundle per account."
    },
    "external_ref": {
      "type": "string",
      "maxLength": 200,
      "description": "Optional client correlation reference and duplicate-detection aid for new-account bundles. Reusing it can return DUPLICATE_ACCOUNT_BUNDLE. It does not provide request retry or response replay; use Idempotency-Key for that."
    },
    "partner_client": {
      "type": "object",
      "required": [
        "client_ref"
      ],
      "properties": {
        "client_ref": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "The partner's own stable identifier for its end client."
        },
        "client_email": {
          "type": [
            "string",
            "null"
          ],
          "format": "email",
          "maxLength": 320
        },
        "client_name": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 200
        },
        "order_ref": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 200,
          "description": "The partner's order identifier (may be shared by several bundles)."
        },
        "account_ref": {
          "type": [
            "string",
            "null"
          ],
          "maxLength": 200,
          "description": "The partner's identifier for the account this bundle produces."
        }
      },
      "additionalProperties": false,
      "description": "Partner platforms only (resellers registered with TokPortal). Records which of the partner's own clients this order is for; returned as partner_client on getBundle and listBundles. Ignored, and reported in meta.ignored_fields, for every other API key."
    }
  },
  "dependentRequired": {
    "advanced_warming_terms": [
      "wants_advanced_warming"
    ],
    "advanced_warming_terms_count": [
      "wants_advanced_warming"
    ]
  },
  "not": {
    "required": [
      "wants_niche_warming",
      "wants_advanced_warming"
    ],
    "properties": {
      "wants_niche_warming": {
        "const": true
      },
      "wants_advanced_warming": {
        "const": true
      }
    }
  },
  "additionalProperties": false
}