CRADמפתחים
עברית

Change booking or business-wide WhatsApp permission

לפני שימוש חי — בדקו יכולות פרוסות, הרשאות ומוכנות של החיבור שלכם.

בדקו את היכולות הפרוסות, הרשאות המפתח ומוכנות העסק בסביבה שלכם. דוגמאות HTTP נלכדו בבדיקות מבודדות; הסימון local-unreleased שלהן אינו אומר שה־API אינו פועל, ואינו מאשר את החיבור שלכם. במסלול הלקוח מאמתים טלפון בתבנית WhatsApp שהעסק הגדיר; SMS אינו נתמך. רישום בידי אדמין מורשה הוא פעולה נפרדת ללא קוד.

PATCH/v1/sites/{siteId}/bookings/{bookingId}/communication-preferences

Behavior

scope: booking affects this booking. scope: all_whatsapp withdraws or explicitly renews permission for this phone across this business. Booking-only opt-in cannot remove global withdrawal. Global resubscription requires the displayed globalVersion and fresh confirmation if it changes. A replay returns its original receipt plus current state; render current preferences, which may remain globally blocked after a later withdrawal.

Authentication

CustomerSession

Credential rules

Opaque short-lived customer session, upgraded by CRAD phone proof; neither a website account nor a cookie grants this authority. A session created with a companion integration credential remains bound to that credential: every request rechecks its expiry and revocation. Omitting or replacing the companion header later does not rebind the session. Current phone proof is required where stated by the operation. After expiry, create a new session and explicitly verify the same phone and integration to recover a known request or booking; retain the original locators and never auto-confirm during recovery.

X-CRAD-Integration-Key (optional header): Optional companion backend credential for the same integration, server requests only; never send from a browser. Required to bind an externalCustomerId on registration.

If this customer session was created with a companion integration credential, that bound credential must still grant bookings:write:customer. Its current expiry/revocation is checked as well; an unrelated key sent later does not repair the session.

Request

Idempotency and recovery

Persist one UUID and the exact request before sending. After an uncertain result, retain that UUID, body and preconditions; do not create a replacement operation just to retry.

  • siteIdpath · stringRequired
    Format and constraints
    siteId schema
    {
      "type": "string",
      "format": "uuid"
    }
  • bookingIdpath · stringRequired
    Format and constraints
    bookingId schema
    {
      "type": "string",
      "format": "uuid"
    }
  • If-Matchheader · stringRequired

    Strong preference ETag returned by notifications. Separate from appointment version.

    Format and constraints
    If-Match schema
    {
      "type": "string",
      "pattern": "^\"n[1-9][0-9]*\"$"
    }
  • Idempotency-Keyheader · stringRequired

    Persist and reuse this exact UUID and request after an unknown result. Do not create a fresh operation to retry.

    Format and constraints
    Idempotency-Key schema
    {
      "type": "string",
      "format": "uuid"
    }
  • X-CRAD-Integration-Keyheader · stringOptional

    Optional companion backend credential for the same integration, server requests only; never send from a browser. Required to bind an externalCustomerId on registration.

    Format and constraints
    X-CRAD-Integration-Key schema
    {
      "type": "string",
      "pattern": "^(?:wbi|wbm)_[a-f0-9]{64}$"
    }

Request body · required

application/json · NotificationPreferences

