{
  "format": "manual-highlevel-workflow-recipe",
  "name": "QuietPass — Phone data (OFF)",
  "version": 1,
  "published": false,
  "automaticTriggers": false,
  "allowReEntry": false,
  "allowMultipleOpportunities": false,
  "configuration": {
    "profile": "phone",
    "locationId": "REPLACE_LOCATION_ID",
    "workflowId": "REPLACE_WORKFLOW_ID",
    "currency": "GBP",
    "allowPaid": false,
    "maximumMicros": 0
  },
  "reviewedMaximumMicros": 20000,
  "authentication": {
    "type": "protected-bearer-credential",
    "origin": "https://quietpass.com",
    "exportCredentials": false
  },
  "steps": [
    {
      "id": "read-source",
      "type": "native-contact-fields",
      "purpose": "Read individual native fields for permanent contact ID, fixed location, phone, explicit ISO country, qp_phone_source_revision and existing receipt. Prefix sourcePhone with phone: to prevent HighLevel numeric coercion."
    },
    {
      "id": "build-request",
      "type": "custom-code",
      "helper": "requestBody",
      "purpose": "Return serialized body and source receipt. No secret inputs."
    },
    {
      "id": "retain-source",
      "type": "retain-execution-output",
      "value": "build-request.receipt",
      "purpose": "Keep the original source receipt in this execution before POST. Do not overwrite a previously bound contact receipt with a preview or unbound request. Never manufacture a revision on retry."
    },
    {
      "id": "lookup",
      "type": "custom-webhook",
      "event": "POST",
      "bodyMode": "key-value",
      "method": "POST",
      "url": "https://quietpass.com/v1/automation/highlevel",
      "body": {
        "payload": "build-request.body"
      },
      "saveResponse": true,
      "followRedirects": false,
      "purpose": "Select Event POST and map the code body into a single payload key/value field. Do not use CUSTOM Raw Body; native interpolation changes serialized JSON escaping. Preview by default. Explicit paid opt-in and existing server limits are both required."
    },
    {
      "id": "bind-operation",
      "type": "custom-code",
      "helper": "retainDecision",
      "purpose": "Bind the operation and normalized E.164 to the original source receipt; reject any changed source metadata."
    },
    {
      "id": "retain-operation",
      "type": "update-contact-fields",
      "condition": "bind-operation.retain === true",
      "fields": [
        "qp_phone_operation_id",
        "qp_phone_source_receipt"
      ],
      "value": "bind-operation",
      "purpose": "Retain the validated operation receipt before CRM result writes. On failure retain this execution response."
    },
    {
      "id": "settled-only",
      "type": "if-else",
      "condition": "lookup.readyToWrite === true AND lookup.state === settled AND lookup.resultState === settled",
      "otherwise": "Stop for preview, pending, unavailable, expired, or HTTP failure. Do not purchase a replacement."
    },
    {
      "id": "reread-source",
      "type": "current-contact-fields",
      "purpose": "Use newly resolved native contact fields immediately before writing, only after an external-edit rehearsal proves they are fresh. Find Contact is skipped for an enrolled contact and is not a fresh-read guarantee."
    },
    {
      "id": "guard-write",
      "type": "custom-code",
      "helper": "writeGuard",
      "purpose": "Require the same location, contact, phone, source revision, original operation and result request ID; skip duplicate writes."
    },
    {
      "id": "write-owned-fields",
      "type": "update-contact-fields",
      "condition": "guard-write.write === true",
      "fields": [
        "qp_phone_e164",
        "qp_phone_country",
        "qp_phone_type",
        "qp_phone_carrier",
        "qp_phone_ported",
        "qp_phone_sms",
        "qp_phone_sms_basis",
        "qp_phone_reachable",
        "qp_phone_checked_at",
        "qp_phone_request_id"
      ],
      "purpose": "Write text fields only. Preserve false; write unknown for unavailable. Never write source phone, country, consent, lifecycle or owner."
    }
  ],
  "recovery": "recovery.json",
  "remainingRace": "HighLevel source reread and field update are separate operations; a small concurrent-edit window remains. Keep number, source receipt and checked time visible."
}
