Using APIs in Red Hat Subscription Management

Red Hat Subscription Management 2023

authorizing, managing, and troubleshooting APIs in Red Hat Subscription Management

Customer Content Services


Red Hat Subscription Management offers 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 Red Hat Subscription Management can help you more effectively keep track of and automate how you manage your Red Hat subscriptions and entitlement usage. By using APIs in Red Hat Subscription Management, you can:

  • Control which tooling you use for which products
  • Better manage your system inventory
  • 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 Customer Portal account.


Please use password management that is consistent with networking 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 would 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 Management 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 Management API Tokens page.
  2. Click the Generate Token button.

2.2. Generating a new refresh token

Once 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 passed in the header to authenticate your Customer Portal user to the Red Hat Subscription Management 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. 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
    # curl -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$offline_token

You should see an output similar to the below where access_token is what will be used as authorization token:


The access_token is what needs to be set/used as an authorization token 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 Red Hat 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 Management APIs has failed. There are two possible solutions you can try.


  1. To authenticate through the Red Hat Subscription Management 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.

Chapter 1. Appendix A. Revision History

Table 1.1. Revision History

RevisionDateChanges MadeAuthor

Revision 1.1-0

Tues Sept 19 2019

Procedures for offline, refresh tokens have changed

Anni Bond

Revision 1.0-1

Wed May 8 2019

Added detail to prerequisites about where to get a secret

Anni Bond

Version 1.0-0

Fri May 3 2019

Initial creation

Anni Bond

Legal Notice

Copyright © 2023 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.