Create an API key and call the API

A key belongs to one Project, is shown once when it is created, and does only what you allow

  1. On the Integrations page, click Create API key
  2. Name it after the system that will use it, e.g. pos-siam-branch
  3. 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)
  4. For Wi-Fi you can limit it to some locations, and you can set an expiry date
  5. Click Create API key and copy the key at once: it is shown only this time
Shell
curl -H "Authorization: Bearer thk_YOUR_KEY" https://api.thailandhosting.com/v1/key

GET /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.

ErrorMeaning
401 invalid_keyThe key is wrong, deleted or expired
403 insufficient_scopeThe key is not allowed to do this, e.g. a read-only key trying to change data
403 api_disabledThis API is not turned on under the Project's Integrations
402 payment_requiredThe month's free calls are used up and the Project's wallet is empty
429 rate_limitedToo 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.

Still stuck? Let our team help

Open a ticket from the Console. Tell us the site or service, what you did and the message on screen. Our reply comes back in the same ticket, so everything stays in one place.