Developers · API v1

Appointments integration API

Connect your management software to agenda.hokzen. Your system sends us the appointments; we send the WhatsApp reminders with a Yes/No confirmation and send every reply back to you by webhook, signed.

Base URL
https://agenda-api.hokzen.com
Prefix
/integrations/v1
Authentication
Authorization: Bearer hk_live_…

You need an agenda.hokzen account on an active paid plan. Keys and the webhook are set up in the app, under “Integrations”, by an owner or admin user.

The essentials

  1. Authentication: Authorization: Bearer hk_live_…. A missing, invalid, revoked or wrong-scope key → the same 401.
  2. What is not yours does not exist: 404, never 403.
  3. Strict bodies: a field that is not in the contract → 422 (validation_error). No guessing.
  4. 60 requests per minute per key; the 61st gets 429 + Retry-After: 60. If attempts with invalid keys keep coming from the same address, we answer 429 rate_limited for a while instead of 401; retry after the time given in the Retry-After header. A valid key never gets this 429. Batch loads have their own per-account limits too (see “Batch load”).
  5. Appointments are identified by your id (external_id), and PUT is idempotent: repeating it never duplicates.
  6. Your client's reply reaches you by webhook (appointment.confirmed, appointment.cancelled, …), signed.
  7. Without an active paid plan, PUT returns 402 payment_required; reading, cancelling and erasing keep working.
  8. Errors always have the shape {"error": {"code": "...", "message": "..."}}. Codes: unauthorized, not_found, validation_error, payment_required, org_deleting, rate_limited.

Keys

  • You create them yourself in the app, under “Integrations”, as an owner or admin user. You need a paid reminders plan (active, or with a payment pending); the free trial does not count. Creating a key without one → 402.
  • Scope appointments: they open /integrations/v1 only. WhatsApp API keys (scope messages) are different keys and get 401 here.
  • The plaintext key is shown once, when it is created; we store its hash. Keep it encrypted and on your server only.
  • There is a maximum number of active appointment keys per account; once you reach it, creating another → 409 api_key_limit. WhatsApp API keys do not count towards it. To rotate: create the new one, switch your system to it and revoke the old one (if you are at the maximum, first revoke one you do not use).
  • Revoking is immediate (the next request with that key gets 401) and does not require a paid plan.
  • When a key is created, the account owners get an email with the key's name, the date and who created it; never the key or its prefix.

If you stop paying

Keys are not deleted. PUT returns 402 payment_required; GET, DELETE and /me keep answering, and /me says so with status: "payment_required". Once you pay again, the same keys work again.

If the API side is paused

/me says so with paused: true and paused_reason: client (you paused it), admin (we cut it) or abuse_auto (automatic pause after unusual API usage). Appointments are still accepted, but with admin or abuse_auto no message for your appointments goes out until we reactivate it: write to us.

The automatic pause looks only at what the appointments you send us through the API have recently caused: many opt-outs or many messages that cannot be delivered. On a paid plan, before pausing we write to you so you can check what is happening; if it happens again after that notice, we pause the API side and your other calendars keep sending. Without a paid plan, the pause is immediate.

Endpoints

  • GET/integrations/v1/me

    Checks the key: org_id, status, settings, connection_id, paused, paused_reason. Creates the api connection if it does not exist yet.

  • PUT/integrations/v1/appointments/{external_id}

    Create or update the appointment. Response = the row after saving.

  • GET/integrations/v1/appointments/{external_id}

    The live row; if there is none, the latest one. Creates nothing. 404 if it was never pushed or was erased.

  • DELETE/integrations/v1/appointments/{external_id}

    Cancels (provider_cancelled) the live rows. 200 with the row if it was already cancelled; 404 if it never existed.

  • DELETE/integrations/v1/appointments/{external_id}?purge=true

    Cancels the appointment and erases the person's data: 200 with the counts, also when there was nothing (see “Erase an appointment's data”).

  • POST/integrations/v1/appointments:batch

    Up to 50 PUTs in one call, with a result per item (see “Batch load”).

Response of GET /integrations/v1/me (IntegrationMeOut):

json
{
  "org_id": "7d1a…",
  "status": "active",
  "connection_id": "c0a1…",
  "settings": {
    "message_display_name": null,
    "contact_phone": null,
    "confirmation_hours_before": 24,
    "paused": false,
    "retention_days": null
  },
  "paused": false,
  "paused_reason": null
}

status: active (your paid plan is active), payment_required (it is not) or deleting (the account is being deleted). paused and paused_reason: see “If the API side is paused”, above. settings.retention_days: your account's retention period, in days; null = none (see “Erase an appointment's data”).

