The Kusties API connects a specialist's or an organisation's own website or system to their Kusties account. Version 1 covers booking: the account's specialists, locations and services, the free times, and the bookings the website makes, lists, reads, cancels and reschedules. Kusties applies the same rules, limits and e-mails as on its own booking page. The API is for servers only: every request carries an API key, and a browser never calls it.
This guide covers what every part of the API shares: addresses, keys and scopes, authentication, errors, conventions, limits and versioning. The booking guide walks through the booking flows, with examples in curl, Node and PHP.
You need:
- an API key from the account holder (the specialist, or a manager of the organisation), made in Kusties under «API un integrācijas»;
- a server that keeps the key secret and calls Kusties over HTTPS;
- this guide and the booking guide, online at https://kusties.com/developers, and the API reference with every operation and field, at https://kusties.com/developers/reference. The OpenAPI (Swagger 2.0) file behind it, for code generators and API tools, is at https://kusties.com/developers/openapi.yaml.
API version 1. This guide: 21 November 2026. Questions: info@kusties.com (quote the X-Request-ID of the request in question).
Kopsavilkums latviski
Kusties API savieno speciālista vai organizācijas mājaslapu vai sistēmu ar Kusties kontu. Pirmā versija ir par pierakstu: mājaslapas serveris var rādīt speciālistus, vietas, pakalpojumus un brīvos laikus, pierakstīt klientu un vēlāk skatīt, atcelt vai pārcelt caur API veiktos pierakstus. Kusties piemēro tos pašus noteikumus, ierobežojumus un e-pastus kā savā pieraksta lapā. Pieraksta plūsmas ar piemēriem ir aprakstītas pieraksta ceļvedī.
- Adreses. Darba vide:
https://api.kusties.app/v1(atslēgaskst_live_…). Testa vide:https://api-sandbox.kusties.app/v1(atslēgaskst_test_…); tajā netiek sūtīti atgādinājumi, un e-pasti pacientiem tiek sūtīti tikai uz testētāju adresēm. - Atslēga. To izveido speciālists vai organizācijas pārvaldnieks Kusties sadaļā «API un integrācijas». Atslēgai izvēlas atļaujas un pēc vajadzības derīguma termiņu, atļautās IP adreses un (organizācijas atslēgai) speciālistus. Atslēga ir redzama tikai vienreiz. Glabājiet to tikai serverī (piemēram, vides mainīgajā
KUSTIES_API_KEY), nekad kodā, ko redz pārlūks: pieprasījumu ar galveniOriginKusties atraida. Sūtiet to katra pieprasījuma galvenēAuthorization: Bearer <atslēga>. Ja ir aizdomas par noplūdi, nekavējoties atsauciet atslēgu. - Laiks. Visi laiki ir UTC (
…Z). Laukstime_zone(pagaidām vienmērEurope/Riga) norāda laika joslu, kurā ir datumi un dienas daļas. - Saraksti. Saraksts ir
{data, next_cursor}; nākamo lapu saņem arcursor=<next_cursor>. - Ierobežojumi. Katrai atslēgai: ne vairāk kā 120 pieprasījumu minūtē, 1200 lasīšanas pieprasījumu stundā, 60 pieraksta pieprasījumu stundā un 60 atcelšanas vai pārcelšanas pieprasījumu stundā. Kontam: ne vairāk kā 100 pierakstu caur API 24 stundās. Ja atbildē 429 ir galvene
Retry-After, nogaidiet tajā norādīto laiku. - Versijas. Versijā 1 izmaiņas API tikai papildina: laukus un vērtības, ko nepazīstat, ignorējiet. Nesaderīgas izmaiņas būs versijā
/v2, un versija 1 pēc tās izziņošanas darbosies vēl vismaz 12 mēnešus.
1. What the API offers
| Method and path | Scope | What it does |
|---|---|---|
GET /me | any | the key (its scopes, expiry, IP restriction and specialists) and the account it acts for (a specialist or an organisation, its time zone, the privacy notice's address) |
GET /specialists | specialists:read | the specialists the key reaches: for a specialist's key, the specialist; for an organisation's key, its specialists who take online bookings from anyone |
GET /locations | locations:read | where visits take place: a specialist's main address and practice places, an organisation's branches |
GET /services | services:read | what can be booked: a specialist's visit types, an organisation's services |
GET /availability | availability:read | the free start times of a service over a range of days |
POST /bookings | bookings:create | books a free start for the person who filled in your form |
GET /bookings | bookings:read | the bookings the account made through the API, a page at a time |
GET /bookings/{id} | bookings:read | one of them |
POST /bookings/{id}/cancel | bookings:update | cancels it |
GET /bookings/{id}/availability | bookings:update | the times it can be rescheduled to |
POST /bookings/{id}/reschedule | bookings:update | reschedules it |
A specialist's key and an organisation's key use the same routes: the key decides the account, and no path names it. A specialist's key books that specialist; an organisation's key books its team, a chosen specialist or any free one. The catalog, the free times and new bookings follow the account's online booking settings (booking guide → Before you start).
New areas will come to version 1 under paths and scopes of their own, without changing these (§7).
2. Addresses and the sandbox
| Environment | Base URL | Keys |
|---|---|---|
| Live | https://api.kusties.app/v1 | kst_live_… |
| Sandbox | https://api-sandbox.kusties.app/v1 | kst_test_… |
Each environment accepts only its own keys, and refuses the other's with 401 invalid_token, whose message names the prefix it expects. GET /me answers "sandbox": true on the sandbox. On these hosts only /v1 is the API: any other address redirects to this documentation.
The sandbox is Kusties' test environment: it runs the same code as live, gets new releases first, and really sends e-mail. For your tests Kusties sets up a sandbox specialist and a sandbox organisation, both taking online bookings from anyone and allowing online cancelling, and sends you kst_test_ keys for them through a one-time secret link.
- Bookings made with sandbox keys schedule no reminders (no SMS).
- Their patient e-mails go only to the addresses on the sandbox's list, whoever changes the booking (the sandbox specialist in Kusties too): tell Kusties your address (or your company's
@domain) to see them. E-mails to any other address are not sent. - Use only your own name, e-mail address and phone number there; never real patients' data.
3. Keys and scopes
Who makes them. The specialist, in Kusties on the profile page under «API un integrācijas»; for an organisation, its managers, on the organisation's page under «API un integrācijas» (a receptionist cannot).
Making a key («Izveidot atslēgu»):
Name (1–60 characters), so the keys can be told apart, e.g. the website's name.
What the key may do («Ko atslēga drīkst darīt»): four groups of scopes. A new key has «Skatīt pakalpojumus un brīvos laikus» and «Pierakstīt» ticked: the four reads and
bookings:create, but notbookings:read.In Kusties Scopes Opens «Skatīt pakalpojumus un brīvos laikus» specialists:read,locations:read,services:read,availability:readGET /specialists,/locations,/services,/availability«Skatīt pierakstus» bookings:readGET /bookings,/bookings/{id}«Pierakstīt» bookings:createPOST /bookings«Atcelt un pārcelt pierakstus» bookings:updatePOST /bookings/{id}/cancel,/bookings/{id}/reschedule;GET /bookings/{id}/availabilityGET /meworks with any key and lists its scopes. A website that only shows free times and books needs the default; one that later shows a booking's status or lists bookings also needs «Skatīt pierakstus», and one that cancels or reschedules needs «Atcelt un pārcelt pierakstus». The last two reach only the bookings made through the API. Give each key only what the website uses: a call without its scope is refused with 403api_key_scope_missing, andmetadata.scopenames the scope it needs.Valid until («Derīga līdz», optional): the key works until the end of the chosen day in Riga time (
Europe/Riga) and then stops (401invalid_token, as for an unknown key). Without a date, it works until it is revoked. Kusties e-mails the specialist, or for an organisation's key its owner and the manager who made the key (while they still manage the organisation), about a week before that day (for a key made at least a week before it) and on the day (if that e-mail goes out only after the key has expired, it says the key has stopped working): the key's name, its hint and the date, never the key. To keep the website working, make a new key, deploy it and revoke the old one before then.Specialists (an organisation's key, optional): «Visi speciālisti» (the default, also those who join the team later) or «Tikai izvēlētie speciālisti» (up to 50). A key limited to some specialists reaches only them:
GET /specialists,GET /servicesand the free times show only them, a booking with any free specialist picks only among them, a request that names another specialist is refused with 403api_key_specialist_not_allowed(metadata.specialist_id), and the other specialists' bookings answer 404 and are left out of the list. A chosen specialist who leaves the organisation is no longer reached.Allowed IP addresses (optional): up to 10 public IPv4 or IPv6 addresses or networks (CIDR), one per line; a network may be no wider than /16 (IPv4) or /48 (IPv6); private and local addresses are refused. With a list, the key works only from those addresses; a request from anywhere else, or one whose address Kusties cannot tell, is refused (403
api_key_ip_not_allowed). Use it only for a server with a fixed outgoing address, not for serverless functions or hosting whose outgoing address changes.
Making a key needs a sign-in to Kusties within the last 10 minutes (Kusties asks to sign in again otherwise). An account may have at most 10 keys that are not revoked (an expired key counts until it is revoked), and one person may make at most 20 keys in 24 hours (for their own account and the organisations they manage, together). Every new key sends the account a security e-mail (the key's name and hint, who made it and when; never the key).
The key is kst_live_ and 43 more characters (52 in all; kst_test_… on the sandbox). Kusties shows it once, when it is made; it keeps only a fingerprint of the key and its hint (the prefix and the last 4 characters), and cannot show the key again. «API un integrācijas» later shows the hint (kst_live_…Wx3k), the scopes, the expiry (its day in Riga time), the specialists, who made the key and when, and when it was last used and from which IP address (updated at most once a minute).
Keep it safe:
- Put it in a server environment variable (
KUSTIES_API_KEY) or your host's secret store, and read it from there. - Never put it in code the browser loads, in the repository, in a URL, in logs, in analytics or error trackers, or in a support ticket. Its fixed prefix
kst_lets secret scanners find a leaked key. - Send it only in the
Authorizationheader, only over HTTPS.
Rotate or change a key. A key cannot be edited. To change its scopes, expiry, specialists or addresses, or to rotate it: make a new key, deploy it, check it with GET /me, then revoke the old one. The bookings made with the old key stay readable, cancellable and reschedulable with any other key of the same account that has the scopes.
Revoke a key in «API un integrācijas» («Atsaukt»): it stops at its next request (401 invalid_token). Revoke at once when the key may have leaked, when a developer or agency who had it leaves, or when the website moves to another server. A password change in Kusties does not revoke keys (so a routine password change never breaks the website): revoke a key yourself when in doubt.
What else stops a key: its expiry; the specialist's Kusties account being blocked, closed or no longer a specialist's account (401 invalid_token); an organisation that is not approved (also while Kusties reviews it again after a change of its name or details) or is suspended: its catalog, free times and new bookings answer 404, while GET /me and the reading, listing, cancelling and rescheduling of the bookings made with its keys keep working; Kusties switching the API off (404 on every route).
4. Authentication and errors
- The key goes in
Authorization: Bearer <key>on every request (the wordBearerin any case). No header: 401authentication_required. A header in another form, or a key that does not work (malformed, unknown, revoked, expired, or the other environment's): 401invalid_token. Every 401 carriesWWW-Authenticate: Bearer realm="kusties-api". A sign-in token of the Kusties app is not a key and is refused the same way. - Browsers are refused. A request that carries an
Originheader, which browsers send, is refused with 403api_browser_not_allowedbefore the key is read (§8). - The order of the checks: a route Kusties has switched off answers 404
not_found; then the limit per calling address, the browser check, the key, the key's limit per minute, the route's scope and the route's own limit. A refused request never counts against a route's limit. - Errors answer one JSON shape. Act on
code;messageis English text for developers, not for patients.fields[]names each refused field of avalidation_failedwith a code of its own (§6);metadatacarries what a code says (scope,specialist_id,limit,retry_after);request_idis the request'sX-Request-ID;timestampis in UTC. A booking with a mistyped phone number, for example:
{
"success": false,
"error": "validation",
"message": "client.phone must be a Latvian number or start with + and the country code",
"fields": [
{
"field": "client.phone",
"code": "phone",
"message": "client.phone must be a Latvian number or start with + and the country code"
}
],
"code": "validation_failed",
"timestamp": "2026-11-21T21:13:24.64212Z",
"request_id": "87dacb0a-8e1c-474e-80df-8ecc536abe4b",
"path": "/v1/bookings",
"method": "POST"
}
5. Conventions
- JSON in UTF-8. Send
Content-Type: application/jsonwith a request body. A body over 1 MB is refused (413request_too_large). - Times are RFC 3339 in UTC, ending in
Z:2026-11-24T07:00:00Z. A time you send may carry any offset (2026-11-24T09:00:00+02:00is the same moment); send a start back exactly as the API gave it. Times count in whole minutes. - Time zones, days and parts of the day. The account, specialists, locations, free times and bookings carry
time_zone, an IANA time zone, alwaysEurope/Rigatoday. Days (from,to,next_available.date) areYYYY-MM-DDin that zone, and so are the parts of the day (part:morningbefore 12:00,day12:00–17:00,eveningfrom 17:00). Show times to patients intime_zone, e.g. withIntl.DateTimeFormatand itstimeZoneoption, or PHP'sDateTimeImmutable::setTimezone(). - A time in a query string (
start_from,start_to): write it in UTC withZ(2026-11-24T00:00:00Z), or encode the offset's+as%2B(2026-11-24T00:00:00%2B02:00). An unencoded+arrives as a space; Kusties reads a space right before the offset as the+it was. A time that does not parse is refused (400validation_failed,invalid). - Ids are UUIDs. A specialist is named by their id (
specialist_id), a location by its id (location_id; a specialist's main address has the specialist's own id), a service by its id (service_id: a visit type's for a specialist, a service's for an organisation). - Lists answer
{"data": […], "next_cursor": …}. Whilenext_cursoris notnull, ask for the next page withcursor=<next_cursor>, passed back as it is, and the other parameters unchanged.GET /bookingstakeslimit(1–100, default 20); the catalog lists (/specialists,/locations,/services) come in one page today, but readnext_cursorthere too. A cursor that is not one Kusties gave is refused (400, fieldcursor, codeinvalid). A single object is answered as it is, withoutdata. - Prices are euro cents (
price_cents: 4500is €45.00). - Optional fields are left out when they have no value; lists are always present, possibly empty. Ignore fields and values you do not know (§7).
- Retries of a booking: send an
Idempotency-Keyheader with everyPOST /bookings, a new one for every booking attempt; a retry with the same key and the same request is answered with the first booking, and nothing is booked twice (booking guide → Retries). X-Request-ID: every answer carries one. Send your own (up to 64 letters, digits,-,_or.) and Kusties uses it; otherwise it makes one. Log it with your own request and quote it when you contact Kusties.- Caching. Kusties never lets its answers be cached (
Cache-Control: no-store). Cache the reads yourself, the catalog and each range of free times, for up to 60 seconds, never longer: a cached free time may already be taken. After a 409booking_slot_taken, drop the cached free times and read them again. Retry-After(seconds) comes with every 429 that can be retried (rate_limited,api_daily_limit_reached);booking_limit_reachedhas none.
6. Limits and error codes
Limits. A 429 with Retry-After can be retried after that many seconds; tell the patient to try later or to call the practice rather than wait in the request.
| Limit | How much | What counts | Answer |
|---|---|---|---|
| Per key: all requests | 120 a minute | every request with the key | 429 rate_limited |
| Per key: reads | 1,200 an hour | every GET | 429 rate_limited |
| Per key: booking requests | 60 an hour | every POST /bookings, refused ones too | 429 rate_limited |
| Per key: cancels and reschedules | 60 an hour | every POST …/cancel and …/reschedule | 429 rate_limited |
| Per calling address | 6,000 an hour | every request to the API, all keys together (IPv6: per /64), before the key is checked | 429 rate_limited |
| Per account | 100 bookings in 24 hours | bookings made through the API with all the account's keys; refused requests and replays do not count | 429 api_daily_limit_reached (metadata.limit, metadata.retry_after) |
| The booking page's limits | 3 open future bookings per e-mail address or phone number with one specialist; 30 online bookings per specialist per day | shared with Kusties' own booking page, its booking widget and organisation pages | 429 booking_limit_reached (no Retry-After) |
| The specialist's settings | the booking window (max_days_ahead), the earliest notice, the step between start times, a daily cap of online bookings | the free times leave those starts out | a booking of one: 409 booking_slot_taken |
| Making keys (in «API un integrācijas», not through the API) | 20 new keys in 24 hours per person | every key one person makes, for their own account and the organisations they manage together | Kusties makes no further key until then |
Error codes.
| Status | code | When | What your website does |
|---|---|---|---|
| 400 | validation_failed | a field or query parameter is wrong (fields[], below); privacy_notice_shown not true; a service that cannot be booked online (service_id, oneof) | correct the request; show the patient the field (e.g. the phone) |
| 401 | authentication_required | no Authorization header | fix your configuration |
| 401 | invalid_token | the key is malformed, unknown, revoked, expired, the other environment's, or a specialist's key whose account is blocked, closed or no longer a specialist's | stop and alert your administrator; do not retry |
| 403 | api_browser_not_allowed | the request carried an Origin header (a browser, or a proxy that forwarded it) | call from your server; do not forward Origin (§8) |
| 403 | api_key_ip_not_allowed | the request did not come from the key's allowed addresses (or Kusties could not tell its address) | check your server's outgoing address and the key's list |
| 403 | api_key_scope_missing | the key lacks the scope; metadata.scope names it | a new key with that scope |
| 403 | api_key_specialist_not_allowed | the request names a specialist the key does not reach: another specialist than a specialist's key's own, or one an organisation's key is not limited to; metadata.specialist_id | leave that specialist out, or use a key that reaches them |
| 404 | booking_unavailable | the specialist does not take online bookings from anyone now; the service is not offered online; the organisation is not approved, or is suspended (its free times and bookings); an organisation's key while Kusties' organisations are off | show "Online booking is not available; please contact the practice" |
| 404 | organization_unavailable | an organisation's GET /specialists, /locations or /services while it is not approved, or is suspended | as above |
| 404 | booking_not_found | not a booking the account made through the API, or one the key does not reach (also a malformed id; for an organisation, its specialist has left) | stop showing it |
| 404 | not_found | Kusties has switched the API (or rescheduling) off | treat as unavailable |
| 409 | booking_slot_taken | the time is no longer free, no specialist (or not the chosen one) is free then, the chosen specialist does not offer the service, or the start is no longer at location_id | read the free times again and let the patient choose |
| 409 | idempotency_key_reused | the Idempotency-Key was used before with another request | a bug: one key per booking attempt |
| 409 | booking_cancel_closed | past the cancelling deadline, cancelling online is off, or the visit is over | tell the patient to contact the specialist |
| 409 | booking_move_closed | past the deadline, rescheduled 3 times, rescheduling online is off, or the booking is cancelled, declined or past | as above |
| 413 | request_too_large | the body is over 1 MB | a bug |
| 429 | rate_limited, api_daily_limit_reached, booking_limit_reached | the limits above | wait for Retry-After where given; tell the patient |
| 500, 502, 503, 504 | none | a fault at Kusties or on the way | retry a booking with the same Idempotency-Key, a few times at most, with a pause |
Field codes. A 400 validation_failed names each field in fields[] with its own code: required, email, max, oneof (not one of the values allowed, or a service that cannot be booked), phone, uuid, date (not YYYY-MM-DD), range (limit outside 1–100; to before from, or more than 31 days in all), invalid (a start_from, start_to or cursor that does not parse), characters, or type (a JSON value of the wrong type, such as "privacy_notice_shown": "true"). The patient's fields are named as the request nests them: client.first_name, client.phone. A body that cannot be read is reported on the field body: json (not valid JSON), required (no body) or invalid (a value that does not parse, such as a start_time without its offset, or a service_id that is not a UUID; the answer's message says which). Ids and times sent back exactly as the API gave them never fail this way.
7. Versioning
- The version is in the path (
/v1). Within version 1, changes only add: new fields in answers, new optional request fields, new values in a list of values (a newstatus,formator scope), new error codes, and new routes and areas. Your code must ignore what it does not know, treat an unknownstatussensibly (for example as "please check with the practice"), and not depend on the order of fields. - A change that would break a working integration (a removed or renamed field, or a changed meaning) comes as a new version under a new path (
/v2), and version 1 keeps working for at least 12 months after the new one is announced. - The API reference and its OpenAPI file always describe version 1 as it is; they are updated when something is added.
8. Your security duties
Your website or system collects patients' data before Kusties does, and acts for the specialist (or the organisation), who answers for it: agree the processing of patients' data with the account holder (GDPR Article 28).
- Call from your server, never from a browser. The key stays on your server. Kusties refuses every request that carries an
Originheader (403api_browser_not_allowed), so a key put into a web page's code fails at its first use; a server that passes the browser's requests on must not forwardOrigin(nor cookies). - TLS only. Call
https://only, and do not follow redirects with the key (the booking guide's examples refuse both). A key that has crossed the network once over plainhttp://has to be revoked. - No patient data in logs. Never log names, contacts, comments or request bodies, in your logs, analytics or error trackers. Log the booking's
id, the errorcodeand theX-Request-IDinstead. - Kusties' privacy notice before a booking. Your form shows Kusties' short notice with a link to
privacy_notice_url(fromGET /me) before it sends a booking, and says so withprivacy_notice_shown: true(booking guide → Your website's duties). - Only bookings people make themselves. Send only the bookings people make through your website or app: no imports, no bookings for someone who did not ask, no test bookings on live. Staff who book on someone's behalf do so in Kusties itself.
- Your own bot check and limits. Kusties does not see your visitors and does not run its bot check on this path; it limits each key and account (§6). Protect your form yourself (for example Cloudflare Turnstile, hCaptcha or reCAPTCHA) and limit bookings per visitor, or one abusive visitor can use up your website's budget for everyone.
- Look after the key (§3): only the scopes the website uses, an IP list for a server with a fixed address, an expiry for a temporary integration; revoke it at once on any suspicion and when people who had it leave.