{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/servera-co-uk/json-schema/servera-co-uk-partner-provision-body-schema.json",
  "title": "PartnerProvisionBody",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/servera-co-uk-openapi.json#/components/schemas/PartnerProvisionBody",
  "properties": {
    "customer": {
      "$ref": "#/$defs/PartnerCustomer"
    },
    "items": {
      "items": {
        "$ref": "#/$defs/PartnerItem"
      },
      "type": "array",
      "title": "Items",
      "description": "Products to order."
    },
    "reference": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Reference",
      "description": "Your own order reference (also used as idempotency anchor in notes)."
    },
    "send_emails": {
      "type": "boolean",
      "title": "Send Emails",
      "description": "Send the end customer the verification + order emails.",
      "default": true
    },
    "link_if_exists": {
      "type": "boolean",
      "title": "Link If Exists",
      "description": "If a customer with this email already exists in Servera but is not yet owned by this partner, link (adopt) it and place the order instead of returning 409. Use for returning customers who already have a Servera account.",
      "default": false
    },
    "start_date": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Start Date",
      "description": "Optional service start date (YYYY-MM-DD) for the whole order. When set, recurring services are billed from this date (registration + next_due anchor here, and the invoice period shows [start_date, start_date+cycle)) instead of the payment date. Must be today or later. Omit to start billing from the payment date."
    }
  },
  "type": "object",
  "required": [
    "customer",
    "items"
  ],
  "$defs": {
    "PartnerCustomer": {
      "properties": {
        "email": {
          "type": "string",
          "title": "Email",
          "description": "End-customer email (used to create/identify the account)."
        },
        "first_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "First Name"
        },
        "last_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Last Name"
        },
        "company_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Company Name"
        },
        "company_number": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Company Number",
          "description": "Company registration code."
        },
        "tax_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tax Id",
          "description": "VAT / tax id, e.g. LT100000000000."
        },
        "phone": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Phone"
        },
        "country": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Country",
          "description": "ISO country code, e.g. LT."
        },
        "language": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Language",
          "description": "Preferred language, e.g. lt or en."
        },
        "vat_validated": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Vat Validated",
          "description": "Set true if YOU (the partner) already validated this VAT number via VIES at registration. Servera then records the validation so the invoice applies 0% reverse charge for a valid intra-EU B2B customer (e.g. an LV company billed by the LT company). Send ONLY when the VIES check actually returned valid.",
          "default": false
        },
        "vat_validated_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Vat Validated Name",
          "description": "Company name returned by VIES for that VAT number (optional; stored with the validation)."
        }
      },
      "type": "object",
      "required": [
        "email"
      ],
      "title": "PartnerCustomer"
    },
    "PartnerItem": {
      "properties": {
        "product_id": {
          "type": "integer",
          "title": "Product Id",
          "description": "Allowed product id."
        },
        "billing_cycle": {
          "type": "string",
          "title": "Billing Cycle",
          "description": "'onetime' for hardware, or monthly/quarterly/semiannually/annually/biennially/triennially for a subscription."
        },
        "quantity": {
          "type": "integer",
          "maximum": 500.0,
          "minimum": 1.0,
          "title": "Quantity",
          "description": "How many.",
          "default": 1
        },
        "giveaway": {
          "type": "boolean",
          "title": "Giveaway",
          "description": "If true, this line is a 100% giveaway (e.g. a free device bundled with a subscription): billed at full price with a -100% discount line on the invoice, netting to 0. The partner decides eligibility.",
          "default": false
        },
        "giveaway_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Giveaway Name",
          "description": "Localized label for the giveaway discount line (e.g. 'Dovana - irenginys nemokamai'). Shown on the invoice. Defaults to a generic label when omitted."
        }
      },
      "type": "object",
      "required": [
        "product_id",
        "billing_cycle"
      ],
      "title": "PartnerItem"
    }
  }
}