Skip to main content

Key Service Management API

The Key Service Management API is mainly used to configure the behavior of the service.

The API is exposed by the Key Service.

OpenAPI Specification​

The API reference in the OpenAPI format can be found at this location: https://key-service-management.axprod.net/api/help

Authorization​

Only authorized callers can make requests to the Management API. Every request carries an Authorization header, and the Key Service accepts three kinds of credentials:

MethodHeaderUse it when
Mosaic access tokenBearer <access token>Your own code or scripts call the API for a Mosaic environment. This is the recommended method.
Service account credentialsBasic base64("<Client ID>:<Client Secret>")A packager or tool for a Mosaic environment can only send a user name and password, for example over SPEKE.
Management keyBasic base64("<Tenant ID>:<Management Key>")Your DRM configuration was created in Axinom Portal under a legacy agreement, or neither Mosaic method fits your setup.

The same methods work for the key exchange endpoints that use this header, such as SPEKE, Harmonic, Anevia, Broadpeak, and Titan.

All methods use the Key Service Management API URL of your environment, https://<your-prefix>.key-service-management.axprod.net/api/. In a Mosaic environment, you find it on the DRM Service page of the Management System, under Admin Settings.

Before you start: a service account​

Both Mosaic methods need a service account of the environment whose DRM configuration you want to use.

  1. In the Mosaic Admin Portal, create a service account for the environment, as described in How to Authenticate a Service Account.
  2. Copy the Client ID and the Client Secret. The secret is shown only once.
  3. Open the Permissions of the service account and grant the Admin permission of the DRM Service.

You do not need a Key Service Tenant ID. The Key Service selects the DRM configuration from the environment that the service account belongs to.

tip

Create a separate service account for each integration, for example one per packager. You can then reset the secret or remove the access of one integration without affecting the others.

Mosaic access token​

Request an access token for your service account from the Mosaic Identity Service, and send it with each request:

Authorization: Bearer <access token>

How to Authenticate a Service Account shows how to get the token, either through the API or, for a quick test, with Generate Access Token in the Admin Portal. The following example requests a token and then lists the key seeds' meta data of the environment:

TOKEN=$(curl -s https://id.service.eu.axinom.net/graphql \
-H "Content-Type: application/json" \
-d '{"query":"mutation { authenticateServiceAccount(input: { clientId: \"<Client ID>\", clientSecret: \"<Client Secret>\" }) { accessToken expiresInSeconds } }"}' \
| jq -r '.data.authenticateServiceAccount.accessToken')

curl https://<your-prefix>.key-service-management.axprod.net/api/KeySeeds \
-H "Authorization: Bearer $TOKEN"

You manage the lifecycle of the token:

  • A token is valid for 1 hour by default. You can change this per environment in the Admin Portal, in the Identity Service configuration, under Service Account Token Lifetime (seconds).
  • Don't use a very long lifetime as a substitute for renewing tokens. A token stops working when the token signing key of the environment changes, which happens on a regular schedule and whenever an administrator uses Revoke & Rotate Signing Key.
  • Reuse a token for as long as it is valid, and request a new one shortly before it expires.
  • Changes to the service account, such as removed permissions, apply to tokens requested after the change.

Any Mosaic access token of the environment works, as long as it carries the Admin permission of the DRM Service.

Service account credentials​

Some packagers can only send a user name and password. For them, the Key Service also accepts the service account credentials directly, through Basic authentication:

Authorization: Basic base64("<Client ID>:<Client Secret>")

In a packager, enter the Client ID as the user name and the Client Secret as the password.

For example, with the Client ID 3f9a1c2e-7b4d-4e8a-9c1f-5d6e7a8b9c0d and the Client Secret Xk7pQ2mN9vR4tL8wZ3bH6jYc (these are sample values, not real credentials), the header is:

Authorization: Basic M2Y5YTFjMmUtN2I0ZC00ZThhLTljMWYtNWQ2ZTdhOGI5YzBkOlhrN3BRMm1OOXZSNHRMOHdaM2JINmpZYw==

The Key Service requests and renews the access token on your behalf, and reuses it while it is valid. Keep the following in mind:

  • Changes to the service account, such as a secret reset, a removed permission, or a deleted account, can take up to the token lifetime (1 hour by default) to take effect.
  • A failed attempt, for example because of a missing permission, is remembered for about 30 seconds. After you fix the cause, wait half a minute before you try again.
  • The first request with new credentials can take a few seconds longer than the following ones.

