# Affiliate API Overview

> How to integrate the Roamify Affiliate API and earn commissions on every sale made through your referral links.

Canonical: https://docs.getroamify.com/affiliate/overview/

## Affiliate Overview
Roamify Affiliate API for a partner is straightforward and easy to use.
You only need to follow a few steps to integrate Roamify Affiliate API into your application and start earning commissions on every sale you make.

> **Warning:** Customer must click your referral link to be able to track the sale and reward you with the commission regardless of promo code used.

- <strong>Step 1: Authentication</strong>: You need to have your Access Token to make requests to Roamify eSIM API. You can get your Access Token from [Roamify Partner Portal](https://partner.getroamify.com/sign-in).
- <strong>Step 2: Get eSIM Packages</strong>: You will be assigned a dedicated endpoint to get a list of eSIM packages, which includes all available eSIM packages and your referral link for each package.
- <strong>Step 3: Present to Customers</strong>: You can present the eSIM packages to your customers using the referral link you received in the previous step.
- <strong>Step 4: Track rewards</strong>: You can track your rewards in the Roamify Partner Portal. You will see how many sales you made, how much commission you earned, and more.

## Recommended steps to use Affiliate API

### Step 1: Authentication
You need to have your Access Token to make requests to Roamify eSIM API. You can get your Access Token from [Roamify Partner Portal](https://partner.getroamify.com/sign-in).

If you don't have an account, you can sign up [here](https://partner.getroamify.com/sign-up) or contact us at [support@getroamify.com](mailto:support@getroamify.com).

Our token is a Bearer token, which means you need to include it in the `Authorization` header of your requests.

### Step 2: Get eSIM Packages
With your dedicated endpoint, you can get a list of eSIM packages that are available for you to promote.

You need to send a `GET` request to the `/api/esim/{partnerSlug}/packages` endpoint.

This endpoint will return a list of all available eSIM packages with referral links for each package.

The referral link will include your unique identifier, which will be used to track the sales you make.

#### Usage - how to get eSIM packages
Here is an example of how you can get a list of eSIM packages using Roamify eSIM API.

**curl**

```bash
curl --request GET \
--url 'https://api-dev.getroamify.com/api/esim/esimradar/packages' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json'
```

**javascript**

```javascript
const axios = require('axios');

axios.get('https://api-dev.getroamify.com/api/esim/esimradar/packages', {
    headers: {
        'Authorization': 'Bearer {access token here}',
        'Content-Type': 'application/json'
    }
})
.then(response => {
    console.log(response.data);
})
.catch(error => {
    console.error(error);
});
```

You can read more about this endpoint [here](https://docs.getroamify.com/affiliate/affiliate-links/).

### Step 3: Present to Customers
Once you have the list of eSIM packages, you can then find each country's eSIM options in the packages array of the response.

- <strong className={"text-red-500"}>Red box</strong> indicates the country name and code.
- <strong className={"text-yellow-500"}>Yellow box</strong> indicates the eSIM packages available for that country.
- <strong className={"text-blue-500"}>Blue box</strong> indicates the referral link for each package.

![eSIM Packages](https://imagedelivery.net/uUE6LNs_ci8SFBH4_n66dQ/docs/affiliate-response/public)

### Step 4: Track rewards
You can track your rewards in the Roamify Partner Portal. You will see how many sales you made, how much commission you earned, and more.

- <strong className={"text-red-500"}>Red box</strong> click to withdraw your earnings.
- <strong className={"text-yellow-500"}>Yellow box</strong> click to view your earnings history.
- <strong className={"text-blue-500"}>Blue box</strong> click to add or update your bank account details for payouts.

![eSIM Packages](https://imagedelivery.net/uUE6LNs_ci8SFBH4_n66dQ/docs/affiliate-reward/public)

### The End
That's it! You have successfully integrated Roamify Affiliate API into your application. If you have any questions or need help, feel free to contact us at [support@getroamify.com](mailto:support@getroamify.com).