The appointment id

external_id: up to 200 characters of [A-Za-z0-9._:-]. No ~ and no /. It is the appointment's id in your system.

Not recommended: ending the id in _YYYYMMDDTHHMMSSZ (e.g. rec_20261021T100000Z). The reminder engine strips that suffix when it groups appointment series, and two appointments that differ only in it would be mixed up.

Create or update an appointment

Body of PUT /integrations/v1/appointments/{external_id} (AppointmentIn):

start_atRFC 3339 with offset
Required. No offset → 422.
end_atRFC 3339 with offset
Optional; must be later than start_at, otherwise 422.
phonestring, 5–32
Required. E.164 (+34611222333) or national (611222333, completed with your account's country).
contact_namestring, ≤ 120
Optional; your client's name, used in the messages.
titlestring, ≤ 120
Optional; shown only on the Agenda screen.
source_created_atRFC 3339 with offset
Optional; when it was booked in your system. No effect today: it only anchors the “booking acknowledgement” step, which is off in the standard setup.

Response (PushedAppointmentOut):

json
{
  "id": "a9c3…",
  "external_id": "rec-1001",
  "status": "pending",
  "start_at": "2026-10-22T10:00:00+02:00",
  "cancelled_reason": null,
  "skipped_reason": null
}

Statuses

pending
Scheduled.
reminder_sent
Your client has been asked; no reply yet.
confirmed
Your client tapped “Yes”.
cancelled
Cancelled, with cancelled_reason: contact_reply (your client said “No”), provider_cancelled (your DELETE), rescheduled (the appointment moved) or manual (cancelled in the app).
unreachable
No valid phone number.
completed
Marked as completed in the app.
skipped
Only in the response to a PUT for a past appointment (skipped_reason: "past").

PUT rules

  • Same external_id, same start_at: updates the row (phone, name, title). No duplicate.
  • Same external_id, new start_at (the appointment moves): a new row in pending; the previous one becomes cancelled / rescheduled. If your client had already been asked, they will be asked about the new time.
  • start_at in the past: nothing is stored, future rows for that id are cancelled and the response is 200 {"status": "skipped", "skipped_reason": "past"}. Your system should not retry it.
  • Invalid phone, or the number we message your clients from: an unreachable row and an appointment.unreachable webhook, the first time only; repeating the PUT unchanged does not emit it again.
  • Appointment cancelled by your client (“No” to the message): another PUT with the same time does not revive it (the decision is your client's). To ask again: DELETE and then PUT with the time, or a new external_id.

Phone numbers

A national number is read with your account's country (ES → +34…). If you have clients in other countries, send E.164. A number that cannot be normalised leaves the appointment unreachable; it is not an HTTP error.

Batch load

For the initial load or a large sync: POST /integrations/v1/appointments:batch with up to 50 appointments. Each item is the PUT body plus external_id, and goes through the same code as the PUT: same rules, same phones, same webhooks. Each item is saved or fails on its own (one bad row does not sink the others), and sending the same batch again duplicates nothing.

Request
POST /integrations/v1/appointments:batch
{"items": [
  {"external_id": "rec-1001", "start_at": "2026-11-03T10:00:00+01:00", "phone": "600111222", "title": "Visit"},
  {"external_id": "rec-1002", "start_at": "2026-11-03T11:00:00+01:00", "end_at": "2026-11-03T10:30:00+01:00", "phone": "+34600333444"}
]}
Response 200 (even when items fail)
{"ok": 1, "failed": 1, "results": [
  {"index": 0, "external_id": "rec-1001", "ok": true,
   "appointment": {"id": "…", "external_id": "rec-1001", "status": "pending", "start_at": "…",
                   "cancelled_reason": null, "skipped_reason": null}},
  {"index": 1, "external_id": "rec-1002", "ok": false,
   "error": {"code": "validation_error", "message": "end_at: Value error, end_at must be after start_at"}}]}

results follows the order of items; appointment is exactly the PUT response. external_id is null when the item carries no valid one.

When the whole call fails

401 unauthorized
Bad key, as everywhere else in the API.
422 validation_error
No items, empty items or more than 50, an item that is not an object, or an unknown top-level field.
402 payment_required
No active paid plan.
409 org_deleting
Account being deleted.
429 rate_limited + Retry-After
More than 60 requests/min with the key · a batch of your account is already running (one at a time) or the server is busy with other batches · your account would go over the batch volume we accept per minute or per day. Batch limits are per account, whichever keys you use. In every case, retry after the time given in Retry-After.

When an item fails (`ok: false`)

validation_error
It does not match the PUT body + external_id. The message gives the field and the reason, never the value; an unknown field is unknown field.
duplicate_external_id
The same external_id appears more than once in the batch: every occurrence fails.
item_failed
It could not be saved (for instance, a simultaneous PUT of the same appointment). Retry it alone or in another batch.

New people: the daily cap on people messaged for the first time does not change with batches. An initial load with many new people goes out over several days; you can see the cap under “Integrations”. If you need more, write to us.

Erase an appointment's data

When a person asks for their data to be erased, or your policy requires it: DELETE /integrations/v1/appointments/{external_id}?purge=true cancels the appointment and erases that appointment's personal data on the spot.

Response 200
{
  "external_id": "rec-1001",
  "purged": { "appointments": 1, "messages": 3, "contacts": 0 }
}
appointments
Rows of that external_id now holding no personal data (rows that were moved or archived count too).
messages
Messages deleted: the ones we sent for that appointment and, if it was the person's last appointment in your account, their whole conversation.
contacts
Contact rows deleted. An opt-out is kept (without the name) and does not count.
  • Repeated, or for an id that never existed: 200 with zeros. It is the exception to “404 if it never existed”: a retry after a timeout is not an error. For the same reason, retry after a 500.
  • Never 402 or 409: erasing also works without a paid plan and while the account is being deleted. Without purge (or with purge=false) it is the usual DELETE.
  • Afterwards: GET and DELETE of that id → 404. A later PUT of the same id creates a new appointment. No webhook is sent for the erasure.
  • When: erase once the appointment needs no more messages (after the visit, and after the follow-up message if you have it on); before that, the pending steps do not go out. A message already on its way to WhatsApp at that instant is delivered. Do not send a PUT and the erasure of the same id at the same time.
  • If the person replies later to a message of that appointment, they get “Your appointment on ⟨date⟩ is no longer active.” and no other appointment is touched.
  • Erasing does not avoid the automatic abuse pause: the sends of erased appointments still count.
  • There is no erasure by phone number (the number would travel in the URL): erase per appointment. Erasing a person's last appointment erases them entirely, also when you erase several of their appointments at once.

What erasure does not reach

Erasure deletes the person's data in agenda.hokzen on the spot: their phone number, their name, the appointment title, your appointment id and the messages we sent them for that appointment; once they have no other appointment in your account, their whole conversation too. Their replies and our confirmations stay in their conversation while they have another appointment with you, and go with the last one. The appointment keeps only its day, time and status, with no personal data, so we can keep our sending number under control.

What remains, without a name: if they opted out, their number and the date, so we never message them again; for billing, a hashed summary per appointment, without the phone number in the clear, that cannot be reversed short of brute force; WhatsApp's technical record, deleted on its own after 30 days; our error queue, if a message of theirs failed to process, until we review it; your appointment id in our API technical logs and in the webhook delivery log (7 days; 30 if the delivery failed), never with their phone or name; and the backups, which rotate in 14 days. If the person writes again later, that new message is stored like any other and goes with your account's retention period, if it has one.

Retention period

settings.retention_days (in /me): if your account has a retention period, the days after which we erase people's data on our own; null = none. With a period, every hour we delete the messages older than it, erase the personal data of the appointments that ended longer ago than it (never sooner than 30 days) and, once a person has no other appointment in your account and no recent messages, their whole conversation. Today it cannot be changed through the API: if you need one, write to us.

Webhook

Register and verify your URL once, in the app, under “Integrations” (owner or admin, with a paid plan; without one → 402). Verification is a challenge: we send {"type":"verification","challenge":"…"} to your URL and your server must return 2xx with the challenge in the body.

  • The URL must be https and public; otherwise 422 webhook_url_invalid.
  • There is a maximum number of URLs per account, counting those of the WhatsApp API; once you reach it, registering another → 409 webhook_limit.
  • Each URL receives only the event families it is subscribed to. The ones created under “Integrations” start with appointments and org, and never receive WhatsApp API messages (messages).

Every delivery

X-Hokzen-Event
Event name.
X-Hokzen-Delivery
Delivery id.
X-Hokzen-Signature
sha256=<hex>: HMAC-SHA256 of the raw body with the whsec_… secret shown when you registered the URL (the same shape Meta uses).
  • Answer 2xx within 10 s and process in the background. We do not follow redirects.
  • Retries after a failure: 1 min, 5 min, 30 min, 2 h, 12 h and 24 h; after that, the delivery is dead.
  • Check the signature against the body exactly as received, before parsing it.

Events

appointment.reminder_sent
Your client has been asked.
appointment.confirmed
Your client tapped “Yes”.
appointment.cancelled
Your client tapped “No” (cancelled_reason: contact_reply) or the appointment was cancelled in the app (manual).
appointment.unreachable
Invalid or excluded phone (on the transition only).

What you do is not notified back to you: your DELETE (provider_cancelled) and moving an appointment with PUT (rescheduled) emit no webhook.

Body of an event — never a phone, a name or a title:

json
{
  "event": "appointment.confirmed",
  "org_id": "7d1a…",
  "external_ref": null,
  "external_id": "rec-1001",
  "start_at": "2026-10-22T08:00:00+00:00",
  "status": "confirmed",
  "occurred_at": "2026-10-21T09:12:33.120451+00:00"
}

cancelled_reason appears only in appointment.cancelled. external_ref is null on an account with its own key. One event per transition: “Yes” → “No” → “Yes” produces three.

Examples

bash
API=https://agenda-api.hokzen.com
KEY=hk_live_…   # your key, created under "Integrations"

# 1 · Check the key
curl -sS "$API/integrations/v1/me" \
  -H "Authorization: Bearer $KEY"

# 2 · Push (or move) an appointment: 10:00
#     Madrid time, national phone number
curl -sS -X PUT \
  "$API/integrations/v1/appointments/rec-1001" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"start_at":"2026-10-22T10:00:00+02:00",
       "end_at":"2026-10-22T10:30:00+02:00",
       "phone":"611222333","contact_name":"Marta"}'

# 3 · Read its status
curl -sS "$API/integrations/v1/appointments/rec-1001" \
  -H "Authorization: Bearer $KEY"

# 4 · Cancel it (200 also if it was already
#     cancelled; 404 if it never existed)
curl -sS -X DELETE \
  "$API/integrations/v1/appointments/rec-1001" \
  -H "Authorization: Bearer $KEY"

# 5 · Erase the person's data
#     (after the visit)
curl -sS -X DELETE \
  "$API/integrations/v1/appointments/rec-1001?purge=true" \
  -H "Authorization: Bearer $KEY"

Behaviours worth knowing

Bad, revoked, wrong-scope or missing key
401 unauthorized, always the same.
Another account's appointment
404 not_found; never 403.
More than 60 requests/min with one key
429 rate_limited, Retry-After: 60.
Many invalid keys in a row from the same address
The next failed attempts from that address get 429 rate_limited for a while (not 401); retry after the time given in Retry-After. A valid key from that address still gets in.
No active paid plan
PUT → 402 payment_required; GET, DELETE (with purge=true too) and /me answer.
API side paused (paused_reason admin or abuse_auto)
Appointments are accepted; nothing goes out until we reactivate it. With abuse_auto reminders are held and, on reactivation, those still in time go out (appointment more than an hour away); with admin they are lost. Your other calendars keep sending.
Daily cap on new people
Appointments pushed through the API can reach a limited number of new people per day per account (you can see it under “Integrations”); someone who already got a message from you before does not count. Anything over the limit is held until the next day (UTC) and goes out then if the appointment is still more than an hour away. If you need more, write to us.
Account being deleted
PUT → 409 org_deleting.
PUT of a past appointment
200 skipped / past; future rows for the same id are cancelled.
DELETE …?purge=true repeated, or for an id that never existed
200 with zeros; never 402 or 409.
Erased appointment
GET → 404; a PUT of the same id creates a new appointment.
Your client said “No” and you repeat the PUT with the same time
Not revived. DELETE + PUT, or a new id.
source_created_at
No effect today (booking acknowledgement off by default).
_YYYYMMDDTHHMMSSZ suffix in external_id
Not recommended (see Endpoints).
National phone number
Completed with your account's country.
Batch load
POST …/appointments:batch, up to 50 per call, a result per item; volume limits per account; one batch at a time.
Your integration has sent us no changes for 7 days
If you have upcoming appointments, we email you. Reminders keep going out with what we have: check that your software is still sending us the appointments.
Opening Agenda from your software
Link to the app; it asks to sign in when needed.
Revoked key
Dies on the spot; use another active key.
GET /integrations/v1/me
Creates the api connection if missing; GET …/appointments/{id} creates nothing.

Schemas in OpenAPI (/openapi.json): AppointmentIn, PushedAppointmentOut, IntegrationMeOut, SettingsOut, BatchIn, BatchOut, PurgedAppointmentOut.

Questions about the integration? Write to support@hokzen.com with the X-Hokzen-Delivery id or the time of the request — never with the key.