Management key​

A management key belongs to a Key Service tenant. To use it, you need:

  • Tenant ID - a GUID, for example c72d7f6a-c4b3-4141-b996-06c6266d5588, used to uniquely identify your tenant
  • Management Key - a GUID, for example 8a276e90-6923-4bda-9f5e-8eddc9159a1e

Pass both in the Authorization header of each request:

Authorization: Basic base64("<Tenant ID>:<Management Key>")

With the values above, the header is:

Authorization: Basic YzcyZDdmNmEtYzRiMy00MTQxLWI5OTYtMDZjNjI2NmQ1NTg4OjhhMjc2ZTkwLTY5MjMtNGJkYS05ZjVlLThlZGRjOTE1OWExZQ==
note

When accessing the Key Service Management API with Tenant ID and management key, make sure to use the Key Service Management Key for authorization, not the License Service Management Key.

Where the values come from

With a legacy agreement, the Tenant ID, the management key, and the API URL are in your configuration PDF; see Legacy agreement credentials. A Mosaic environment is created without a management key, because the Mosaic methods above make it unnecessary. If neither of them fits your setup, request a management key from Axinom Support. The Tenant ID of a Mosaic environment is on the DRM Service page of the Management System.

Caution

It is not possible to recover the Management Key if it’s lost. It is possible to generate a new one by raising a ticket to Axinom Support.

Endpoints​

The API exposes the following endpoints:

Content Keys Operations​

EndpointMethodDescription
/ContentKeysPOSTCreates a new content key
/ContentKeysGETReturns one or multiple content keys (only their metadata; not the real key value)
/ContentKeysPUTUpdates the name of a content key
/ContentKeysDELETEDeletes a content key
/Import/ContentKeysPOSTImports one or multiple content keys from a JSON array
/Export/ContentKeysPOSTExports one or multiple content keys as a CPIX document

Key Seeds Operations​

EndpointMethodDescription
/KeySeedsPOSTCreates a new Key Seed
/KeySeedsGETReturns one or multiple Key Seeds (only their metadata; not the real Key Seed value)
/KeySeedsPUTUpdates the name of a Key Seed or makes it default
/KeySeedsDELETEDeletes a Key Seed
/Import/KeySeedsPOSTImports one or multiple Key Seeds from a JSON array
/Export/KeySeedsPOSTExports one or multiple Key Seeds as a PKSC document

Errors​

In case of an error, the service returns an HTTP status code following HTTP conventions.

Additionally, the service adds a human-readable explanation of the error in a custom HTTP header X-AxDRM-ErrorMessage.

If HTTP/1 is used the same error explanation is returned as HTTP ReasonPhrase.

Caution

We recommend that you rely on the X-AxDRM-ErrorMessage header because the ReasonPhrase is not supported by HTTP/2, and also some HTTP/1 client libraries do not support parsing the ReasonPhrase.

CORS clients, such as browsers, sometimes don’t have access to custom HTTP headers. To enable such clients reading the informational headers, service adds Access-Control-Expose-Headers header to the response and explicitly enables reading of the "X-AxDrm-ErrorMessage" header.

Authentication errors​

The most common errors when authenticating:

StatusMessageWhat to check
401Authentication is required.The request has no Authorization header.
400Invalid authentication token: ...The Basic value is not valid Base64, or the decoded value has no colon between user name and password.
400Invalid Basic authentication 'username': the value is not a valid GUID.The user name must be a Client ID or a Tenant ID.
400Invalid Basic authentication 'password': ...The password is empty or longer than 64 characters.
401Invalid service account credentials.The Client ID or the Client Secret is wrong, or the service account was deleted.
401Invalid JWT. The token has expired.Request a new access token.
401Invalid JWT. ...The token is malformed, or it was not issued by the Mosaic Identity Service.
403Insufficient permissions to access this service.Grant the Admin permission of the DRM Service to the service account. For a token, request a new one after the change.
401There was no matching DRM tenant for the Mosaic environment.The DRM Service is not enabled for the environment of the service account or token, or the DRM configuration is disabled.
401Unknown credentials.The Tenant ID or the management key is wrong, or the management key was disabled.
500An error occurred, but the details have been omitted for security reasons. ...The Key Service could not verify the service account credentials. Try again later, and contact Axinom Support if the error persists.

Was this page helpful?