API and webhooks
On the Pro plan you can read and change your bookings from your own tools, and get a call on your server whenever someone books, cancels or reschedules.
API keys
- Create a key in Settings → API and webhooks (the owner or an admin only). The key is shown once: keep it like a password.
- Send it with every request to https://api.getmiagenda.com as Authorization: Bearer gma_… . The key acts as the person who made it, with their role in the account.
- Each key gets 120 requests a minute. Over that, the answer is 429 with a Retry-After header.
- Removing the key, or that person leaving the account, stops it at once.
What a key can do
Answers are JSON. An error is a problem (RFC 9457) with a stable code, such as booking.not_found. A key can’t reach settings or billing, or make other keys: that answers 403 auth.api_key_not_allowed.
GET /v1/me- Who the key is: the person and the account.
GET /v1/event-types- Your event types; GET /v1/event-types/{id} for one.
GET /v1/bookings?view=upcoming- Your bookings: upcoming, past or cancelled, in pages (cursor, limit up to 100).
GET /v1/bookings/{id}- One booking, with the invitee’s answers.
POST /v1/bookings/{id}/cancel- Cancels with {"reason": "…"}; the invitee is told.
POST /v1/bookings/{id}/accept- Accepts a request; /decline with {"note": "…"} declines it.
/v1/account/webhooks- Lists, creates, changes and removes webhooks (see below).
Webhooks
- Add a public https address and pick the events: booking.created (a booking was confirmed: booked, paid, or a request accepted), booking.cancelled and booking.rescheduled.
- We POST JSON: {"id", "type", "createdAt", "data": {"booking": …}}. The booking is as GET /v1/bookings/{id} returns it; for booking.rescheduled, data.previousBookingId is the booking it replaced.
- Answer with a 2xx within 10 seconds. Otherwise we retry for about two hours. If the last 10 deliveries fail, we pause the webhook and tell the owner.
- A delivery can arrive more than once or out of order: use the event id to drop repeats, and check the booking’s status.
Check the signature
Each delivery has a GetMiAgenda-Signature header: t=<unix seconds>,v1=<signature>. The signature is the hex HMAC-SHA256 of "t.body" with the webhook’s secret (whsec_…). Compute it over the body exactly as received, compare in constant time, and refuse ones older than 5 minutes.
import crypto from 'node:crypto';
// header: the GetMiAgenda-Signature value; body: the raw request body
function verify(header, body, secret) {
const { t, v1 } = Object.fromEntries(header.split(',').map((p) => p.split('=')));
if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
const expected = crypto.createHmac('sha256', secret).update(`${t}.${body}`).digest('hex');
return v1.length === expected.length && crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
}