--- title: "OAuth for Gainsight APIs" slug: "oauth-for-gainsight-apis" updated: 2026-11-23T12:30:38Z published: 2026-11-23T12:30:38Z canonical: "support.gainsight.com/oauth-for-gainsight-apis" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.gainsight.com/llms.txt > Use this file to discover all available pages before exploring further. # OAuth for Gainsight APIs Gainsight NXT This article explains to admins about the Open Authorization (OAuth) for Gainsight APIs. ## Overview Gainsight offers REST APIs to integrate your applications or services with the Gainsight platform. Using these APIs, you can insert or update data into the Gainsight applications from external systems. This feature helps integrate with Gainsight with more flexibility. Gainsight has the following two methods to control access to the APIs: - Access Key - OAuth This article provides information on the OAuth process only. For more information about Access Key, refer to the [*Generate API Access Key*](/v1/docs/generate-rest-api-key-1#generate-access-key) *article*. For more information about OAuth 2.0, refer to the [*OAuth 2.0*](https://oauth.net/2/) article. ## Prerequisites - Your org must have **Connectors 2.0 (Horizon Experience)** to use the OAuth atuhentication for APIs. - **Callback URL:** This is a URL where you receive the Authorization Code post authorization. ## Configure OAuth for accessing Gainsight APIs The following are the major steps to configure OAuth for accessing Gainsight APIs: ### Create Application In the *User Management* page, admins can create an application to get **Client ID** and **Client Secret**. To create an application: 1. Navigate to the **Administration > User Management > Authentication** tab **> OAuth Applications** tab. **Note**: Only SuperAdmins can access OAuth Applications. 2. Click **Add Application**. 3. In the **Name** field, enter a unique name of the application. 4. From the **Scope** dropdown list, select *Read* or *Read/Write*. **Note:** The Scope selected within the application applies to all Gainsight APIs. 5. Turn on the **Enable PKCE (Proof Key for Code Exchange)** toggle. PKCE adds an additional security layer to the OAuth authorization. 6. *(Optional)* Select the **Enforce Allowed IP Ranges** checkbox to add trusted IP ranges. When selected, API access is restricted to requests originating from the specified IP addresses only. For more information, refer to the [*Allow List Trusted IP Addresses*](/v1/docs/allow-list-trusted-ip-addresses) article. 7. In the **Callback URLs** field, enter the URL for the callback. 8. *(Optional) Click* ***Add another URL*** *to add another URL for callback.* ![Add Application using PKCE](https://cdn.us.document360.io/8e136619-829c-49c5-afb1-72de86f13288/Images/Documentation/Add_Application.jpg?sv=2026-02-06&spr=https&st=2026-11-24T18%3A13%3A54Z&se=2026-11-24T19%3A13%3A54Z&sr=b&sp=r&sig=QnI1%2FHxluYL4CSmhLm2nTsRrBuGvD1JaEHo6NmxzBGI%3D) 9. Click **Add Application**. A **Copy your client secret** popup appears displaying the OAuth Client Secret. Copy the secret using the **Copy to clipboard** option or reveal it using the eye icon before dismissing the popup. ![Copy Client Secret dialog showing OAuth client secret with options to reveal, copy to clipboard, and confirm the secret has been saved.](https://cdn.us.document360.io/8e136619-829c-49c5-afb1-72de86f13288/Images/Documentation/image5.png?sv=2026-02-06&spr=https&st=2026-11-24T18%3A13%3A54Z&se=2026-11-24T19%3A13%3A54Z&sr=b&sp=r&sig=WQG4p0s33yRImcMa2Yy4pqWwe3%2Fe%2FtGJQZi8VPZkWOM%3D) 10. Click **I've saved the secret** button to dismiss the popup. The Client Secret is permanently masked after this point and cannot be viewed again. If you lose the secret, you must regenerate it. **IMPORTANT:** - Admins can create upto three applications in Gainsight. The same Client ID can be used to generate multiple Authorization Codes for different Scopes passed in the browser.These authorization codes can be used for generating Access Tokens from different external agents (browser or applications). For more information about Authorization Code and Access Token, refer to the [Obtain Authorization Code](/v1/docs/oauth-for-gainsight-apis#obtain-authorization-code) and [Generate Access Token](/docs/oauth-for-gainsight-apis#Generate_Access_Token) sections. - While creating an application, Permissions (of authorizing a user) and Scope (selected in the application) play an important role in defining access type for the external application, which are accessing the Gainsight APIs. The following are the two scenarios where access is provided based on the selected scopes and user’s permissions: - If the authorizing user has fewer permissions than the scope provided in the application or in the browser, then the level of access for the external application will be as per the user’s permissions. For example, If the user has only Read Permission, an application getting authorized by the same user will not be able to Write into any object accessed via the APIs. - If the Scope provided in the application or in the browser is lesser than the Permissions given to the user, then the level of access for the external application will be as per the Scope provided in the application or the browser. - After generation of the Authorization Code, if the Scope of an application is changed, the users must regenerate the Authorization Code for the new Scopes. - After the Access Token has been generated, if the authorizing user’s permissions change, they will have to re-authorize to generate a new Access Token and Refresh Token as the existing tokens will have access to the data according to the user’s previous permissions. #### **Re-Generate Client Secret** If you lose your Client Secret or need to rotate it for security reasons, you can generate a new one using the Re-Generate Client Secret option in the application details screen. > [!NOTE] > Note > > Re-generating a Client Secret immediately invalidates the existing secret. Any integration using the previous secret stops working until you update it with the new secret. To re-generate a Client Secret: 1. Navigate to **Administration** > **User Management** > **Authentication** > **OAuth Applications**. 2. Click the three-dots vertical menu next to the application and select **View/Edit**. The application details screen opens. ![OAuth Applications page showing application list with View/Edit option to manage application settings, credentials, and access configuration.](https://cdn.us.document360.io/8e136619-829c-49c5-afb1-72de86f13288/Images/Documentation/image3.png?sv=2026-02-06&spr=https&st=2026-11-24T18%3A13%3A54Z&se=2026-11-24T19%3A13%3A54Z&sr=b&sp=r&sig=yjEkPMHwNx4mSLfrdTp3zDLUTR4bg95TUrbHZDJ2aMI%3D) 3. Click **Re-Generate Client Secret** in the Client Secret field. A confirmation dialog box appears. ![OAuth application settings showing client credentials, callback URLs, and Re-Generate Client Secret option for rotating application secrets.](https://cdn.us.document360.io/8e136619-829c-49c5-afb1-72de86f13288/Images/Documentation/image2.png?sv=2026-02-06&spr=https&st=2026-11-24T18%3A13%3A54Z&se=2026-11-24T19%3A13%3A54Z&sr=b&sp=r&sig=n7ZkEskipgC684aG2Li5Z2iENI%2FTjoFFoV4WNQ3XVto%3D) 4. Read the warning and click **Re-generate** to proceed. ![Confirmation dialog warning that regenerating the OAuth client secret invalidates the current secret, with Re-generate and Cancel options.](https://cdn.us.document360.io/8e136619-829c-49c5-afb1-72de86f13288/Images/Documentation/image6.png?sv=2026-02-06&spr=https&st=2026-11-24T18%3A13%3A54Z&se=2026-11-24T19%3A13%3A54Z&sr=b&sp=r&sig=ZVaq3skkSfv0kMXq3fQVC54YLCtbp3ROy5L89%2BEnxCs%3D) 5. In the **Copy your client secret** dialog box, click **Copy to clipboard** to copy the new secret. You can also click the eye icon to reveal the secret before copying. ![Copy Client Secret dialog showing the OAuth client secret with options to reveal, copy to clipboard, and confirm secure storage before closing.](https://cdn.us.document360.io/8e136619-829c-49c5-afb1-72de86f13288/Images/Documentation/image5.png?sv=2026-02-06&spr=https&st=2026-11-24T18%3A13%3A54Z&se=2026-11-24T19%3A13%3A54Z&sr=b&sp=r&sig=WQG4p0s33yRImcMa2Yy4pqWwe3%2Fe%2FtGJQZi8VPZkWOM%3D) 6. Click **I've saved the secret** to dismiss the dialog box. > [!NOTE] > Note > > The Client Secret is displayed only once. Copy and store the secret securely before dismissing the dialog box. If you lose the secret, you must re-generate it. ### Obtain Authorization Code After creating an application, you need to generate an Authorization code. The Authorization code is used to generate Access and Refresh Tokens. **Note:** Authorization code can be generated for each type of Scope (Read or Read/Write). To obtain the Authorization Code: 1. In a new browser tab, enter the following URL and replace the **Application URL**, **Client ID**, **Callback URL**, and **Scope**. **URL format:** /v1/authorize?clientId=&redirectUri=&scopes= **Sample URL:** [https://xyzcompany.gainsightcloud.com/v1/authorize](https://xyzcompany.gainsightcloud.com/v1/authorize)?clientId=yGCCltz2ZZuqhUqfB2DgUPInBaFlq7uR&redirectUri=[https://oauthtest..com&scopes=read_write](https://oauthtest..com&scopes=read_write) **IMPORTANT:** - *redirectUri* and *Callback URL* provided while creating the application must be the same. - Only two scopes can be provided, *read* or *read_write*. 2. Press *Enter* on your keyboard. The login page of Gainsight is displayed. 3. Enter the **Username** and **Password**. **Note:** The application can access data based on the permissions of the user who authorized the application. 4. Click **Log IN**. This redirects you to the *Callback URL* provided in the application. You can find the **Authorization Code** in the URL. [Embedded content](https://player.vimeo.com/video/579388639) ### Gainsight Recommended OAuth Access Gainsight recommends using the below URL that follows the OAuth Standard to generate an Access token. **URL:** https:///v1/users/oauth/access/token #### Get User OAuth Access Token Based on Authorization Code Replace the **Client Secret** and **Authorization code** in the request body. ```plaintext { "clientId": "Insert Client ID", "clientSecret": "Insert Client Secret", "grantType":"authorization_code", "redirectUri" : "Insert URL", "code" :"Insert Code" } ``` You will get a JSON response back containing the *Access Token* (validity 3600 seconds) and *Refresh Token*. The following is a sample JSON response: ```plaintext {    "access_token": "<>",    "refresh_token": "<>",    "token_type": "Bearer",    "expires_in": 3600 } ``` #### Get User OAuth Access Token Based on Refresh Token After an *Access Token* expires, you can get a new Access Token by using the *Refresh Token* generated with the *Access Token*. The following script shows the sample request body to refresh the Access Token: ```plaintext { "clientId": "Insert Client ID", "clientSecret": "Insert Client Secret", "grantType":"refresh_Token", "refreshToken": "Insert Refresh Token" } ``` You will get a JSON response back containing the *Access Token* (validity 3600 seconds) and *Refresh Token*. The following is a sample JSON response: ```plaintext {    "access_token": "<>",    "refresh_token": "<>",    "token_type": "Bearer",    "expires_in": 3600 } ``` ### Generate Access Token (Earlier Version) You can generate the Access Token by entering the following URL in the POST method. **URL:** https:///v1/users/oauth/token **Notes:** - This is an earlier version of token generation. Gainsight recommends using the method described in the [Gainsight Recommended OAuth Access](/v1/docs/oauth-for-gainsight-apis#gainsight-recommended-oauth-access) section to generate access tokens, as it follows the OAuth standard and provides improved security and compatibility. - User Permissions restrict the data that can be accessed by the APIs when called using the Access Tokens. - Gainsight follows the Authorization Code flow of the OAuth authentication, that is, an authorization code is required to generate the Access Token. Replace the **Client Secret** and **Authorization code** in the request body. ```plaintext {    "clientId": "Insert Client ID",    "clientSecret": "Insert Client Secret",   "grantType":"authorization_code",   "redirectUri" : "Insert URL",   "code" :"Insert Code" } ``` You will get a JSON response back containing the *Access Token* (validity 3600 seconds) and *Refresh Token*. The following is a sample JSON response: ```plaintext {    "result": true,    "errorCode": null,    "errorDesc": null,    "requestId": "wquoiueoiasd",    "data": {        "accessToken": "ukjds80asdsvdfvsdvdsvsdvsdvdvskjlklk112nkl",        "refreshToken": "dassadaadjlsadjlsaddadvdsddsdvsdvdvdssdvd",        "TokenType": "Bearer",        "expiresIn": 3600    },    "message": null } ``` You can use this **Access Token** in the Gainsight APIs and Bulk API job’s cURL Command. For more information about how to generate the cURL command, refer to the [*Gainsight Bulk API*](/v1/docs/gainsight-bulk-api-1#curl-api) and [*API and Developer Docs*](/v1/docs/api-and-developer-docs-1) articles. ## Refresh Token After an *Access Token* expires, you can get a new Access Token by using the *Refresh Token* generated with the *Access Token*. The following script shows the sample request body to refresh the Access Token: ```plaintext {  "clientId": "Insert Client ID",       "clientSecret": "Insert Client Secret",   "grantType": "refresh_token",        "refreshToken": "Insert Refresh Token" } ``` > [!NOTE] > Note > > - Each time you generate an access token, a new refresh token is also generated. By default, a refresh token is valid for 365 days, but can be used only once. > - Gainsight enables OAuth Refresh Token Rotation by default. Each time Gainsight generates a new access token, it also issues a new refresh token and immediately invalidates the previous one. When refresh tokens are rotated, it is important to understand how the system handles token reuse and concurrent requests. **Breach Detection** If an access token request is made using a previously invalidated refresh token, the system triggers breach detection. This invalidates all refresh tokens in the token chain, including the most recently issued one. The user must then re-authorize the application to obtain a new authorization code and tokens. **Rotation Overlap Period** To reduce unintentional breach detection caused by near-simultaneous refresh requests, Gainsight automatically applies a Rotation Overlap Period of 30 seconds. During this window, only the immediately preceding refresh token remains valid for up to 30 seconds after a new refresh token is issued. All other earlier refresh tokens in the chain remain invalidated. This is applied automatically and requires no action from customers or Gainsight Support. **Example Business Use Case:** 1. Using authorization_code (code1) generates Access Token AT1 and Refresh Token RT1. 2. Using RT1 generates Access Token AT2 and Refresh Token RT2. RT1 is immediately invalidated. 3. Using RT2 generates Access Token AT3 and Refresh Token RT3. RT2 is immediately invalidated. 4. Using RT1 again triggers breach detection, even within the overlap window, because RT1 is not the immediately preceding token. RT1, RT2, and RT3 are all invalidated. ## Revoke Authorization Admins can revoke the authorization of an application to restrict the access to Gainsight data, if required. To revoke authorizations of an application: 1. Navigate to the **Administration > User Management > Authentication > OAuth Applications**. 2. Click the **three-dots** **vertical** menu and select **View/Edit**. The *OAuth Application* details page is displayed. 3. Click **Authorizations**. 4. Click the **three-dots** **vertical** menu and select **Revoke Authorization**. A confirmation dialog is displayed. 5. Click **Confirm**. **Note:** When a user authorization is revoked, the *Refresh Token* becomes invalid. ![Screenshot 2024-06-29 at 11.07.25 PM.png](https://cdn.us.document360.io/8e136619-829c-49c5-afb1-72de86f13288/Images/Documentation/Screenshot_2024-06-29_at_11.07.25%E2%80%AFPM.png?sv=2026-02-06&spr=https&st=2026-11-24T18%3A13%3A54Z&se=2026-11-24T19%3A13%3A54Z&sr=b&sp=r&sig=u1AyjkepSMkbs2ndUzs0HSVcYm7sKjXa98pDRzSHsZY%3D) ## Revoke Refresh Token Admins can revoke the Refresh Token by calling the APIs. The following are the required details for revoking the Refresh Token: | Method | POST | | --- | --- | | URL | https:///v1/users/oauth/revoke | | Request Headers | Content-type: application/json | ### Request Body ```plaintext {    "clientId": ,    "clientSecret": ,    "refreshToken": } ``` ## Refresh Token Status Admins can view the status of the Refresh Token in the *Authorization* tab. The newly generated Refresh Token is valid for an hour, after which a new Refresh Token is generated. The following are the statuses: - **Active:** Indicates that the Refresh Token is active and can be used to generate new Access tokens. - **Expired:** Indicates that the Refresh Token is expired and cannot be used to generate new access tokens. Users have to re-authorize to generate a new Refresh Token, refer to [Obtain Authorization Code](/v1/docs/oauth-for-gainsight-apis#obtain-authorization-code) section in this article. - **Revoked:** Indicates that the Refresh Token is revoked by the user. Users can re-authorize to generate a new Refresh Token. - **Invalid:** Indicates that the Refresh Token has become invalid due to the deactivation of the user. Delete an Application Admins can delete an application to remove the authorization of the application. When an application is deleted, access to Gainsight data of the external application is automatically restricted. To delete an application: 1. Navigate to the **Administration > User Management > Authentication > OAuth Applications**. 2. Click the **three-dots** **vertical** menu and select **Delete**. A confirmation dialog is displayed. 3. **Click Yes.** **Note:** If the application is deleted, all codes or tokens will be invalid. Deactivate Application When an application is deactivated, Access Token and Refresh Token generated for the application are temporarily blocked until the application is activated again. To deactivate an application: 1. Navigate to the **Administration > User Management > Authentication > OAuth Applications**. 2. Turn OFF the **Status** toggle switch to deactivate the application. OAuth with Gainsight APIs You can authorize the Gainsight APIs by using OAuth, when accessing Gainsight data from the external applications. The following are the details required for validation of the API call: ### Method Details | **HTTP Method** | PUT | | --- | --- | | **Content Type** | application/json | | **Response Format** | JSON | | **Requires Authentication** | Yes | | **Header** | **Accesskey:** Pass the API Access key you received from Gainsight in the header “Accesskey” Or **Authorization:** Pass the “Bearer ” in the header | ### Required Parameters | **Required Parameters** | **How To Use** | **Description** | | --- | --- | --- | | API Key | Passed through the Request Header | Pass the API Access key you received from Gainsight in the header “Accesskey”. | | Authorization | Passed through the Request Header | Pass the “Bearer ” in the header. | | New Record or Update Record JSON | Passed through the Request Body | This is the JSON that represents a new record that you create in the Person object or update an existing record. A sample JSON is shown in the below section Request Body. | | Key | Passed through the Request Body | Email is the only field that helps to identify a record in the Person object. Passing this field through API request body is mandatory. Using this field, remaining fields in the Person object are updated or a new record is created. | ## Additional Resources For more information on the Gainsight APIs, refer to the following articles: - [Company API Documentation](/v1/docs/company-api-documentation) - [Person API Documentation](/v1/docs/people-api-documentation) - [Gainsight Bulk API](/v1/docs/gainsight-bulk-api) - [Events API](/v1/docs/events-api-1) - [Cockpit API](/v1/docs/call-to-action-cta-api-documentation) - [Success Plan API](/v1/docs/success-plan-apis-1) - [Data Management API](/v1/docs/data-management-apis-1)