# Authentication

## Overview
Authentication is required to access the partners API. Clients must include the correct API key and API secret in the request headers for each API call.

## Obtaining API Credentials
To access the API, you must retrieve your API key and secret from the Partners Platform API Security page.

1. Log in to the [**Partners Platform**](https://partners.service.cedar.money/).
2. Navigate to **API** > [**API Security**](https://partners.service.cedar.money/app/api/security).
3. Generate or retrieve your **API Key** and **API Secret**.
4. Use these credentials in your API requests as described below.

## IP Whitelisting
To ensure secure access, the API requires IP whitelisting. Only requests originating from approved IP addresses will be allowed.

### Configuring IP Whitelisting
1. Log in to the [**Partners Platform**](https://partners.service.cedar.money/).
2. Navigate to **API** > [**API Security**](https://partners.service.cedar.money/app/api/security).
3. Locate the **IP Whitelisting** configuration.
4. Add the necessary IP addresses that should have access.
5. Save the changes to apply the whitelist settings.

Ensure that your requests originate from an approved IP address to avoid authentication failures.

## Request Headers
To authenticate API requests, include the following headers:

- **x-api-key**: The API key assigned to your application.
- **x-api-secret**: The API secret associated with your API key.

Example headers:
```plaintext
x-api-key: CEDAR_DEV_api_key_cc77406f-06e1-4f83-a5f3-def6128e4ce2
x-api-secret: CEDAR_DEV_api_secret_RvDAeLtIF9kik17sds0TYEnPLlhvHjBDZ6yutIgK52BvQj5aR1caA7HF6Vzk9JD6sJHb8Tl9I6WzWdgwiIi5TC8cYgD4yydBIQy4
```

## Example Request
A sample cURL request demonstrating authentication:

```bash
curl -X GET "https://partners-server.service.cedar.money/ resource" \
  -H "x-api-key: CEDAR_DEV_api_key_cc77406f-06e1-4f83-a5f3-def6128e4ce2" \
  -H "x-api-secret: CEDAR_DEV_api_secret_RvDAeLtIF9kik17sds0TYEnPLlhvHjBDZ6yutIgK52BvQj5aR1caA7HF6Vzk9JD6sJHb8Tl9I6WzWdgwiIi5TC8cYgD4yydBIQy4"
```

## Authentication Failure Responses
If authentication fails due to missing or incorrect credentials, the API will return an appropriate HTTP status code and error message.

- **400 Bad Request**: Missing or invalid API key/secret.
- **403 Forbidden**: Authentication succeeded but access to the resource is denied.

Example error response:
```json
{
   "exception":{
      "errorCode":"API_KEY_MISSING",
      "message":"API key missing"
   }
}
```

## Security Recommendations
- Keep your API key and secret confidential.
- Rotate credentials periodically for security. Rotating credentials is available at the partners platform.
- Use HTTPS to encrypt API requests and responses.




