---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/direct/doc/dg-v4/en/live/PayCampaigns.md
  - https://yandex.com/dev/direct/doc/dg-v4/ru/live/PayCampaigns.md
  - href: en/live/PayCampaigns.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/direct/doc/dg-v4/en/llms.txt

# PayCampaigns (Live)
Paying for campaigns using an advertising agency's credit limit, or the advertiser's overdraft.
This method allows advertising agencies and direct advertisers to add funds to the campaign balance with deferred payment (see [Paying by credit and overdraft](https://yandex.com/dev/direct/doc/dg-v4/en/concepts/finance.md)).


{% note alert %}

Direct advertisers can pay for a campaign only when it has been approved by a moderator (see the campaign parameter StatusModerate).

{% endnote %}


## Recommendations and restrictions


{% note alert %}

All campaigns specified in the same method call must be of the same type. [More information about campaign types](https://yandex.com/dev/direct/doc/dg/objects/ad.htmlcampaign.md)

{% endnote %}


We recommend paying for campaigns using as few calls of the `PayCampaign` method per day as possible. This recommendation is aimed at improving the performance of the Yandex Direct API. In terms of productivity, it is better to pay for several campaigns at once using a single method call than to make multiple calls to pay for each campaign individually.

Restrictions on method calls:

- A single user can call the method 1000 times per day.
- A single campaign can have no more than 30 transactions per day, including generating invoices ([CreateInvoice (Live)](https://yandex.com/dev/direct/doc/dg-v4/en/reference/CreateInvoice.md)), transferring funds ([TransferMoney (Live)](https://yandex.com/dev/direct/doc/dg-v4/en/reference/TransferMoney.md)), and delayed payment ([PayCampaigns](https://yandex.com/dev/direct/doc/dg-v4/en/live/PayCampaigns.md)).

Exceeding these limits results in the error [56](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#ErrorCode56).

## Currency restrictions


{% note alert %}

There is no provision for paying for multiple campaigns in different currencies using a single method call.

{% endnote %}


All campaigns specified in the same method call must be in the same currency.

Payment amounts (the Sum parameter) should be specified in the campaign currency (by setting the corresponding value for the Currency parameter). All amounts must be specified in the same currency.

## New in the Live 4 version

The Currency input parameter is required.

Added the “Overdraft” payment method (the PayMethod parameter).

Added the Currency input parameter.


## Input data {#input}

The input data structure in JSON is shown below.


{% note alert %}

It is mandatory to include the `finance_token` and `operation_num` parameters in the request. For more information, see the [Accessing finance methods](https://yandex.com/dev/direct/doc/dg-v4/en/concepts/finance-token.md).

{% endnote %}


```javascript
{
   "method": "PayCampaigns",
   "finance_token": (string),
   "operation_num": (int),
   "param": {
      /* PayCampaignsInfo */
      "Payments": [
         {  /* PayCampElement */
            "CampaignID": (int),
            "Sum": (float),
            "Currency": (string)
         }
         ...
      ],
      "ContractID": (string),
      "PayMethod": (string)
   }
}
```

Parameters are described below.


#|
||
**<sup >Parameter</sup>**
|
**<sup >Description</sup>**
|
**<sup >Required</sup>**
||

||
**<sub >PayCampaignsInfo object</sub>**
||
||
`Payments`
|
Array of `PayCampElement` objects. Each object indicates the campaign and payment amount.
|
Yes
||
||
`ContractID`
|
The number of the credit agreement.
|
For advertising agencies
||
||
`PayMethod`
|
Campaign payment method:

- Bank — Payment by credit (for advertising agencies).
- Overdraft — Payment by overdraft (for direct advertisers).
|
Yes
||

||
**<sub >PayCampElement object</sub>**
||
||
`CampaignID`
|
The campaign ID.
|
Yes
||
||
`Sum`
|
The payment amount in the currency specified in the `Currency` parameter. When creating an invoice, the amount is rounded mathematically to the second decimal place (for all currencies, including the tenge).

The value in the real currency must include the client's VAT.

To get the minimum acceptable value, use the [Dictionaries](https://yandex.com/dev/direct/doc/ref-v5dictionaries/dictionaries.md).[get](https://yandex.com/dev/direct/doc/ref-v5dictionaries/get.md) method for version 5 of the API and specify the dictionary name `Currencies` in the request.
|
Yes
||
||
`Currency`
|
The currency that the amount is shown in.

Acceptable values: RUB, CHF, EUR, KZT, TRY, UAH, USD, BYN. The value must match the campaign currency; otherwise, an error is returned with code [245](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#BadCurrency).
|
Yes
||
|#


## Output data {#output}

Returns 1 if successful, as shown in the following example.

```javascript
{
   "data": 1
}
```

For an invalid request, possible error codes are [245](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#BadCurrency), [355](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#errorCode355), [356](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#errorCode355), [357](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#errorCode357), [363](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#errorCode363), and [364](https://yandex.com/dev/direct/doc/dg-v4/en/reference/ErrorCodes.md#errorCode364).


## Examples of input data {#examples}

## Python

```python
{
   'Payments': [
      {'CampaignID': 3193279, 'Sum': 50000.0, 'Currency': 'RUB'},
      {'CampaignID': 3193244, 'Sum': 1200.0, 'Currency': 'RUB'}
   ],
   'ContractID': '23452345/67',
   'PayMethod': 'Bank'
}
```

## PHP

```php
array(
   'Payments' => array(
      array('CampaignID' => 3193279, 'Sum' => 50000.0, 'Currency' => 'RUB'),
      array('CampaignID' => 3193244, 'Sum' => 1200.0, 'Currency' ='RUB')
   ),
   'ContractID' => '23452345/67',
   'PayMethod' ='Bank'
)
```

## Perl

```perl
{
   'Payments' => [
      {'CampaignID' => 3193279, 'Sum' => 50000.0, 'Currency' => 'RUB'},
      {'CampaignID' => 3193279, 'Sum' => 1200.0, 'Currency' ='RUB'}
   ],
   'ContractID' => '23452345/67',
   'PayMethod' ='Bank'
}
```


