On this page

API Keys

API keys let your code use Qencode: run transcoding jobs, create live streams, manage storage and read statistics. This guide covers creating and managing keys, what each key role can do, how keys turn into access tokens, and what changed for existing integrations.

Overview

  • Each project has its own API keys, up to 20 working keys per project. Use a separate key for each application, server or environment.
  • New keys start with qnc_, so they are easy to recognise in code and to scan for.
  • The full key is shown only once, when you create it. Copy it and store it somewhere safe, such as your secrets manager. Afterwards the portal and the API show only the key's last four characters.
  • Every key has a role (Admin, Developer or Billing), an optional expiry and an optional IP allow list.
  • Each project's original key is its Primary key (see Your Primary key).

Manage your API keys

1
Open the API keys of a project

On the Transcoding Projects or Streaming Projects page, click the value in the API Keys column of the project. The list shows each key's name, last four characters, role, expiry, when it was last used, and who created it. Revoked keys stay in the list as history.

2
Create a key

Click Create API key and choose:

  • Name: optional, for example the server or app that uses the key.
  • Role: Admin, Developer or Billing (see Key roles).
  • Expiry: 30, 90 or 365 days, a custom date and time, or never. New keys expire after 90 days by default.
  • IP allow list: optional (see IP allow list).

Copy the key from the confirmation window. It is not shown again.

3
Edit a key

You can change a key's name, role, expiry and IP allow list at any time. The key itself stays the same. After a change of role, tokens issued earlier from the key stop working within about a minute: get a new token.

4
Roll a key

Rolling replaces a key with a new one without downtime. The new key keeps the old key's name, role and IP allow list, and the old key keeps working for a grace period you choose: from 0 to 720 hours (30 days), 24 hours by default. Update your systems to the new key before the grace period ends.

  • A roll with a grace period needs a free slot under the 20-key limit, because both keys work during it.
  • If a key has leaked, roll it with a grace period of 0 so the old key stops at once.

5
Revoke a key

Revoking stops a key for good. Tokens already issued from it stop working within about a minute. Primary keys can't be revoked: roll them instead.

Key roles

The role decides what a key, and every token issued from it, can do:

PermissionAdminDeveloperBilling
Transcoding, live streaming, media storage, player✓✓—
Statistics✓✓✓
Billing✓—✓
Read organization information✓——
List projects; rename or delete the key's own project✓✓—
Create new projects✓——
Read the key list of the key's own project✓——
Create, change or revoke API keys; manage the team———

Creating, changing and revoking keys and managing your team are done in the Qencode portal while signed in, never with an API key.

note
Team roles and key roles
Your role in the organization decides which keys you can manage. Owners and Admins can manage every key. Developers can create only Developer keys, always with an expiry, and can change only the Developer keys they created. A project created by a Developer starts with a Developer-role Primary key. Billing members can't manage keys.

Your Primary key

Each project's original key is its Primary key:

  • It has the Admin role, never expires and can't be revoked. To replace it, for example after a leak, roll it: the new key becomes the Primary key and also never expires.
  • The portal uses the Primary key to run jobs from the Request Builder and to create live streams. Keep it on the Admin or Developer role and without an IP allow list, or those portal features stop working for the project.
  • Removing a team member and revoking the keys they created skips Primary keys.

Your existing keys keep working: when this feature was released, each project's existing key became its Primary key with the Admin role and no expiry.

IP allow list

You can limit a key to specific addresses: single IPv4 or IPv6 addresses and CIDR ranges, separated by commas, for example 203.0.113.10, 198.51.100.0/24. An empty list allows any address.

The list is checked when a token is issued or refreshed, not on every request. A token issued to an allowed address keeps working from any address until it expires (up to 24 hours).

Get an access token

Exchange an API key for an access token, then send the token as a bearer token:

curl -X POST https://auth.qencode.com/v1/auth/access-token \
  -H 'Content-Type: application/json' \
  -d '{"access_id": "qnc_YOUR_API_KEY"}'
{
  "access_token": "eyJ...",
  "token_expire": 1796000000.0,
  "refresh_token": "eyJ...",
  "refresh_token_expire": 1796600000.0
}
  • The access token carries the key's project and role and lives up to 24 hours.
  • The refresh token lives 7 days and can only renew a token for the same key: POST https://auth.qencode.com/v1/auth/refresh-token with {"refresh_token": "..."}.
  • A wrong, revoked or expired key, or a request from an address outside the key's IP allow list, gets 401.
  • When a key is revoked, expires or gets a different role, its tokens stop working within about a minute.

The Transcoding API (/v1/access_token) and the Live Streaming API exchange keys the same way and apply the same rules. They refuse Billing keys, which can use only billing and statistics.

What changed for existing integrations

Most integrations keep working without changes. Check these:

  • Project responses no longer include the full key. GET /v1/project/{vod|live} in the Account API returns "api_key": null with the key's last_four, api_key_role and active_key_count. If your code reads keys from project responses, store each key when you create it instead.

    // before
    { "id": "386591dd-...", "name": "My project", "api_key": "5adb0584aa29f" }
    // now
    { "id": "386591dd-...", "name": "My project", "api_key": null,
      "last_four": "aa29", "api_key_role": "admin", "active_key_count": 1 }
  • Tokens follow their key. A token used to act with the account owner's full access. Now it has only its key's role and works on its key's project.

  • Keys can't manage keys or the team. Use the portal for that.

Move integrations off the Primary key

  1. Create a key for each application or server, with the lowest role it needs (usually Developer; Admin only if it creates projects).
  2. Give each key an expiry, and an IP allow list for servers with fixed addresses.
  3. Switch the integration to the new key and check its Last used value.
  4. Keep the Primary key for the portal, and roll it if you think it was exposed.

If a key leaks

  1. Revoke the key, or roll it with a grace period of 0 if it is a Primary key. Its tokens stop working within about a minute.
  2. If it was an Admin key, check your project list for projects you don't recognise and delete them. Contact support@qencode.com to get the list of projects that key created.
  3. Create a replacement key with the lowest role the system needs.