Public API and API key (custom portal development)
The guest portal talks to Captivo through a small set of /api/v1 endpoints, authenticated by a tenant API key. This page states what those endpoints and the key are, exactly as the product behaves, for people who build or modify a portal page. It is not a management API.
What the API is, and what it is not
- It is the API behind guest sign-in: send an SMS or e-mail password, redeem a voucher, sign in a hotel guest, run the sponsor request, and the shared username-and-password sign-in. The portal pages Captivo serves and the files you download for a firewall both call it.
- It is not a general management API. There is no endpoint to create vouchers, list guests, read sessions or change settings. The one read endpoint for stored records is the PMS reservation list.
- It is separate from outbound webhooks, which Captivo sends to you (see the webhooks page), and from the inbound PMS webhook, which is signed with its own secret rather than this key (see the hotel PMS page).
The API key
The key lives under Settings → RADIUS, tab API Settings, section API Key (Admins only). Without a key the page offers Create API Key. With one, it shows the key masked, with Show and copy buttons, the creation date, and Regenerate and Revoke. A key older than six months carries a grey "unchanged for N months" note; it is information only.
- Format:
cap_live_followed by 32 random characters. One key per tenant, stored as plain text. Every call must send it in theX-API-Keyheader. - Regenerate (after a confirmation) makes the old key invalid at once. Every portal file you downloaded carries the old key, so guests cannot sign in on those firewalls until you download the files again and upload them. A portal page that Captivo itself serves (the Portal URL) is built with the current key whenever it is opened, so it keeps working.
- Revoke removes the key. Every endpoint then answers 401, and the portal cannot sign anyone in, hosted or downloaded, until you create a new key (and, for downloaded files, upload them again).
- Creating, regenerating and revoking are recorded as Portal API Key Rotated and Portal API Key Revoked in Settings → Logs, Audit tab (see audit logs).
Authentication, origins and errors
All endpoints except the reservation list are POST with a JSON body (Content-Type: application/json); the reservation list is GET. Every call needs X-API-Key. The tenant is always the one the key belongs to. An answer is {"success": true, "data": ...} or {"success": false, "error": "..."}. Error text follows the tenant language for most endpoints, but some messages are Turkish only.
| Status | When |
|---|---|
401 | No X-API-Key header ("API key gerekli (X-API-Key header)") or an unknown key ("Geçersiz API key"). |
403 | The tenant is closed to new sign-ins ("Tenant aktif değil"), the RADIUS service is switched off ("RADIUS servisi aktif değil"), the Origin is not allowed, a login method that was switched off is called ("This sign-in method is turned off", METHOD_DISABLED), or, for the PMS reservation list, there is no panel session. |
400 | A missing or invalid field, a wrong code, a voucher with no uses left, room details that do not match. |
429 | A rate limit (table above). SMS and e-mail answers carry X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset and Retry-After headers. |
500 / 502 / 503 | A server error; the e-mail could not be sent (502); the SMS service is not configured, or the on-premise licence blocks guest sign-in (503). |
Allowed Origins (CORS)
The list under Allowed Origins (CORS) on the same tab decides which web pages may call the API from a browser. An empty list and * mean the same: everything is allowed. Otherwise the request's Origin header must equal an entry exactly (protocol included: hotspot login pages are usually http, so http://192.168.1.1, not https). A call that sends no Origin header at all, such as curl, is refused with 403 when the list is not empty and has no *; add -H "Origin: ..." in tests. A wildcard entry such as https://*.example.com matches only real subdomains (and the apex), with the same scheme and port; an entry written without a scheme means https only. An address typed without a protocol gets http:// for local addresses and https:// for domain names, and an https:// entry for a local IP is marked as likely wrong.
The check compares a header the caller writes, so it keeps other web pages from using visitors' browsers to call your API; it does not authenticate a script, which can send any Origin. Preflight (OPTIONS) requests are answered with 204. The downloaded portal also sends X-Captivo-Template, its build version, which the panel uses to warn about out-of-date files.
Endpoint reference
| Endpoint | You send | data holds | Limits |
|---|---|---|---|
POST /api/v1/sms/send | phone (required); firstName, lastName, email, mac, ip, deviceType, userAgent, portalLang (tr or en: the SMS is written in it). | username (the phone number), expiresIn and sessionDuration (both seconds). The password is not in the answer; it is sent by SMS. | 3 per minute per phone (changes with the SMS Gateway setting); 5 per 10 minutes per MAC or IP; a daily tenant budget (500 by default); 503 when no SMS gateway is configured. |
POST /api/v1/email/send | email (required); firstName, lastName, phone, mac, ip, deviceType, userAgent, portalLang. | username, email, expiresIn, sessionDuration (seconds). The password goes by e-mail. | 5 per minute per e-mail address; 2000 per 24 hours per tenant. |
POST /api/v1/voucher/verify | code (required; upper-cased, spaces removed); mac, ip, deviceType, userAgent. | username, password, sessionDuration and expiresIn (seconds), validUntil, batchName, remainingUses (null = unlimited). Every successful call spends one use of the voucher. | 10 attempts per 15 minutes per device (MAC, else IP); a success resets the count. |
POST /api/v1/pms/auth | roomNumber (required) and lastName or identityNumber (by method); mac, ip, deviceType, userAgent. | guestName, username, password, sessionDuration (MINUTES), checkOutAt, redirectUrl. | 8 per 15 minutes per room and IP; 30 per 15 minutes per IP. Details: the hotel PMS page. |
GET /api/v1/pms/reservations | Query: status, roomNumber, search, page, limit (default 20, at most 100). | reservations (room, guest name, e-mail, phone, check-in and check-out, status, device count) and pagination. The key alone is not enough: the request must also come from a signed-in panel user of the same tenant who may view PMS, otherwise it answers 403. | None. |
POST /api/v1/sponsor/list | No body needed. | sponsors: id, name and department of active sponsors (at most 500). E-mail addresses are not returned. | None. |
POST /api/v1/sponsor/request | sponsorId and phone (required); firstName, lastName, email, mac, ip. | requestId (only to the caller that created the request; when an existing open request is reused, reused is true and no requestId is returned), sponsorName, reused, emailSent. | 3 per 15 minutes per device and per phone. |
POST /api/v1/sponsor/status | requestId (required; the one sponsor/request returned). | status (PENDING, APPROVED, REJECTED, EXPIRED), credentials (username, password, validUntil, sessionDuration when approved and still valid; else null) and message. | 12 per minute per requestId. |
POST /api/v1/directory/login | username and password (required); mac, ip, zone, redirurl, deviceType, userAgent. The tenant comes from the key; a tenantSlug in the body is ignored. | success and data: username, sessionDuration, redirectUrl. | The same handler as the portal's username-and-password sign-in: 5 attempts per 15 minutes per user and device, 10 per 15 minutes per user. |
- Units differ: sessionDuration is in seconds for SMS, e-mail and voucher, but in minutes for pms/auth.
- The username returned by
voucher/verifyandpms/authcarries your tenant prefix (for exampleacme-hotels_ACME-K7Q2M9XA). A downloaded portal then submits the username and password to the firewall's own sign-in address; the API itself never opens the network. - The hotel PMS webhook,
POST /api/v1/pms/webhook, belongs to the PMS, not to guests: it uses the HMAC signature instead of this key. See hotel PMS integration.
Examples
Ask for a Wi-Fi password by SMS. The Origin header stands in for the portal's address, so use an address that is in your Allowed Origins list or leave the list empty:
curl -s -X POST "https://portal.acme.example/api/v1/sms/send" \
-H "Content-Type: application/json" \
-H "X-API-Key: cap_live_<your key>" \
-H "Origin: http://192.168.1.1" \
-d '{"phone":"+15550100","firstName":"Sam","lastName":"Carter","mac":"AA:BB:CC:DD:EE:FF","portalLang":"en"}'{
"success": true,
"data": {
"username": "+15550100",
"expiresIn": 3600,
"sessionDuration": 28800
}
}Redeem a voucher (this spends one use):
curl -s -X POST "https://portal.acme.example/api/v1/voucher/verify" \
-H "Content-Type: application/json" \
-H "X-API-Key: cap_live_<your key>" \
-H "Origin: http://192.168.1.1" \
-d '{"code":"ACME-K7Q2M9XA","mac":"AA:BB:CC:DD:EE:FF"}'{
"success": true,
"data": {
"username": "acme-hotels_ACME-K7Q2M9XA",
"password": "<the voucher's own password>",
"sessionDuration": 7200,
"expiresIn": 7200,
"validUntil": "2026-11-26T16:41:07.000Z",
"batchName": "Lobby",
"remainingUses": 0
}
}A refused call, here for an origin that is not on the list:
{
"success": false,
"error": "Origin not allowed"
}Handling the key and the endpoints safely
- Do not rely on the key to keep anything private. What it unlocks is whatever the endpoints above do for a caller who has it: send passwords to numbers and addresses (within the limits), redeem codes and run sponsor requests. The reservation list no longer opens with the key alone; it also needs a signed-in panel session.
- Set Allowed Origins to the real address of your portal pages. It does not authenticate anyone, but it stops other websites from calling the API from your guests' browsers.
- Keep downloaded portal files on the firewall only, not in tickets, chat or public repositories, and re-download them after changing login methods or the key.
- A login-method switch under Settings → Portal → Login Methods hides the option on the page and the API refuses the method too: the endpoint answers 403 METHOD_DISABLED. See guest sign-in methods.
- If you build your own portal page, copy the markup and the calls from a downloaded file rather than starting from scratch, and keep the design in portal design so the two do not drift apart.
Versioning and changes
The version is in the path (/api/v1). Captivo publishes no deprecation schedule and does not negotiate versions. Paths that downloaded portal files call are kept as they are, because renaming one would force every customer to re-download and re-upload their files; the sign-in endpoint is still called directory/login although it now serves every username-and-password sign-in. Treat unknown fields in an answer as additions and ignore them, do not depend on the wording of error text, and read the units from the table above.
Common problems
- Every call returns 401 after you regenerated the key: the downloaded file still holds the old one. Download the portal files again and upload them to the firewall.
- A browser call fails with no useful message although the key is right: the page's address is not in Allowed Origins (check http against https), or a header the preflight does not allow was added. Only Content-Type, X-API-Key and X-Captivo-Template are allowed.
- curl returns 403 "Origin not allowed" while the same call works from the portal: add an Origin header that is on the list.
- A voucher test burns a use. Use a voucher you created for testing, with enough uses. See RADIUS settings for how the credential is then accepted by the network.
- Deliveries to your own system, such as a CRM, are webhooks, not this API: see webhooks.