{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/elocuenti-com/json-schema/elocuenti-com-feedback-request-body-schema.json",
  "title": "FeedbackRequestBody",
  "description": "Send exactly one of `order_id` (an order in Elocuenti) or `external_reference` (your own order number). `idempotency_key` is optional: without it the key is `order_id` (as text) or else `external_reference`, within your business, so the same order never gets two surveys.",
  "x-generated": "2026-11-06",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/elocuenti-com-openapi.json#/components/schemas/FeedbackRequestBody",
  "type": "object",
  "properties": {
    "phone": {
      "type": "string",
      "minLength": 10,
      "description": "Customer phone in E.164 format.",
      "title": "Phone"
    },
    "template_name": {
      "type": "string",
      "minLength": 1,
      "description": "WhatsApp template name to send.",
      "title": "Template Name"
    },
    "template_params": {
      "description": "Optional template variables. Keys must match the template's `parameter_mapping` (e.g. `customer_name`, `order_id`). Merged with defaults (`customer_name`, `order_id`).",
      "anyOf": [
        {
          "type": "object",
          "additionalProperties": true
        },
        {
          "type": "null"
        }
      ],
      "title": "Template Params"
    },
    "order_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "UUID of the order being asked about. Optional — omit for ticketing/marketplace flows that don't sync orders into Elocuenti.",
      "title": "Order Id"
    },
    "external_reference": {
      "description": "Caller's own ID for the transaction (any string). Used for dedup when no order_id is available.",
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "External Reference"
    },
    "idempotency_key": {
      "description": "Explicit dedup key. Defaults to order_id (as text) or external_reference. To send AGAIN for an order that already has a row (e.g. to re-deliver a corrected link), pass a different key such as `<external_reference>-resend-1`: dedup is per (tenant, idempotency_key) only.",
      "anyOf": [
        {
          "type": "string",
          "maxLength": 255
        },
        {
          "type": "null"
        }
      ],
      "title": "Idempotency Key"
    },
    "batch_id": {
      "description": "Optional caller-supplied batch identifier. Echoed verbatim into the structured logs so a whole send can be reconciled per batch (created / deduplicated / failed) with a single log query.",
      "anyOf": [
        {
          "type": "string",
          "maxLength": 128
        },
        {
          "type": "null"
        }
      ],
      "title": "Batch Id"
    },
    "customer_name": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Customer Name"
    },
    "customer_email": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Customer Email"
    },
    "fallback_template": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Optional fallback template name if the primary is not found.",
      "title": "Fallback Template"
    },
    "from": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Optional. The business WhatsApp number to send from, in E.164 (e.g. `+573001234567`). Omit it to send from the business default. A number that is not one of the business's active numbers is refused with 422 `from_number_not_available`.",
      "title": "From"
    }
  },
  "required": [
    "phone",
    "template_name"
  ]
}