Skip to main content

Move from an API key to a public key

A page that starts calls with new HamsaVoiceAgent(API_KEY) keeps working: its calls run what your agent’s prod serves, as before. Move when you can. Anyone who opens your page can read the key in it, and an older API key can do much more than start calls. A public key can only start calls, in one environment.
1

Create a public key

On the API keys page, create a key under Website or app, for prod. Limit it to your agents and to your site’s domains.
2

Update the SDK

Public keys need version 0.7.0 or later:
On a CDN, change the version in the script’s address to 0.7.0.
3

Pass the key as publicKey

Options you already pass go in the same object:
start() and everything after it stay the same.
4

Delete the old key

Once your site runs on the public key, delete the API key on the API keys page, if nothing else uses it.
What works differently with a public key:
  • One environment. A public key reaches only its own environment. Give your staging site a staging key.
  • No choosing a version from the page. To choose per call, get call tokens on your server with a secret key.
  • getJobDetails() doesn’t work. Read the call from your server, or use the agent’s webhook.

Options that no longer do anything

start() still accepts userId, preferHeadphonesForIosDevices, connectionDelay and disableWakeLock, so code that passes them keeps working, but they have no effect. You can remove them.

Older versions of the SDK

Connection details are set for you: you don’t configure the call server yourself. For code written for versions before 0.4, see the SDK’s migration guide on GitHub.