Using APIs in Red Hat Subscription Management

Subscription Central 1-latest

authorizing, managing, and troubleshooting subscription management APIs

Customer Content Services


Red Hat subscription services offer developed and documented APIs to help you better automate, manage, and track your subscriptions to Red Hat products.

1. Using APIs in Red Hat Subscription Management

Using APIs in subscription services can help you more effectively track and automate your Red Hat subscriptions usage in the following ways:

  • Control which tools that you use for each product
  • Better manage your system and subscription inventories
  • Update and secure your systems more efficiently
  • Continue receiving official support for your Red Hat products

Red Hat Subscription Management APIs use OAuth 2.0 for authorization. To obtain a token and access the APIs, you will need the following pieces of information:

2. Using tokens for authentication

Offline and refresh tokens are used by Red Hat Subscription Management to authenticate your system after you set up your account using your secret to authenticate your Red Hat Single Sign On (SSO) account.


Please use password management that is consistent with security best practices. It is never safe to store any passwords or credentials in plaintext. Treat your offline token with the same security measures that you use for a password to protect it against unauthorized use.

2.1. Generating a new offline token

An offline token never expires as long as it is used at least once every 30 days and is used to create access tokens for the Red Hat Subscription Manager APIs. It works as a password and allows you to continue being able to authenticate your account without having to create new refresh tokens.


  1. Visit the Red Hat Subscription Manager API Tokens page.
  2. Click the Generate Token button.

2.2. Generating a new refresh token

After you have created the offline token, you can use that token to create a new refresh token, which includes an access token that is valid for five minutes. Access tokens are used in the header to authenticate your Customer Portal user account to the Red Hat Subscription Manager APIs.


  1. Set the offline token value. In this example, we set it in plaintext and shorten the token value for clarity:

    # offline_token='eyJhbGciOiJSUzI1NiIsInR5cCIgOiA'
  2. Enter the following command to create a function to easily filter out JSON values.

    # function jsonValue() {
    awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/'$KEY'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p
  3. Enter the following command to extract the access_token:

    # curl -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$offline_token

    The expected output is similar to the following, where access_token is the token used to authorize your account:

  4. Enter the following command to set the access_token as an authorization token that can be used to perform the API call.

    # token=`curl -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$offline_token | jsonValue access_token`

3. Accessing available subscription management APIs

Red Hat provides a Swagger file to describe the specifications of the Red Hat Subscription Management APIs. The Swagger specification includes information about the API endpoints available, input parameters, expected output, and possible error responses. The swagger file can be imported into REST clients like Postman or RESTlet to automatically build a library of API calls.

4. Troubleshooting API errors

Table 1. API errors



BadRequest error

Validate that you entered the API call correctly and try again.



Generate a new authorization token.



Generate a new authorization token.


Not found

Resource not found or does not exist.


Too many requests

Reduce the frequency of requests


Internal server error

The problem is on Red Hat’s end. Wait a minute and try your request again.

4.1. Troubleshooting error 403

Error 403 is a "not authorized" error, meaning that the authentication you are using for Red Hat Subscription Manager APIs has failed. There are two possible solutions you can try.


  1. To authenticate through the Red Hat Subscription Manager gateway, ensure the authorization header includes the text "bearer" before entering your API call:

    curl -H "Authorization: Bearer <token>" <api_url>
  2. If the header is correct, create a new token. Refresh tokens last for five minutes.

4.2. Troubleshooting error 429

Error 429 is a “rate limiting” error, meaning that your account has exceeded the number of allowed requests per second. This limit applies to all users of a single Red Hat account.


Extract the header of the response, which includes: * X-RateLimit-Limit: the total requests/sec allowed * X-RateLimit-Remaining: the number of requests/sec remaining (this will be a negative integer) * X-RateLimit-Delay: the number of seconds the requester should wait before trying again

Adjust the rate of requests to the X-RateLimit-Limit value and start again once the X-RateLimit-Delay time has passed.

Legal Notice

Copyright © 2024 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.