---
title: "How to Consume an API (Client Credentials)"
description: "Exchange your client credentials for a short-lived access token and call the 9fin API."
url: "https://console.9fin.com/getting-started-consume-api"
image: "https://console.9fin.com/_og/d/c_Ocean.takumi,title_How+to+Consume+an+API+(Client+Credentials),description_Exchange+your+client+credentials+for+a+short-lived+access+token+and+call+the+9fin+API.,props_eyJ0aGVtZSI6eyJtb2RlIjoibGlnaHQiLCJjb2xvcnMiOnsicHJpbWFyeSI6IiMwOTVDRUYifX19,p_Ii9nZXR0aW5nLXN0YXJ0ZWQtY29uc3VtZS1hcGki,s_FF-BSjLTTziytAL2.png"
---

## How to Consume an API (Client Credentials)

Exchange your client credentials for a short-lived access token and use it to call the 9fin API.

## [Authentication during the transition](#authentication-during-the-transition)

9fin is transitioning its APIs from static API keys to a client-credentials authentication strategy. During this transition, some APIs will continue to use API keys, while others will require a `client_id` and `client_secret`.

Follow the authentication method documented for the API you are consuming:

-   If you were issued an **API key**, continue to use the API key authentication flow.
-   If you were issued a **client ID and client secret**, follow the client-credentials flow on this page.

With client-credentials authentication, you exchange your `client_id` and `client_secret` for a short-lived access token. You then send that token as a bearer credential when calling the API.

The **client secret** is the long-lived credential and does not expire unless it is rotated or revoked. The **access token** is short-lived and remains valid for one hour.

---

## [1\. Get your credentials](#_1-get-your-credentials)

1.  **Sign in to the [Kong Dev Portal](https://console.9fin.com/)** using your external developer account.
2.  **Create an application** from [My Applications](https://console.9fin.com/apps).
3.  **Copy your `client_id` and `client_secret` when they are displayed.** The client secret is shown only once, when the application is created.

Store your client secret securely. Do not include it in source code, logs, or client-side applications.

---

## [2\. Exchange your credentials for an access token](#_2-exchange-your-credentials-for-an-access-token)

Token endpoint:

`https://api.9fin.com/oauth/token`

```bash
CLIENT_ID='<from the Dev Portal>'
CLIENT_SECRET='<from the Dev Portal>'

TOKEN=$(curl -sS -X POST \
  https://api.9fin.com/oauth/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  -d grant_type=client_credentials \
  | jq -r '.access_token')
```

The `-u` option sends the credentials using `client_secret_basic`.

`client_secret_post` is also supported. To use it, send the credentials in the request body instead:

```bash
TOKEN=$(curl -sS -X POST \
  https://api.9fin.com/oauth/token \
  -d grant_type=client_credentials \
  -d client_id="$CLIENT_ID" \
  -d client_secret="$CLIENT_SECRET" \
  | jq -r '.access_token')
```

Do not send `scope=openid`. Although the authentication strategy declares it, the `client_credentials` grant rejects it.

A successful response looks like this:

```json
{
  "access_token": "...",
  "expires_in": 3600,
  "token_type": "bearer"
}
```

---

## [3\. Call the API](#_3-call-the-api)

Send the access token in the `Authorization` header:

```bash
curl -sS \
  -H "Authorization: Bearer $TOKEN" \
  https://api.9fin.com/<api-path>
```

---

## [4\. Refresh the token](#_4-refresh-the-token)

Access tokens remain valid for **one hour** (`expires_in: 3600`).

**There is no refresh token.** The `client_credentials` grant does not issue one, so the response will not contain a `refresh_token` field. To obtain a new access token, repeat step 2.

Refresh the token proactively—about one minute before it expires—instead of waiting for a `401` response. This helps prevent intermittent failures caused by clock skew or requests that are still in flight when the token expires.