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

Connect your business calendar

Use your own staff interface to read, create and manage approved appointments, then keep a scoped local calendar in sync.

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

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

Start with the staff action

This guide is for a business administration backend. Keep your existing calendar UI and authenticate your staff on your server. Send a Management bearer from that server only; an Origin header is refused. The customer self-service booking workflow remains a separate API with phone proof and different versions.

The calendar contract is a development preview. Its recorded examples are isolated SQL/HTTP observations, not live delivery or an external installation. Obtain an approved API base, business/integration binding and environment readiness before activation. No UI package is required.

Ask the owner for both the necessary appointments scopes and a per-credential calendar grant. A key with scopes but no approved grant cannot access the calendar. Existing keys are not widened. GET /v1/management shows installed support, granted scopes and resources.appointments; those are different facts.

Staff taskRequired approval
Read appointments and resourcesappointments:read plus a current calendar resource grant.
Quote, availability and creationappointments:read and appointments:create. The contact must already have a canonical businessCustomerId.
Status, missed and conditional undoappointments:read and appointments:status; current action admission still applies.
Cancel, including status:CANCELLEDappointments:read and appointments:cancel; explicit notice choice and current preview.
Move an accepted appointmentappointments:read and appointments:reschedule, business_manager ceiling and recognized accepted terms.
Replicate the calendarappointments:read and appointments:sync for a bounded date range and approved resources.
Display personal detailsJoined customer basics additionally require contacts:read. Appointment notes require appointments:notes:read and notesRead in the calendar grant.

Keep resource access explicit

A provider grant covers one active provider and cannot reschedule. A business_manager grant can cover selected providers or wholeBusiness. wholeBusiness covers assigned providers; includeUnassigned independently controls appointments with no provider. Calendar grants are separate from hours/block grants and from customer-field grants.

Read resources for supported providers, services and booking modes. Do not infer booking permission from a listed provider, an installed capability or an available slot. Customer names can be null without contacts:read; notes can be null without their independent grant. Raw customer notes and custom_data are never calendar output.

Directory from/to select appointments that overlap a half-open range of at most 93 days. Omit providerId for all currently granted resources, use a provider UUID for one granted resource, or providerId=unassigned for the separately approved unassigned set. This differs from block listing, where omitted providerId means business-wide blocks only.

Create one reviewed appointment

  1. Select or record the customer

    Use canonical businessCustomerId. A trusted staff contact entry can use contacts:record; lookup/read need their own permissions. A mappingId or website account ID is not a businessCustomerId. These steps do not create phone proof or WhatsApp consent.

    Record a business contactLook up one exact business phoneList business customers
  2. Review a quote

    Send businessCustomerId and the selected provider/service/removal choice. Quotes expire after five minutes. Service-duration businesses require compatible treatment terms; an ordinary appointment can have null service and price. The server owns duration and price.

    Review appointment terms
  3. Choose an available time

    Send the same selection and a business localDate. Display returned startAt/endAt instants using the returned timezone. The server applies the selected treatment, scheduled breaks and existing bookings; calendar cell spacing does not determine valid starts. Availability does not reserve capacity; use the reviewed quoteVersion and returned startAt for creation.

    Find available business appointment times
  4. Persist and submit once

    Before POST, save one operation UUID and exact request in your backend. Put that UUID in Idempotency-Key. A new acceptance returns 201; an accepted replay returns 200. This staff command is silent and does not imply a booking confirmation message.

    Create a business appointment
  5. Recover uncertainty

    Recover the original UUID before another write. not_found does not prove an in-flight request cannot commit. Keep the same request, quoteVersion and operation UUID for exact retry; do not fetch a new quote or create a replacement intent while the old result is uncertain.

    Recover an uncertain appointment command

Use the returned booking times

A configured business can space starts by the total selected treatment duration, including removal, and restart that spacing at the end of a scheduled break. For a 90-minute treatment, hours 09:00–18:00 and a break 12:00–12:30, the schedule can offer 09:00, 10:30, 12:30, 14:00 and 15:30 before other constraints remove times. This is an illustrative schedule, not a live availability response or a rule for every business.

