{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ometria/json-schema/ometria-order-extended-schema.json",
  "title": "Order Extended",
  "description": "Describes an Order record.",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/ometria-swagger-openapi.json#/components/schemas/OrderExtended",
  "type": "object",
  "required": [
    "@type",
    "id",
    "timestamp",
    "totals"
  ],
  "properties": {
    "@type": {
      "type": "string",
      "description": "The value must be \"order\". This shows that this record represents an order object."
    },
    "id": {
      "type": "string"
    },
    "timestamp": {
      "type": "string",
      "description": "Time the order was placed on the site or in store. Following ISO 8601 dateTime format with timezone offset _YYYY-MM-DDThh:mm:ss+Z_.",
      "format": "date-time"
    },
    "totals": {
      "$ref": "#/$defs/OrderExtendedTotals"
    },
    "web_id": {
      "type": "string",
      "description": "The web ID passed with through the JS tracker, this is only required if the value is different to the id."
    },
    "status": {
      "type": "string",
      "description": "Code representing the status of this order, e.g. 'complete', 'pending', 'shipped' etc, max length: 32."
    },
    "is_valid": {
      "type": "boolean",
      "description": "Whether or not the order is <a href=\"https://support.ometria.com/hc/en-gb/articles/360011169057-Valid-orders-in-Ometria\" target=\"_blank\">valid</a>, i.e. payment was correctly processed.\n Valid orders are counted in revenue reporting. Use `True` for valid orders, `False` for invalid orders."
    },
    "customer": {
      "$ref": "#/$defs/OrderCustomer"
    },
    "lineitems": {
      "type": "array",
      "description": "Array of OrderLineItem objects representing the items in this order.",
      "items": {
        "type": "object",
        "description": "Describes an individual product line item added to an Order.",
        "required": [
          "product_id",
          "quantity",
          "unit_price",
          "totals"
        ],
        "properties": {
          "product_id": {
            "type": "string",
            "description": "The ID of the product in this line item, max length: 255."
          },
          "quantity": {
            "type": "integer",
            "description": "The number of products in the line item (excluding any refunded items).\nThis field is required if you are using the lineitem array."
          },
          "unit_price": {
            "type": "number",
            "description": "The unit price of the product in this line item.",
            "format": "float"
          },
          "quantity_refunded": {
            "type": "integer",
            "description": "The number of products refunded in the line item."
          },
          "totals": {
            "$ref": "#/$defs/OrderExtendedLineItemTotals",
            "description": "The totals of the lineitem. This field can be used to express the order value in an account base currency and a local currency."
          },
          "is_on_sale": {
            "type": "boolean",
            "description": "Indicating whether the product was on sale when the order was placed."
          },
          "variant_options": {
            "type": "array",
            "description": "An array of [OrderLineItemVariantOption](#definition-OrderLineItemVariantOption) objects.",
            "items": {
              "$ref": "#/$defs/OrderLineItemVariantOption"
            }
          },
          "properties": {
            "description": "Custom key / value pairs accessible in emails using the related Order object.",
            "type": "object"
          }
        }
      }
    },
    "ip_address": {
      "type": "string",
      "description": "IP address of visitor who placed order if known."
    },
    "channel": {
      "type": "string",
      "description": "The channel this order came through, e.g., 'online', 'in store', 'mobile app' etc.\nThis can be a useful reporting filter in Ometria, so it is helpful to differentiate your channels as much as possible.\nMaximum chararacters 16. If you exceed the character limit this field will pass validation, but appear truncated in Ometria.",
      "default": "online"
    },
    "store": {
      "type": "string",
      "description": "Code representing the store the order was placed in, max length: 32, lower case.\nIf left empty this field is set to 'null'."
    },
    "payment_method": {
      "type": "string",
      "description": "Code representing payment method."
    },
    "shipping_method": {
      "type": "string",
      "description": "Code representing shipping method, max length: 100.\nIf you exceed the character limit this field will pass validation but appear truncated in Ometria."
    },
    "shipping_address": {
      "$ref": "#/$defs/OrderAddress"
    },
    "billing_address": {
      "$ref": "#/$defs/OrderAddress"
    },
    "coupon_code": {
      "description": "The coupon code applied to this order, max length: 128 characters, lower case. Orders with a longer coupon code are rejected.\nIf left empty this field is set to 'null'.",
      "type": "string"
    },
    "properties": {
      "description": "Custom key / value pairs accessible in emails using this order object.",
      "type": "object"
    },
    "extra_identifiers": {
      "type": [
        "array",
        "null"
      ],
      "description": "Optional list of extra identifiers (such as a loyalty ID) as per your identity resolution configuration, e.g. `loyalty_id`. Custom identifiers must be configured for your account before you send them. See <a href=\"https://support.ometria.com/hc/en-gb/articles/32595707442077-Custom-identifiers\">Custom identifiers</a> for the full format, multi-valued identifiers, and CSV usage.",
      "items": {
        "$ref": "#/$defs/ExtraIdentifier"
      }
    }
  },
  "$defs": {
    "ExtraIdentifier": {
      "title": "Extra Identifier",
      "type": "object",
      "description": "An additional identifier for a record, used to attach non-standard customer or record IDs (e.g. loyalty programme IDs, external CRM IDs). Records may carry multiple extra identifiers.",
      "required": [
        "type",
        "value"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "The identifier type label. Must contain only lowercase letters and underscores (regex `^[a-z_]+$`), 1-255 characters. Will be coerced to lowercase on ingestion.",
          "minLength": 1,
          "maxLength": 255,
          "pattern": "^[a-z_]+$"
        },
        "value": {
          "type": "string",
          "description": "The identifier value (free-form string)."
        }
      }
    },
    "OrderAddress": {
      "type": "object",
      "description": "Describes an Address.",
      "properties": {
        "city": {
          "type": "string",
          "description": "The city or town for this address, max length: 32, lower case.\nFollow ISO 3166-1 alpha-2.\nIf you exceed the character limit this field will pass validation but appear truncated in Ometria.\nIf left empty this field is set to 'null'."
        },
        "state": {
          "type": "string",
          "description": "The state or county of the address, max length: 32, lower case.\nIf you exceed the character limit this field will pass validation but appear truncated in Ometria.\nIf left empty this field is set to 'null'."
        },
        "postcode": {
          "type": "string",
          "description": "The postcode or zipcode of the address, max length: 32, lower case.\nIf you exceed the character limit this field will pass validation but appear truncated in Ometria.\nIf left empty this field is set to 'null'."
        },
        "country_code": {
          "type": "string",
          "description": "The country for this address, must be 2 characters, upper case, e.g. 'GB'.\nFollow ISO 3166-1 alpha-2.\nIf left empty this field is set to 'null'.",
          "minLength": 2,
          "maxLength": 2
        }
      }
    },
    "OrderCustomer": {
      "type": "object",
      "description": "The details of the customer who placed the order.",
      "properties": {
        "id": {
          "type": "string",
          "description": "The <a href=\"https://ometria-api-reference.readme.io/docs/contacts-endpoint#customer-ids\" target=\"_blank\">customer's ID</a>, max length: 255.\nThis can be any unique identifier you use for your customers which you'd like to use for reporting in Ometria. It must not contain any personally identifiable information (name, email address etc.)"
        },
        "email": {
          "type": "string",
          "description": "The customer's email address, max length: 255, lower case.\nIf left empty this field is set to 'null'."
        },
        "firstname": {
          "type": "string",
          "description": "The customer's first name, max length: 64."
        },
        "lastname": {
          "type": "string",
          "description": "The customer's last name, max length: 64."
        },
        "phone_number": {
          "type": "string",
          "description": "The customer's phone number, in E.164/International format (e.g. starting \"+447...\")"
        }
      }
    },
    "OrderExtendedBaseTotal": {
      "type": "object",
      "description": "The totals of this order represented in the base currency",
      "required": [
        "grand_total",
        "currency"
      ],
      "properties": {
        "currency": {
          "type": "string",
          "description": "The base currency totals - as set for your account. Following ISO 4217",
          "minLength": 3,
          "maxLength": 3
        },
        "shipping": {
          "type": "number",
          "description": "The value of the shipping in the base currency",
          "format": "float"
        },
        "tax": {
          "type": "number",
          "description": "The value of the tax in the base currency",
          "format": "float"
        },
        "discount": {
          "type": "number",
          "description": "The value of the discount in the base currency as a negative number",
          "format": "float"
        },
        "subtotal": {
          "type": "number",
          "description": "The value of the subtotal in the base currency",
          "format": "float"
        },
        "grand_total": {
          "type": "number",
          "description": "The value of the grand total in the base currency",
          "format": "float"
        }
      }
    },
    "OrderExtendedLineItemBaseTotal": {
      "type": "object",
      "description": "The totals of this lineitem represented in the base currency",
      "required": [
        "total"
      ],
      "properties": {
        "currency": {
          "type": "string",
          "description": "The currency of the base lineitem totals - as set for your account. Following ISO 4217",
          "minLength": 3,
          "maxLength": 3
        },
        "unit_price": {
          "type": "number",
          "description": "The value of the unit price in the base currency",
          "format": "float"
        },
        "discount": {
          "type": "number",
          "description": "The value of the discount on the lineitem in the base currency as a negative number",
          "format": "float"
        },
        "refunded": {
          "type": "number",
          "description": "The total price of refunded products in this line item.",
          "format": "float"
        },
        "subtotal": {
          "type": "number",
          "description": "The subtotal of this lineitem in the base currency (after refunded amounts have been taken into consideration).",
          "format": "float"
        },
        "tax": {
          "type": "number",
          "description": "The tax of this lineitem in the base currency (after refunded amounts have been taken into consideration).",
          "format": "float"
        },
        "total": {
          "type": "number",
          "description": "The total price of this line item in the base currency (after refunded amounts have been taken into consideration).",
          "format": "float"
        }
      }
    },
    "OrderExtendedLineItemLocalTotal": {
      "type": "object",
      "description": "The totals of this lineitem represented in the local currency",
      "required": [
        "total"
      ],
      "properties": {
        "currency": {
          "type": "string",
          "description": "The currency of the local lineitem totals. Following ISO 4217",
          "minLength": 3,
          "maxLength": 3
        },
        "unit_price": {
          "type": "number",
          "description": "The value of the unit price in the local currency",
          "format": "float"
        },
        "discount": {
          "type": "number",
          "description": "The value of any discount applied to the line item.\nThis value should be either a negative number, e.g. -`2.99` or `0`.",
          "format": "float"
        },
        "refunded": {
          "type": "number",
          "description": "The total price of refunded products in this line item.",
          "format": "float"
        },
        "subtotal": {
          "type": "number",
          "description": "The subtotal of this lineitem in the local currency (after refunded amounts have been taken into consideration).",
          "format": "float"
        },
        "tax": {
          "type": "number",
          "description": "The tax of this lineitem in the local currency (after refunded amounts have been taken into consideration).",
          "format": "float"
        },
        "total": {
          "type": "number",
          "description": "The total price of this lineitem in the local currency (after refunded amounts have been taken into consideration).",
          "format": "float"
        }
      }
    },
    "OrderExtendedLineItemTotals": {
      "type": "object",
      "description": "The totals of the lineitem. This can be used to express the order value in a base currency and a local currency.",
      "properties": {
        "base": {
          "$ref": "#/$defs/OrderExtendedLineItemBaseTotal"
        },
        "local": {
          "$ref": "#/$defs/OrderExtendedLineItemLocalTotal"
        }
      }
    },
    "OrderExtendedLocalTotal": {
      "type": "object",
      "description": "The totals of this order represented in the local currency",
      "required": [
        "grand_total",
        "currency"
      ],
      "properties": {
        "currency": {
          "type": "string",
          "description": "The currency of the local totals.  Following ISO 4217",
          "minLength": 3,
          "maxLength": 3
        },
        "shipping": {
          "type": "number",
          "description": "The value of the shipping in the local currency",
          "format": "float"
        },
        "tax": {
          "type": "number",
          "description": "The value of the tax in the local currency",
          "format": "float"
        },
        "discount": {
          "type": "number",
          "description": "The value of the discount in the local currency as a negative number",
          "format": "float"
        },
        "subtotal": {
          "type": "number",
          "description": "The value of the subtotal in the local currency",
          "format": "float"
        },
        "grand_total": {
          "type": "number",
          "description": "The grand total of the order.",
          "format": "float"
        }
      }
    },
    "OrderExtendedTotals": {
      "type": "object",
      "description": "The totals of the order in a base currency and a local currency.",
      "properties": {
        "base": {
          "$ref": "#/$defs/OrderExtendedBaseTotal"
        },
        "local": {
          "$ref": "#/$defs/OrderExtendedLocalTotal"
        }
      }
    },
    "OrderLineItemVariantOption": {
      "type": "object",
      "description": "Describes the configurable options attached to a Lineitem.",
      "required": [
        "type",
        "id",
        "label"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "The type of the variant option."
        },
        "id": {
          "type": "string",
          "description": "The id of the variant option."
        },
        "label": {
          "type": "string",
          "description": "The label of the variant option."
        }
      }
    }
  }
}