- On the Integrations page, click Create API key
- Name it after the system that will use it, e.g.
pos-siam-branch - Pick its permissions: read or read and change for each API (only the Project's Owner or an Admin can create keys that change data)
- For Wi-Fi you can limit it to some locations, and you can set an expiry date
- Click Create API key and copy the key at once: it is shown only this time
curl -H "Authorization: Bearer thk_YOUR_KEY" https://api.thailandhosting.com/v1/keyGET /v1/key tells you the key's Project and permissions. It is not billed, so use it to check your setup.
Never put an API key in a web page or an app your customers download. Call the API from your own server only. If a key leaks, delete it and create a new one.
| Error | Meaning |
|---|---|
401 invalid_key | The key is wrong, deleted or expired |
403 insufficient_scope | The key is not allowed to do this, e.g. a read-only key trying to change data |
403 api_disabled | This API is not turned on under the Project's Integrations |
402 payment_required | The month's free calls are used up and the Project's wallet is empty |
429 rate_limited | Too many calls: wait the seconds in the Retry-After header and try again |
Every error is a Problem Details JSON (RFC 9457) with a code your program can check and a detail that explains it.
If something goes wrong
The Create API key button is greyed out
Turn on at least one API under Integrations first.
I cannot create a key that changes data
Only the Project's Owner or an Admin can. Ask someone with that role to create it.
A key that used to work now gets 401
It expired, was deleted, or the person who made it left the Project (their keys expire at once). Create a new key.