All of these schema rules apply together.

  • whatsappbooleanRequired

    The explicit customer choice. A booking-only true value does not undo an existing global withdrawal.

  • scopestringRequired

    booking changes this booking only. all_whatsapp changes global WhatsApp permission for the same phone at this business; it is not limited to this integration or booking.

    Allowed values: ["booking","all_whatsapp"]

  • noticeVersionstringOptional

    Value: "website-transactional-whatsapp-v1"

  • expectedGlobalVersionintegerOptional

    Required only for all_whatsapp=true. Copy the current preferences.globalVersion shown to the customer; a stale value requires refresh and fresh confirmation, not an automatic retry with a newer version.

    minimum: 0maximum: 9007199254740991

  • allOf 1unspecifiedSchema branch
    View branch fields and rules
    • ifobjectSchema rule
      View branch fields and rules
      • whatsappbooleanCondition predicate

        Value: true

    • thenunspecifiedSchema rule
      View branch fields and rules
      • noticeVersionunspecifiedRequired in this branch

        Presence constraint in this rule; evaluate its enclosing condition or negation. The field’s type may be defined elsewhere.

  • allOf 2unspecifiedSchema branch
    View branch fields and rules
    • ifobjectSchema rule
      View branch fields and rules
      • whatsappbooleanCondition predicate

        Value: true

      • scopestringCondition predicate

        Value: "all_whatsapp"

    • thenunspecifiedSchema rule
      View branch fields and rules
      • expectedGlobalVersionunspecifiedRequired in this branch

        Presence constraint in this rule; evaluate its enclosing condition or negation. The field’s type may be defined elsewhere.

    • elseunspecifiedSchema rule
      View branch fields and rules
      • notunspecifiedSchema rule

        This rule must not match.

        View branch fields and rules
        • expectedGlobalVersionunspecifiedPart of a negated rule

          Presence constraint in this rule; evaluate its enclosing condition or negation. The field’s type may be defined elsewhere.

  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "properties": {
    "whatsapp": {
      "type": "boolean",
      "description": "The explicit customer choice. A booking-only true value does not undo an existing global withdrawal."
    },
    "scope": {
      "enum": [
        "booking",
        "all_whatsapp"
      ],
      "description": "booking changes this booking only. all_whatsapp changes global WhatsApp permission for the same phone at this business; it is not limited to this integration or booking."
    },
    "noticeVersion": {
      "const": "website-transactional-whatsapp-v1"
    },
    "expectedGlobalVersion": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9007199254740991,
      "description": "Required only for all_whatsapp=true. Copy the current preferences.globalVersion shown to the customer; a stale value requires refresh and fresh confirmation, not an automatic retry with a newer version."
    }
  },
  "required": [
    "whatsapp",
    "scope"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "whatsapp": {
            "const": true
          }
        },
        "required": [
          "whatsapp"
        ]
      },
      "then": {
        "required": [
          "noticeVersion"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "whatsapp": {
            "const": true
          },
          "scope": {
            "const": "all_whatsapp"
          }
        },
        "required": [
          "whatsapp",
          "scope"
        ]
      },
      "then": {
        "required": [
          "expectedGlobalVersion"
        ]
      },
      "else": {
        "not": {
          "required": [
            "expectedGlobalVersion"
          ]
        }
      }
    }
  ]
}

Successful responses

200 · NotificationPreferenceResult

Authoritative result; notification acceptance is independent of booking success.

ETag · Strong quoted version of returned current.preferences, including on replay. It is not the version of the historical preference receipt.
ETag schema
{
  "type": "string",
  "pattern": "^\"n[1-9][0-9]*\"$"
}

