---
title: Connect to the OpenLM External API Gateway
description: Create a General API client in OpenLM Identity, request an access token, and send your first request to OpenLM Platform through the External API Gateway.
product: OpenLM Platform
---

To read OpenLM Platform data or manage License Access Control from your own application or integration, such as ServiceNow, send your requests to the OpenLM External API Gateway. The gateway is one address for several OpenLM Platform services: License Access Control, the Reporting Data API, AI Reporting insights, SAM entitlement records, Broker Hub, the ServiceNow CMDB feeds, and the OpenLM MCP Connector.

Your application signs in with its own client credentials. The access level of those credentials decides what it can read or change, and the gateway returns only the data of the account the credentials belong to.

## How access works

Access to the gateway takes three steps:

1. An administrator who manages Identity creates a General API client and chooses its access level.
1. Your application exchanges the client ID and secret for an access token at the OpenLM Identity Server.
1. Your application sends the token with every request to the gateway.

This is a server-to-server flow, with no user sign-in or browser redirect. Your application authenticates as itself.

### Access levels

Each General API client carries one or more access levels. A higher level includes everything the lower levels allow, so one level is enough. The following table lists the levels:

| Access level | Scope | What the client can do |
| :---- | :---- | :---- |
| Read | `api.read` | Run every query: reports and CSV exports, AI Reporting insights, License Access Control settings and history, SAM entitlement records, the ServiceNow CMDB feeds, the Broker list, and the OpenLM MCP Connector. |
| Manage | `api.manage` | Everything Read allows, plus changes in License Access Control: add and update rules and policies, approve or deny discovered license servers, and deploy rules, policies, and license servers. |
| Admin | `api.admin` | Everything Manage allows, plus delete License Access Control rules, license servers, and policies, change the License Access Control configuration, and approve or remove Brokers in Broker Hub. |

