> For the complete documentation index, see [llms.txt](https://docs.geniesolutions.io/genie-partner-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.geniesolutions.io/genie-partner-api/tutorials-and-examples/machine-to-machine-authentication/setup-and-config.md).

# Setup and Config

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

The key variables you will need to do requests to the Partner API are `API_URL`,`API_KEY AUTH_URL, TOKEN_URL, CLIENT_ID, CLIENT_SECRET, SCOPES`

### Steps <a href="#steps" id="steps"></a>

1. Request tokens: From the authorized application, request an Access Token for your API.
2. Call API: Use the retrieved Access Token to call your API.

#### Example of requesting token:

```
curl --request POST \
  --url 'https://TOKEN_URL/oauth2/token' \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data grant_type=client_credentials \
  --data client_id=CLIENT_ID \
  --data client_secret=CLIENT_SECRET \
  --data scope="<scopes>"
```

#### Example response:

If all goes well, you'll receive an `HTTP 200` response with a payload containing `access_token`, `token_type`, and `expires_in` values:

```
{
  "access_token": "eyJz93a...k4laUWw",
  "token_type": "Bearer",
  "expires_in": 86400
}
```

#### Call API

To call the Partner API the application must pass the retrieved Access Token as a Bearer token in the Authorization header of your HTTP request:

```
curl --request GET \
  --url https://<API_URL>/EligibilityRequest \
  --header 'authorization: Bearer ACCESS_TOKEN' \
  --header 'content-type: application/json'
  --header 'x-api-key: API_KEY'
```
