Webhook Validator

Calls an external HTTP endpoint to validate and optionally modify the cart during cart validation.

Overview

The Webhook Validator delegates cart validation to an external HTTP endpoint that you host. During cart validation, Omnium sends the cart to your endpoint as a POST request. Your endpoint inspects the cart and returns a validation result that can:

  • approve the cart,
  • reject it with one or more validation errors, and/or
  • return a modified cart (for example with adjusted line items, prices, or properties) that Omnium applies back to the cart.

This makes it suitable for custom validation rules, external stock or price checks, fraud screening, or any logic that must run against the cart and lives in your own systems.

The Webhook Validator operates on the cart. It runs when the cart is validated — for example via the cart Validate endpoint and other cart validation flows. It does not run against orders.

Identifier

PropertyValue
Connector IDwebhookValidator
Validation TypeExternal

Setup

Add a connector named webhookValidator to the Connectors section in tenant settings. The connector's host is the URL Omnium posts the cart to.

{
  "name": "webhookValidator",
  "implementations": ["IValidator"],
  "host": "https://validation.example.com/api/cart-validate",
  "bearerToken": "YOUR_API_KEY",
  "properties": [
    { "key": "IsRequestWrapperEnabled", "value": "false" },
    { "key": "IsOnlyLineItemsUpdated", "value": "false" }
  ]
}

The name must be exactly webhookValidator — that is how Omnium locates the connector for this validator.

Authentication

Omnium sets the Authorization header on every request based on the connector configuration. Use one of:

FieldHeader sent
bearerTokenAuthorization: Bearer <token>
tokenAuthorization: Token <token>
username + passwordAuthorization: Basic <base64>

For other schemes, add headers via customHeaders instead.

Properties

KeyTypeDefaultDescription
IsRequestWrapperEnabledboolfalseWhen true, the cart is wrapped in a request envelope ({ "cart": { ... } }) instead of being sent as the bare cart object.
IsOnlyLineItemsUpdatedboolfalseWhen true and your response returns a cart in value, only the line items (value.orderForm.lineItems) are applied back to the cart. When false, the entire returned cart is applied.

Optional connector fields

FieldTypeDescription
customHeadersarrayExtra HTTP headers added to every request
timeOuttimespanRequest timeout (e.g. "00:00:30")
enabledForMarketsstring[]Only run for these markets
disabledForMarketsstring[]Exclude these markets
enabledForMarketGroupsstring[]Only run for these market groups
disabledForMarketGroupsstring[]Exclude these market groups

Request — what your endpoint receives

Omnium sends a POST request to the connector's host with the cart as the JSON body. Field names are camelCase.

Default (no wrapper): the body is the cart object directly.

POST /api/cart-validate HTTP/1.1
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Accept: application/json
User-Agent: OmniumOms/{version}
{
  "id": "C123456",
  "marketId": "NOR",
  "billingCurrency": "NOK",
  "status": "Draft",
  "orderForm": {
    "lineItems": [
      {
        "lineItemId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "code": "SHOE-BLACK-42",
        "displayName": "Running Shoe - Black - Size 42",
        "quantity": 1,
        "placedPrice": 999.00,
        "extendedPrice": 999.00
      }
    ],
    "subTotal": 999.00,
    "total": 999.00
  }
}

The body is the full cart (OmniumCart) — the same model returned by the Cart API. The fields above are illustrative; the actual payload contains the complete cart.

With IsRequestWrapperEnabled = true: the cart is nested under cart.

{
  "cart": {
    "id": "C123456",
    "marketId": "NOR",
    "orderForm": { "lineItems": [ /* ... */ ] }
  }
}

Request headers

HeaderValue
Content-Typeapplication/json
Acceptapplication/json
User-AgentOmniumOms/{version}
AuthorizationBased on connector auth config (see Authentication)

Plus any headers configured via customHeaders.

Response — what your endpoint must return

Return HTTP 200 with a JSON validation result:

FieldTypeDescription
isValidatedSuccessfulbooltrue if the cart passed. Defaults to true if omitted. Forced to false whenever validationErrors is non-empty.
validationErrorsarrayValidation errors. A non-empty list fails validation.
validationWarningsarrayWarnings. Do not fail validation.
validationMessagestringOptional overall message.
valueobjectOptional. A modified cart to apply back (see Modifying the cart).

Each entry in validationErrors / validationWarnings:

FieldTypeDescription
messagestringHuman-readable message.
translateKeystringOptional translation key.
validationTypestringCategory, e.g. External, Inventory, Price, Customer.
referenceIdstringOptional reference, e.g. a SKU or line item ID.

Approve the cart

Return 200 with {} or:

{
  "isValidatedSuccessful": true
}

Reject the cart

Return one or more validationErrors. A non-empty list marks the cart as invalid regardless of isValidatedSuccessful.

{
  "isValidatedSuccessful": false,
  "validationErrors": [
    {
      "message": "Item SHOE-BLACK-42 is not available for delivery to this postal code",
      "validationType": "External",
      "referenceId": "SHOE-BLACK-42"
    }
  ]
}

Modifying the cart

To change the cart, return the updated cart in value. Omnium applies it back to the cart.

{
  "isValidatedSuccessful": true,
  "value": {
    "id": "C123456",
    "orderForm": {
      "lineItems": [
        {
          "lineItemId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
          "code": "SHOE-BLACK-42",
          "quantity": 1,
          "placedPrice": 899.00
        }
      ]
    }
  }
}
  • When IsOnlyLineItemsUpdated = true, only value.orderForm.lineItems is applied; the rest of the returned cart is ignored.
  • When IsOnlyLineItemsUpdated = false (default), the full returned cart is applied.

The request envelope and the response use different field names for the cart. With IsRequestWrapperEnabled enabled, the request wraps the cart under cart, but the response must always return the cart under value.

Behavior

ConditionResult
HTTP 200, isValidatedSuccessful: true, no validationErrorsCart passes
HTTP 200 with a non-empty validationErrorsCart fails validation; errors are returned to the caller
HTTP 200 with valueThe returned cart (or only its line items) is applied back to the cart
Non-2xx responseValidation fails with an External error containing the status code and response body

Omnium sends camelCase field names in the request. Field matching on the response is case-insensitive, so isValidatedSuccessful and IsValidatedSuccessful are both accepted.

On this page