Give each integration the lowest level it needs. An integration that only reads reports needs Read. For the access level of each operation, see [External API Gateway reference](https://www.openlm.com/documentation/cloud/api/external-api-gateway-reference).

## Before you begin

To connect to the gateway, you need the following:

- An administrator who manages Identity in your OpenLM Platform account, to create the client.
- The addresses of the region your account is in, from the following table.

| Region | Base URL `{BASE_URL}` | Identity Server `{IDENTITY_URL}` |
| :---- | :---- | :---- |
| US | `https://cloud-us.openlm.com` | `https://cloud-us.openlm.com/identity` |
| EU | `https://cloud-eu.openlm.com` | `https://cloud-eu.openlm.com/identity` |

Every gateway endpoint is under `{BASE_URL}/api/externalapigateway`.

## Create a General API client

Create one client for each integration, so that you can reset or remove one without cutting off the others.

To create a client:

1. Open **Navigation** (the grid icon in the header).
1. Select **Platform Administration**, then **Identity**.
1. Under **Management**, select **Authorization**.
1. Select **Add Client**.
1. In **Select Client Type**, select **GeneralApiClient**.
1. Enter a **Description** that names the integration, for example `ServiceNow production`.
1. In **Select Access Scopes**, select the access level the integration needs: **Read**, **Manage**, or **Admin**.
1. Leave **Encrypted authorization client** cleared. An encrypted client gives you an encrypted text instead of a client ID and secret that your application can use.
1. Select **Save**.
1. In the **Secret Key** dialog, copy the **Client ID** and **Secret Key**, or select **Download** to save both in a `.json` file.

:::warning[Store the secret safely]
Keep the secret in a secret manager or an environment variable, and never hardcode it in source or commit it to a repository. If you lose the secret, select the client on the **Authorization** page and select **Reset Secret**. The previous secret stops working, so update every application that uses it.
:::

The client ID starts with `openlm.external.api.` and ends with your customer ID. To change the access level of an integration, create a new client with the level you need, move the integration to it, then select the old client and select **Delete**.

To keep the values for the next steps, export them as environment variables:

```bash
export OPENLM_CLIENT_ID="<your-client-id>"
export OPENLM_CLIENT_SECRET="<your-secret-key>"
export OPENLM_IDENTITY_URL="https://cloud-us.openlm.com/identity"
export OPENLM_GATEWAY_URL="https://cloud-us.openlm.com/api/externalapigateway"
```

## Request an access token

To request a token, send a `POST` to the token endpoint of the Identity Server with `grant_type=client_credentials`. Set `scope` to the access level you chose for the client.

```bash
curl -X POST "$OPENLM_IDENTITY_URL/connect/token" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "grant_type=client_credentials" \
  -d "client_id=$OPENLM_CLIENT_ID" \
  -d "client_secret=$OPENLM_CLIENT_SECRET" \
  -d "scope=api.read"
```

The response contains the access token:

```json
{
  "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6...",
  "expires_in": 3600,
  "token_type": "Bearer",
  "scope": "api.read"
}
```

Keep the `access_token` value for your requests. The token endpoint is also listed as `token_endpoint` in the discovery document at `{IDENTITY_URL}/.well-known/openid-configuration`.

### Token lifetime

Access tokens are valid for 1 hour (3,600 seconds, the `expires_in` value). The client-credentials flow doesn't issue refresh tokens. Cache the token, reuse it for every request, and request a new one shortly before it expires rather than before every request.

## Send your first request

Send the token in an `Authorization: Bearer` header on every request. Most requests go to the GraphQL endpoint, `{BASE_URL}/api/externalapigateway/graphql`.

This request reads the first 25 license usage records of your account:

```bash
curl -X POST "$OPENLM_GATEWAY_URL/graphql" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "query": "{ licenseUsage(first: 25) { totalCount nodes { user_name feature_name vendor start_time_utc } } }" }'
```

`licenseUsage` is a Reporting Data API query. The gateway accepts it with the same arguments and fields that [Query the Reporting Data API](https://www.openlm.com/documentation/cloud/api/reporting-api-queries) describes.

AI Reporting insights also have REST endpoints. This request lists the licenses with no use in more than 60 days:

```bash
curl "$OPENLM_GATEWAY_URL/insights/licenses/idle?idle_days=60" \
  -H "Authorization: Bearer $ACCESS_TOKEN"
```

For every endpoint and operation, see [External API Gateway reference](https://www.openlm.com/documentation/cloud/api/external-api-gateway-reference).

### Combine queries in one request

To read data from several services at once, put their queries in one GraphQL request. The gateway sends each part to its service and returns one combined reply. The following rules apply:

- If any part fails, the reply carries the error and no data from any service.
- The whole request needs the highest access level that any of its queries needs.
- Only queries can be combined. A mutation must be in a request that stays within one service.
- Two parts can't return the same response key. Give them distinct aliases.

## Troubleshooting

The following table lists common problems, their causes, and fixes. For every error code the gateway returns, see [Errors](https://www.openlm.com/documentation/cloud/api/external-api-gateway-reference#errors).

| Symptom | Likely cause | Fix |
| :---- | :---- | :---- |
| `400 invalid_client` from the token endpoint | Wrong client ID or secret, or the client belongs to the other region. | Check both values, and request the token from the Identity Server of the region where you created the client. |
| `400 invalid_scope` from the token endpoint | The requested `scope` isn't an access level of the client, or the client was created without one. | Request the scope of the access level you chose. If the client has none, create a new client and select an access level. |
| `401 Unauthorized` from the gateway | The token is missing or expired, or it comes from a client of another type, such as **ReportingDataApi**. | Request a new token with a **GeneralApiClient** client, and send it in the `Authorization: Bearer <token>` header. |
| `403` with `Access denied. Operation requires '<level>' access level` | The client's access level is lower than the operation needs. | Use a client with the level the message names. |
| `403` with `Operation '<name>' is not permitted through this gateway` | The operation name is misspelled, or the gateway doesn't offer that operation. | Check the name in [External API Gateway reference](https://www.openlm.com/documentation/cloud/api/external-api-gateway-reference). |
| `429` with `RATE_LIMITED` | The client sent more requests than its limit allows. | Wait for the number of seconds in the `Retry-After` header, then retry. |
| Requests work, then fail after about 1 hour | The token expired. | Request a new token. |

## Related pages

For more information, see these pages:

- [External API Gateway reference](https://www.openlm.com/documentation/cloud/api/external-api-gateway-reference): endpoints, operations, access levels, limits, and errors.
- [Query the Reporting Data API](https://www.openlm.com/documentation/cloud/api/reporting-api-queries): the report queries, their arguments, and CSV exports.
- [Generate an authorization file](https://www.openlm.com/documentation/cloud/getting-started/authorize-components/): the **Authorization** page of Identity, where you also create clients for installed components.
