API key management

Updated at:

An API key is a credential used to call Voice Studio server-side APIs, including the Real-time Speech Synthesis WebSocket API. Every server-side call must include an API key. Voice Studio uses this key to identify the associated workspace and to check permissions, control concurrency, and bill for usage. In the left navigation pane, click System > API Key to go to the API key management page.

Page structure

  • Left navigation pane: System > API Key

  • Right panel: Use this panel to create an API key, temporarily disable a key, or permanently delete an unused key.

image

Core operations

1. Create an API key

  1. Click the Create API Key button in the upper-right corner.

  2. Confirm the following settings in the dialog box:

    • Credential type (required): Defaults to API Key (Long-term), which creates a server-side key with no expiration date.

    • Permission scope (optional): Defaults to tts:*, which grants access to all speech synthesis features. The default value is recommended.

  3. Click Create.

image

  1. After creation, the full plaintext credential is displayed (for example, sk-0f3c9a1e7b2d4856a1dd7e9f5b3d8a24). Copy and save it to your secret management system immediately.

This is the only time you can view the plaintext key. After you close the dialog box, you cannot view the key again on the page or through any API. If you lose it, you must delete the key and create a new one.

2. Use an API key in your code

Include the API key in the WebSocket handshake for real-time speech synthesis. For server-side calls, place it in the request header:

Authorization: Bearer sk-0f3c9a1e7b2d4856a1c07e9f5b3d8a24

For browser-based calls, which do not allow custom WebSocket request headers, use a query parameter instead:

wss://convai-platform.aliyuncs.com/api-ws/v1/inference?token=sk-...

For the complete protocol specification, see the Real-time Speech Synthesis WebSocket API documentation.

The long-term API key created in the console is intended for server-side use only. Do not embed it in front-end code, mobile application packages, or public code repositories.

3. Disable and enable a key

To disable a key, click Disable in its row. The key is immediately deactivated, and its status changes to Disabled. To reactivate it, click the Enable button that appears.

Use cases: Temporarily block suspicious calls or pause an old credential during a canary release without permanently revoking it.

4. Delete a key

To delete a key, click Delete in its row. After confirmation, the key is permanently revoked and cannot be recovered.

Unlike a disabled key, which you can re-enable, a deleted key cannot be recovered. You should delete a key, not just disable it, if you suspect a key compromise.

Both disabling and deleting take effect immediately. When the status changes, the platform clears the authentication cache. There is no grace period during which a disabled key can still be used.

5. Rotate an API key

As a best practice, rotate long-term API keys periodically. We recommend the following sequence:

  1. Create a new API key.

  2. Perform a canary release in your services to switch to the new key and verify that calls are working correctly.

  3. Disable the old key and continue to monitor. If you missed any callers, they will report authentication failures, and you can immediately re-enable the old key to roll back.

  4. After confirming there are no issues, delete the old key.

Step 3, disabling the old key and monitoring, is crucial. If you delete the key directly and then discover a service is still using it, you cannot roll back the change.

Key limitations

  • Plaintext is not retrievable: A plaintext credential consists of the prefix sk- followed by 32 lowercase hexadecimal characters, for a total of 35 characters. The platform only stores a SHA-256 hash of the key. The platform returns the plaintext only once upon creation. If lost, you must delete the key and create a new one.

  • Four statuses and transition rules: {#credential-status}

    Status

    Description

    Allows authentication

    Active

    Normal and usable.

    Yes

    Disabled

    Manually disabled. You can restore it at any time.

    No

    Expired

    The system sets this status automatically when the key expires.

    No

    Deleted

    Manually deleted and irreversible.

    No

    • You can toggle a key between the Active and Disabled states.

    • You can change a key's status from Active or Disabled to Deleted, but this action is irreversible.

    • The system sets the Expired status automatically; you cannot set it manually.

  • Keys created in the console are long-term credentials: The expiration time is displayed as Long-term, meaning the key does not expire automatically. Therefore, you must manage its lifecycle proactively. Delete unused keys.

  • Permission scope is not a permissions boundary: tts:* is the only valid value for this field. Specifying other values does not narrow the key's permissions. Do not use this field for permission isolation. To limit the blast radius, create separate keys for each application.

  • Credentials are bound to a workspace: The system binds each API key to the current workspace upon creation, and it cannot be moved. Voice Studio will reject an attempt to use a key from workspace A to access resources in workspace B. As a best practice, create separate keys on a per-workspace, per-application basis instead of using a single key for your entire organization.

  • Credentials determine billing attribution: Voice Studio bills the usage from an API key to the workspace it belongs to. By creating separate keys for each application, you also segregate usage data for billing.

  • The API key list lacks "Name" or "Description" fields: Use the ID and Creation Time to distinguish between different keys, and record the purpose of each key in your own secret management system.

  • Not interchangeable with Model Studio API keys: Although Voice Studio uses a protocol compatible with Model Studio, you cannot use a Model Studio API key to call Voice Studio. This action returns a 401 error because the products have separate credential systems.

FAQ

  • I forgot to save the plaintext key. Can I view it again? No. The platform does not store the plaintext. Delete the credential and create a new one.

  • Can I use the masked key like sk-f69eb**** from the list to make calls? No. That is only a masked prefix for identification and is not the complete plaintext key.

  • How long does it take for a key to be disabled? It takes effect immediately. The platform clears the authentication cache when the status changes.

  • Should I disable or delete a key? Use disable if you might need to restore the key later. Use delete if you are sure the key is no longer needed or if you suspect it has been compromised.

  • Can a deleted key be recovered? No. Deletion is irreversible. As a best practice, disable the key first and monitor your services to ensure there are no issues before deleting it.

  • Can I change the "permission scope" to a different value? Keep the default value tts:*. Changing it will not narrow the permissions and may cause confusion.

  • How many keys can I create in one workspace? There is no hard limit. However, we recommend creating separate keys for each application and deleting any that are unused.

  • Can I use a Model Studio API key to call Voice Studio? No. This will result in a 401 error.

  • What do the 401, 4401, and 4403 errors mean during a WebSocket handshake? A 401 error indicates an invalid credential during the handshake phase (which then closes the connection with code 1006). A 4401 error means the credential became invalid after the connection was established. A 4403 error means the credential is valid but does not have permission to access the target resource, which usually indicates a workspace mismatch.