Multiple API Keys
Updated
On this page
Create secondary API keys for the supported developer operations on your Xirsys account. Each secondary key can be disabled, given an expiration, or deleted independently of your existing primary key.
Available to eligible paid accounts: Basic, Standard, Pro, Elite, and Volume production accounts can create secondary keys in Connect across Xirsys regions. Use the normal public gateway, https://global.xirsys.net, or the regional gateway configured for your account.
Understand the Three Credential Types
| Credential | Purpose | Where it belongs |
|---|---|---|
| Primary API key | Your existing account API secret. Its copy and refresh workflow remains available. | Your trusted backend or secret manager. |
| Secondary API key | An additional account-wide developer credential for the supported channel and dynamic TURN operations. | Your trusted backend or secret manager. Use the full value as the Basic-auth password with the same account username. |
| Temporary TURN credentials | The username and credential returned by a successful dynamic TURN request. | Return these temporary ICE values from your backend to the WebRTC client. |
Keep both primary and secondary API secrets out of browser and mobile code, source control, URLs, and logs. A secondary API key is not the credential passed to RTCPeerConnection; obtain temporary ICE credentials from the TURN API first. See Secure API Calls for the backend boundary.
Create and Copy a Secondary Key
- Sign in to the Xirsys dashboard and open Connect.
- In the API Keys card, select create new api key.
- In Copy your new API key, select Copy key and save the complete value in your backend's secret manager.
- Select Done after saving it. New secondary keys are enabled and have No Expiration by default.
Copy it immediately: the complete secondary secret is shown only once. After the dialog closes, the list contains metadata and a short suffix, not a recoverable secret. The backend stores only a verifier. You cannot reveal or copy the full key again later; if it is lost, delete that key and create a replacement.
Use the In-panel TURN Example
In Connect → API Keys, expand How to use secondary API key and select the copy icon labeled Copy API example. The dashboard fills in your signed-in account's ident. Replace YOUR_SECONDARY_API_KEY with the full key you saved when it was created, and replace YOUR_CHANNEL with an owned channel. Run the request from your trusted backend environment.
The in-panel example uses https://global.xirsys.net and requests temporary TURN credentials with webrtc=1, a trailing slash after the channel, and no JSON body. With no explicit expire, the TURN credential lifetime defaults to 60 seconds; it does not change the secondary API key's expiration date. Keep the full API key on your backend and return only the temporary ICE values to the WebRTC client.
Account Limits and Plan Changes
Eligible paid accounts have 15 occupied key slots in total, including the primary key: up to 14 secondary keys. Active keys and disabled but unexpired keys occupy slots, including keys with no expiration. Expired or deleted secondary keys release their slots.
Free accounts cannot create new secondary keys. Keys retained after a downgrade can still be managed. Disabling a key does not free a slot; delete an unused key or wait for its scheduled expiration before creating another when the account is at its limit.
Use a Secondary Key from Your Backend
Authenticate with HTTP Basic auth over HTTPS, using your existing account username and the full secondary API key as the password. Preserve the entire xk1_<uuid>.<secret> value, including the xk1_ prefix and the dot. The displayed suffix alone cannot authenticate a request.
The public examples below contain placeholders. Replace YOUR_IDENT with your account ident, YOUR_SECONDARY_API_KEY with the full secondary key, and YOUR_CHANNEL with an existing channel owned by the same account. Preserve the exact case-sensitive channel name. The dashboard's copied example already fills in the ident.
Secondary-key requests currently support channel names of 1–128 ASCII characters: letters, digits, dots, underscores, and hyphens, starting with a letter or digit (^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$). URL encoding does not make other characters supported. If an existing channel name falls outside this form, use a compatible channel or the existing primary-key flow.
Request Temporary TURN Credentials
curl --user 'YOUR_IDENT:YOUR_SECONDARY_API_KEY' \
--request PUT \
'https://global.xirsys.net/_turn/YOUR_CHANNEL/?webrtc=1'This bodyless request uses the default 60-second TURN credential authentication lifetime. When an explicit expire is supplied, it accepts positive whole seconds as a number or a decimal string, subject to the existing 21,600-second TURN lifetime cap. This lifetime is separate from the secondary key's optional expiration date.
Check the HTTP status and s === "ok" before using the response. With webrtc=1, the array at v.iceServers can be passed directly to WebRTC:
const iceServers = data.v.iceServers;
const peerConnection = new RTCPeerConnection({ iceServers });Existing format: "urls" requests remain supported. That mode returns a single ICE server object at v.iceServers; wrap it in an array before passing it to WebRTC. The webrtc=1 response is already an array and needs no extra wrapper.
Your backend returns the temporary ICE values to the client; it keeps the secondary key private. Use the request shape above for secondary keys. The general TURN API guide also documents primary-key request formats and routing options; those options do not establish secondary-key compatibility.
Supported Operations
- Normal
/_nschannel listing, creation, and deletion operations for the owning account. Channel ownership and normal authorization checks still apply. - Normal
PUT /_turn/<owned-channel>requests for dynamic, short-lived ICE credentials, using the qualified request shape above.
For example, list your account's channels without additional modifiers:
curl --user 'YOUR_IDENT:YOUR_SECONDARY_API_KEY' \
'https://global.xirsys.net/_ns'See the Channels API for channel concepts. Secondary keys do not add per-key channel scopes, roles, quotas, or usage analytics. They share existing account and channel limits.
Secondary keys are not supported for static or persistent TURN issuance, signaling, account or primary-secret reads, billing or account administration, Dashboard sign-in, key management through Basic auth, generic datastore APIs, delegated or composite identities, or other unqualified entry points. Manage keys through the signed-in Connect screen.
Manage Access and Expiration
Open Connect → API Keys in the dashboard and identify a secondary key by its creation date and suffix.
| Action | How it works |
|---|---|
| Disable | Select the power control and confirm Disable. This blocks new authorization decisions for the key. The unexpired key still occupies a slot. |
| Reactivate | Use the power control on a disabled, unexpired key and confirm Reactivate. An expired key cannot be reactivated. |
| Set or change expiration | Select the row's expiration value, choose a date and time in Expiration Date, then select Save. The time must be at least five minutes ahead of the server clock; allow extra time while saving. |
| Remove expiration | For an unexpired key, open its expiration editor, select Clear Expiration Date, and save. Once the key has expired, its expiration cannot be extended or removed; create a replacement. |
| Delete | Select the trash control and confirm Delete. Deletion cannot be undone and releases the key's occupied slot. |
Revocation affects new authorization decisions: disabling, deleting, or expiring an API key does not immediately terminate calls. Previously issued temporary TURN credentials, existing allocations, and established connections may continue for their own lifetimes.
Rotate or Replace a Key
- Create a replacement secondary key in Connect and copy it immediately. You need an available slot.
- Update the trusted backends that use the old secondary key and verify a supported channel or dynamic TURN request with the replacement.
- Disable the old key when those backends have switched, then delete it when it is no longer needed.
If a secondary secret is lost, replace it; there is no recovery or later reveal. Refreshing the primary API key is a separate action that rotates only the primary credential. It does not rotate, revoke, or reveal secondary keys.
Troubleshooting
| Symptom | Check |
|---|---|
| Cannot create a secondary key | Use Connect and confirm an eligible Basic, Standard, Pro, Elite, or Volume plan. Free accounts cannot create new secondary keys. |
| Key limit reached | The primary counts toward the 15-slot total. Disabled unexpired keys also count. Delete an unused secondary key or wait for its expiration. |
| The full secret is no longer visible | Only the creation dialog reveals it. If you did not save the full value, delete and replace the key. |
| Unauthorized API request | Check the same account username, the entire secondary key including prefix and dot, its enabled and unexpired state, the gateway hostname, channel ownership, and a supported operation. Invalid, disabled, deleted, or expired keys return unauthorized. |
| Expiration cannot be saved | Choose a time at least five minutes ahead of the server clock. Reload the list if the key's state changed; an already expired key must be replaced. |
| Temporary service error | Back off and retry. A service or authorization-authority failure is distinct from an invalid credential; it does not by itself mean the key is wrong. |
| A call continues after revocation | API-key revocation blocks new authorization decisions. Existing temporary TURN credentials and established connections have separate lifetimes. |
For persistent problems, contact Xirsys Support with the time, gateway endpoint, HTTP status, and sanitized error details. Do not send primary secrets, full secondary keys, or temporary TURN credentials.