The optional slotGridAnchor:segment_start in a Management quote or accepted terms records this rule. When absent, preserve the existing day-opening anchor, even if slotIntervalMinutes equals durationMinutes. Do not infer it from current business settings. Existing bookings and blocks remove conflicting starts without restarting the spacing.

Keep accepted terms and operation receipts unchanged. Rescheduling and alternative proposals use the accepted appointment’s saved grid rule; later policy changes do not rewrite it. Fetch the server’s availability for that action instead of rebuilding a time list in your interface.

Use the correct money and version units

Oversized or invalid stored price, terms or notes can be null with a fieldUnavailableReasons entry. Display the unavailable value honestly; do not turn it into zero or silently substitute current catalogue data.

Use the authoritative quote and its returned total range, including supported provider overrides and removal fees. Preserve optional range fields through your backend and browser models. “Price decided at the visit” applies to an explicitly unpriced treatment in a validated published service/current service quote, or its recognized frozen accepted terms. A null appointment price alone does not establish that agreement: ordinary or legacy appointments without recognized accepted terms remain unknown/unavailable. Accepted terms remain frozen after catalogue changes.

ContractHow to interpret it
Management calendar priceMajor and totalPriceMajorMajor units: 120 means 120 currency units. A numeric zero is explicit; null is not a zero price. Read currency separately. Never divide these values by 100.
Management quote totalPriceRangeMajor and accepted terms basePriceRangeMajor/totalPriceRangeMajorOptional range bounds in major units. HALA range pricing retains a null exact amount. Display the returned total range as an estimate; never use its minimum as a fixed charge.
Customer self-service booking pricesThe existing booking contract uses integer ILS minor units. Do not pass that money object into calendar commands.
Unknown ordinary appointment currencycurrency:null means no accepted currency was saved. Do not guess from today’s service catalogue.
Accepted termsterms preserves the accepted treatment, duration and money. A later catalogue change does not rewrite an accepted appointment.
Physical appointment versionPreserve aN and its quoted ETag, such as "a3", for If-Match. This is not websiteVersion, an owner grant revision or a sync projection epoch.

Review a change against the version on screen

Use allowedActions as current UI advice, then submit the exact quoted ETag you displayed. The command rechecks authority, transition, timing and capacity. After a 412 conflict, re-read and ask the staff member to review current state; do not silently replace If-Match.

A 409 REMINDER_IN_PROGRESS refuses the requested change; nothing was accepted for that request. An unresolved reminder claim can prevent leaving CONFIRMED, including a change to NOW. Refresh the appointment and allowedActions, explain that the change was not saved, and let the staff member explicitly retry later. Do not retry automatically or infer that a reminder was delivered.

A timeout or lost response is different: the change may already have committed. Recover the original operation UUID and retain its exact request until the result is known; do not create a new intent or automatically repeat the staff action.

Approve an approval-required PENDING request directly with action:status and status:CONFIRMED, the displayed If-Match and one saved operation UUID. Omit notificationIntent and previewVersion; no action preview is required. CRAD queues that decision’s customer confirmation, subject to booking consent and current delivery gates. Do not also create a campaign. Approval preserves the booking’s update language and does not establish missing consent.

Cancellation, including status:CANCELLED, and rescheduling need a five-minute action preview and an explicit notificationIntent: silent or request_notice. The final action sends that previewVersion, unchanged choice, rendered If-Match and a durable operation UUID saved before dispatch. propose_time also requires preview/apply, with newStartAt and request_notice; read proposal-availability first. It preserves PENDING until customer agreement and is not an immediate confirmed replacement. Other ordinary status actions omit previewVersion.

Rescheduling changes the start time only, preserving accepted customer/provider/service/duration/price. It cancels the original physical row and creates a successor. Follow receipt.successorAppointmentId and current.appointmentId, while retaining the original receipt. Ordinary appointments without recognized accepted terms cannot use this replacement operation.

mark_missed can return a server-bound undo descriptor valid for at most six seconds. Undo is a separate status-authorized command using that prior operation ID and accepted version; it must still pass current checks. There is no arbitrary revival of accepted snapshots or unrestricted status assignment.

Settle an uncertain creation without losing its original identity

