# Balance and Payment API

{% hint style="info" %}
This document describes how to get the current balance for affiliates and make payments/adjustments via API.
{% endhint %}

{% hint style="danger" %}
The default API URL is **<https://boapi.smartico.ai/>** but depending on your setup it could be different. Check for the exact URL in the '***Settings***' section.
{% endhint %}

TheAffiliatePlatform (TAP) provides API to get the current balance of the affiliates and make payments. API is provided as a REST over HTTP and uses SSL for data protection.

## Getting balances for all affiliates

Operator API is similar to the Affiliate API.

Example of the API call using CURL:

{% code overflow="wrap" %}

```bash
curl --location --request GET 'https://boapi.smartico.ai/api/af2_balance_op?filter={"above_threshold":true,"to":"2025-04-30T23:59:59Z"}&range=[0,9]' \
--header 'Authorization: cc1a4c56-44de-11ed-a835-04d6e06175364b-2354'
```

{% endcode %}

The parameter **above\_threshold,** when set to true, will filter only affiliates that have a positive balance (or balance above the threshold set on the operation level).  \
The parameter **to** will filter only the due balances until a specific date.\
\
You can also pass **affiliate\_id** as the parameter to get results only for a specific affiliate.

The API is returning a list of affiliates with details for each one. The most important parameters are:

* affiliate\_id
* balance - the current, not paid commission for this affiliate
* commissions\_total - total lifetime commission earned by the affiliate
* payments - already paid amount
* threshold - the minimal amount in the operator currency that the operator is going to pay to the affiliate (above\_threshold parameter is using this value for the filter)

Example of full response

{% code lineNumbers="true" %}

```json
[
    {
        "id": 35427,
        "affiliate_id": 35427,
        "affiliate_name": "Master",
        "payment_method_details": {
            "bank_name": "ggg",
            "beneficary": "gggg",
            "swift_code": "g",
            "back_country": "ggg",
            "erc20_wallet": "11111",
            "paypal_email": "1223564",
            "trc20_wallet": "12345",
            "account_number": "ggg"
        },
        "aff_status_id": 2,
        "payments": 482375.82,
        "last_payment_date": "2024-02-26T12:36:48.147Z",
        "adjustments": 10440.71052180003,
        "cpl_fee": 0,
        "cpa_fee": 216349,
        "rev_share_fee": 295535.57972609997,
        "sub_affiliate_fee": 0,
        "deposit_amount": 3510143.7671,
        "ftd_amount": 85595.6949,
        "deposit_count": 27908,
        "ftd_count": 47404,
        "registrations_count": 28670,
        "payment_method_id": 4,
        "payment_method_name": "PayPal",
        "auto_payment_enabled": null,
        "manager_id": 56427,
        "treshold": 300,
        "not_processed_payment_amount": 1,
        "create_date": "2022-03-10T18:44:52.983Z",
        "commissions_total": 511884.57972609997,
        "balance": 39949.47024789999,
        "operator_currency": "EUR",
        "user_id": 56427,
        "manager": "luana@smartico",
        "manager_contacts": {
            "phone": "",
            "email": "support@smartico.ai",
            "skype": "some",
            "telegram": "",
            "fb": "",
            "vk": "",
            "discord": null,
            "whatsapp": null,
            "first_name": "Luana",
            "last_name": "T"
        }
    },
    {
        "id": 217628,
        "affiliate_id": 217628,
        "affiliate_name": "Sevginar test",
        "payment_method_details": {
            "ana": "aaa",
            "istpay_cpf": "1234567",
            "pay4fun_cpf": "1234567",
            "trc20_wallet": "123456",
            "netteller_vat": "12233112",
            "netteller_email": "support@smartico.ai",
            "netteller_account_number": "123123"
        },
        "aff_status_id": 2,
        "payments": 20,
        "last_payment_date": "2024-03-28T13:58:23.826Z",
        "adjustments": 20,
        "cpl_fee": 0,
        "cpa_fee": 30,
        "rev_share_fee": 5496.5585835,
        "sub_affiliate_fee": 0,
        "deposit_amount": 69.9572,
        "ftd_amount": 34.9786,
        "deposit_count": 2,
        "ftd_count": 1,
        "registrations_count": 1,
        "payment_method_id": 2,
        "payment_method_name": "Neteller",
        "auto_payment_enabled": null,
        "manager_id": 99327,
        "treshold": 0,
        "not_processed_payment_amount": 1,
        "create_date": "2024-01-16T08:59:13.062Z",
        "commissions_total": 5526.5585835,
        "balance": 5526.5585835,
        "operator_currency": "EUR",
        "user_id": 99327,
        "manager": "support@smartico",
        "manager_contacts": {
            "phone": "",
            "email": "support@smartico.ai",
            "skype": "",
            "telegram": "",
            "fb": "",
            "vk": "",
            "discord": "",
            "whatsapp": null,
            "first_name": "Priscila",
            "last_name": "C"
        }
    }
]
```

{% endcode %}

## Making the payment through the API

Example of the request with the CURL:

```bash
curl --location --request POST 'https://boapi.smartico.ai/api/af2_payments_op' \
--header 'Authorization: cc1a4c56-44de-11ed-a835-04d6e06175364b-2354' \
--header 'Content-Type: application/json' \
--data-raw '{
    "affiliate_id": 35426,
    "amount": 1,
    "send_mail_to_aff": false,
    "operator_comments": "Here are internal comments that will be NOT visible for the affiliate",
    "payment_details": "Here are public comments that will be visible for the affiliate"
}'
```

Passed parameters:

* amount - is the amount in the operator currency
* send\_mail\_to\_aff - if set to 'true', will trigger automatic mail to the affiliate that payment is made (mail template & operational campaign need to be set up in the TAP BackOffice)
* optionally can be passed 2 parameters - period\_from & period\_to as a UNIX second from the epoch, indicating the period for the payment

Example of response

```json
{
    "id": 15561,
    "payment_id": 15561,
    "amount": 1,
    "affiliate_id": 35426,
    "payment_details": "Here are public comments that will be visible for the affiliate",
    "create_by": 1,
    "create_date": "2022-11-23T13:17:08.637Z",
    "period_from": "2022-11-23T13:17:08.397Z",
    "period_to": "2022-11-23T13:17:08.397Z",
    "operator_comments": "Here are internal comments that will be NOT visible for the affiliate",
    "payment_date": "2022-11-23T13:17:08.397Z",
    "payment_status_id": 4,
    "operator_currency": "EUR",
    "affiliate_name": "mattfff",
    "payment_method_id": 0,
    "payment_method_details": {},
    "username": "gik",
    "payment_status_name": "Paid",
    "manager_id": 2342,
    "payment_name": "mattfff - 1 EUR"
}
```

## Making adjustment to affiliate's balance

Example of the request with the CURL:

```bash
curl --location --request POST 'https://boapi.smartico.ai/api/af2_adjustments_op' \
--header 'Authorization: cc1a4c56-44de-11ed-a835-04d6e06175364b-2354' \
--header 'Content-Type: application/json' \
--data '{ 
     "affiliate_id": 348678, 
     "adjustment_type_id": 5, 
     "amount": -11
}'
```

Passed parameters:

* affiliate\_id
* adjustment\_type\_id  - always use **value 5** to ensure
* amount - can be positive or negative value


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.theaffiliateplatform.com/apis-and-configurations/balance-and-payment-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