application/json · NotificationPreferenceResult

  • receiptallOf (object & unspecified)Required

    All of these schema rules apply together.

    View nested fields
    • allOf 1objectSchema branch
      View branch fields and rules
      • bookingIdstring · uuidRequired
      • preferencesVersionintegerRequired

        minimum: 1

      • whatsappbooleanRequired
      • scopestringRequired

        Allowed values: ["booking","all_whatsapp"]

      • additionalPropertiesno value allowedSchema rule
    • allOf 2unspecifiedSchema branch

      Immutable result of the original accepted preference operation. On replay it may differ from current consent after a later change.

  • currentallOf (object & unspecified)Required

    All of these schema rules apply together.

    View nested fields
    • allOf 1objectSchema branch
      View branch fields and rules
      • bookingIdstring · uuidRequired
      • bookingVersionintegerRequired

        minimum: 1

      • preferencesobjectRequired
        View nested fields
        • versionintegerRequired

          minimum: 1

        • whatsappbooleanRequired
        • globallyBlockedbooleanRequired
        • globalVersionintegerRequired

          minimum: 0maximum: 9007199254740991

        • noticeVersionanyOf (string | null)Required

          At least one of these variants must match.

          View nested fields
          • anyOf 1stringSchema branch
          • anyOf 2nullSchema branch
        • additionalPropertiesno value allowedSchema rule
      • notificationsarrayRequired
        View nested fields
        • []objectArray item

          One logical notification. A booking can have multiple reminder entries with different offsetMinutes. The default is one reminder approximately two hours before the appointment; businesses explicitly enabled for configurable reminders may schedule up to their authorized limit of three. Confirmation, change and cancellation entries do not consume that reminder allowance. A changed appointment start has a separate allowance; returning to a previously used start does not replay an already attempted reminder. Availability depends on the deployed scheduler and the business configuration. Customer booking and communication-preference requests cannot change the business reminder limit or offsets. Businesses explicitly choose a 24-hour reminder (1440 minutes) through owner preview/apply; this is not a global default. Pending requests do not receive confirmed-appointment reminders. Proposal/rejection use separate approved templates and current opt-in.

          View nested fields
          • idstring · uuidRequired
          • purposestringRequired

            Allowed values: ["confirmation","change","cancellation","reminder","proposal","rejection"]

          • channelstringRequired

            Value: "whatsapp"

          • statestringRequired

            accepted is provider acceptance, not delivery. unknown is an uncertain send outcome and is not an instruction to resend. Notification failure does not undo an accepted appointment.

            Allowed values: ["not_requested","unavailable","scheduled","queued","accepted","delivered","failed","unknown","suppressed","expired"]

          • reasonanyOf (string | null)Required

            At least one of these variants must match.

            View nested fields
            • anyOf 1stringSchema branch
            • anyOf 2nullSchema branch
          • dueAtstring · date-timeRequired
          • offsetMinutesintegerOptional

            Reminder lead time in elapsed minutes, for example 1440, 480 or 60. Optional for compatibility with legacy projections; it does not indicate a customer-service messaging window.

            minimum: 60maximum: 10080multipleOf: 60

          • scheduledAtstring · date-timeOptional

            Same instant as dueAt for configurable reminder entries. Legacy projections may omit this additive field.

          • updatedAtstring · date-timeRequired
          • additionalPropertiesno value allowedSchema rule
      • additionalPropertiesno value allowedSchema rule
    • allOf 2unspecifiedSchema branch

      Current authorized notification and consent state. Use this for display after either a new operation or a replay.

  • replayedbooleanRequired
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "properties": {
    "receipt": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "bookingId": {
              "type": "string",
              "format": "uuid"
            },
            "preferencesVersion": {
              "type": "integer",
              "minimum": 1
            },
            "whatsapp": {
              "type": "boolean"
            },
            "scope": {
              "enum": [
                "booking",
                "all_whatsapp"
              ]
            }
          },
          "required": [
            "bookingId",
            "preferencesVersion",
            "whatsapp",
            "scope"
          ],
          "additionalProperties": false
        },
        {
          "description": "Immutable result of the original accepted preference operation. On replay it may differ from current consent after a later change."
        }
      ]
    },
    "current": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "bookingId": {
              "type": "string",
              "format": "uuid"
            },
            "bookingVersion": {
              "type": "integer",
              "minimum": 1
            },
            "preferences": {
              "type": "object",
              "properties": {
                "version": {
                  "type": "integer",
                  "minimum": 1
                },
                "whatsapp": {
                  "type": "boolean"
                },
                "globallyBlocked": {
                  "type": "boolean"
                },
                "globalVersion": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 9007199254740991
                },
                "noticeVersion": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "version",
                "whatsapp",
                "globallyBlocked",
                "globalVersion",
                "noticeVersion"
              ],
              "additionalProperties": false
            },
            "notifications": {
              "type": "array",
              "items": {
                "type": "object",
                "description": "One logical notification. A booking can have multiple reminder entries with different offsetMinutes. The default is one reminder approximately two hours before the appointment; businesses explicitly enabled for configurable reminders may schedule up to their authorized limit of three. Confirmation, change and cancellation entries do not consume that reminder allowance. A changed appointment start has a separate allowance; returning to a previously used start does not replay an already attempted reminder. Availability depends on the deployed scheduler and the business configuration. Customer booking and communication-preference requests cannot change the business reminder limit or offsets. Businesses explicitly choose a 24-hour reminder (1440 minutes) through owner preview/apply; this is not a global default. Pending requests do not receive confirmed-appointment reminders. Proposal/rejection use separate approved templates and current opt-in.",
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "purpose": {
                    "enum": [
                      "confirmation",
                      "change",
                      "cancellation",
                      "reminder",
                      "proposal",
                      "rejection"
                    ]
                  },
                  "channel": {
                    "const": "whatsapp"
                  },
                  "state": {
                    "enum": [
                      "not_requested",
                      "unavailable",
                      "scheduled",
                      "queued",
                      "accepted",
                      "delivered",
                      "failed",
                      "unknown",
                      "suppressed",
                      "expired"
                    ],
                    "description": "accepted is provider acceptance, not delivery. unknown is an uncertain send outcome and is not an instruction to resend. Notification failure does not undo an accepted appointment."
                  },
                  "reason": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "dueAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "offsetMinutes": {
                    "type": "integer",
                    "minimum": 60,
                    "maximum": 10080,
                    "multipleOf": 60,
                    "description": "Reminder lead time in elapsed minutes, for example 1440, 480 or 60. Optional for compatibility with legacy projections; it does not indicate a customer-service messaging window."
                  },
                  "scheduledAt": {
                    "type": "string",
                    "format": "date-time",
                    "description": "Same instant as dueAt for configurable reminder entries. Legacy projections may omit this additive field."
                  },
                  "updatedAt": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "id",
                  "purpose",
                  "channel",
                  "state",
                  "reason",
                  "dueAt",
                  "updatedAt"
                ],
                "additionalProperties": false
              }
            }
          },
          "required": [
            "bookingId",
            "bookingVersion",
            "preferences",
            "notifications"
          ],
          "additionalProperties": false
        },
        {
          "description": "Current authorized notification and consent state. Use this for display after either a new operation or a replay."
        }
      ]
    },
    "replayed": {
      "type": "boolean"
    }
  },
  "required": [
    "receipt",
    "current",
    "replayed"
  ],
  "additionalProperties": false
}

Errors and recovery

Input validation

  • 413REQUEST_TOO_LARGE

    The JSON request body exceeds 8,192 bytes.

  • 415JSON_REQUIRED

    Send Content-Type: application/json.

Error responses declared in the contract (10)

The preview contract shares generic error definitions across operations. This list is not an exhaustive list of runtime errors.

401 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
403 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
404 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
409 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
410 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
412 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
422 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
428 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
429 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}
503 · Structured failure. Keep the same operation key if outcome is uncertain.

application/json · Error

  • errorobjectRequired
    View nested fields
    • codestringRequired
    • requestIdstring · uuidRequired
    • retryAfterintegerOptional

      minimum: 1

    • additionalPropertiesno value allowedSchema rule
  • additionalPropertiesno value allowedSchema rule
Complete schema and nested fields
JSON Schema
{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "error": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "code": {
          "type": "string"
        },
        "requestId": {
          "type": "string",
          "format": "uuid"
        },
        "retryAfter": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "code",
        "requestId"
      ]
    }
  },
  "required": [
    "error"
  ]
}