GET appointment-operations/{operationId} is read-only. not_found does not prove that a delayed create cannot still commit. Keep the original UUID and exact body; never release a customer hold merely because the requested time passed or a later quote changed.

The reviewed contract adds POST appointment-operations/{operationId}/resolve for a deliberately abandoned, uncertain Management create. Send the original creation body and original operation UUID, with current appointments:read, appointments:create and the original resource grant. This is a state-changing resolution, not another availability check. Confirm the endpoint is deployed before using it.

Resolution serializes with the original create. If creation won, status:committed returns its immutable receipt and current authorized lineage. Otherwise status:rejected with receipt.outcome:not_executed permanently fences that UUID, so even a delayed original POST cannot create an appointment. Only that terminal proof allows the unresolved hold to end and a separately reviewed booking to begin. A timeout or authority refusal during resolution leaves the original command unresolved.

Retain original intent, UUID, notes and receipts after resolution. Repeating the same resolution is safe; a changed body conflicts. This endpoint does not settle customer-session intents, edits, reschedules or cancellations, which retain their own recovery contracts.

Separate accepted changes from message delivery

receipt is immutable accepted history; current is authorized state at the time of this response. It can be newer, point to a successor, or be null with a reason after removal or loss of access. Recovery still needs current same-integration authority for the original action and resource.

request_notice requests follow-up; it does not promise delivery. The accepted receipt can say queued while notificationCurrent later says unavailable, accepted, delivered, failed, unknown or suppressed. accepted is provider acceptance; delivered requires matching delivery evidence. notificationCurrent.reason can be connection_changed when the saved sender binding no longer matches or WhatsApp is unavailable. Restore the connection and inspect the notification without repeating the appointment command. Reasons are extensible; preserve unknown values. A connection or template failure does not undo the appointment.

An ordinary cancellation uses legacy_cancellation; a requested ordinary replacement uses business_calendar_change; a website-linked booking can retain its website route. Actual dispatch depends on its configured and enabled route, current authority, sender, recipient and messaging rules. No command grants consent or activates a scheduler. Unknown dispatch must not trigger a duplicate appointment command or an automatic duplicate message.

Bootstrap and maintain a scoped local calendar

Use a separate cursor/checkpoint store for appointment, customer and website booking-lineage feeds. projectionEpoch and scopeId are opaque; neither is an appointment version. A fixed-range mirror does not automatically move forward with the calendar—start a new scoped bootstrap when the desired range changes.

Native panel, bot and approved API writes participate in the same physical appointment stream. A metadata signal can be followed by newer current state. Source labels mask other integrations and native users; do not treat them as a staff identity audit. Calendar operation receipts preserve only their accepted facts.

  1. Fix the range and resource set

    POST from/to spanning at most 93 days. Omitted providerId means all current granted resources; JSON null selects permitted unassigned appointments. A snapshot captures up to 10,000 membership IDs, lasts 30 minutes and has a limit of 10 active snapshots per credential.

    Begin a scoped appointment synchronization
  2. Apply membership pages

    Follow only returned cursors, with limit 1–100. Pages hydrate current physical fields, not historical values. Upsert live rows by appointmentId/version and remove minimal tombstones. Joined customer/catalogue labels are separate data; permission to sync appointments does not grant them.

    Read appointment membership or changes
  3. Continue through changes

    After membership completes, retain its nextCursor for deltas. Apply each page and its cursor atomically in your store, deduplicate eventId and retain the current version. current is authoritative even when an older signal says removed. current:null removes the scoped local row; it is not proof of global deletion. Advance empty filtered pages too.

  4. Acknowledge durable progress

    POST a complete issued cursor only after storing the page. Persist the ACK UUID before sending; retry the exact UUID/cursor after uncertainty. Partial membership and backward progress are refused. ACK is separate from applying the data locally.

    Acknowledge an applied appointment checkpoint
  5. Restart after authority or retention changes

    Credential rotation, changed calendar/disclosure grants, expired cursors or the 30-day retention floor require a new bootstrap. Exact ACK recovery can return the original receipt with bootstrapRequired:true; do not resume the obsolete projection. Replace only this scoped cache, preserving your site’s private fields.