---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.2
alternate:
  - https://yandex.com/dev/direct/doc/dg-v4/en/reference/CreateInvoice.md
  - https://yandex.com/dev/direct/doc/dg-v4/ru/reference/CreateInvoice.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/direct/doc/dg-v4/en/llms.txt

# CreateInvoice
Generates an invoice for one or more campaigns in HTML format.

{% note alert %}

Disabled method. Use version 5 of the API.

For information about the compatibility of methods between versions 4 and 5, see the [Migration guide](https://yandex.com/dev/direct/doc/migration/concepts/methods.md).

{% endnote %}


The [CreateInvoice (Live)](https://yandex.com/dev/direct/doc/dg-v4/en/live/CreateInvoice.md) version also exists for this method.

When calling this method, specify one or more campaigns and the amounts to pay that should be shown in the invoice. The method returns the URL of the invoice. Only the user who the method was called on behalf of can access the invoice (the user must log in on Yandex).


{% note alert %}

Direct advertisers can generate an invoice only when the campaign 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/campaign.md)

{% endnote %}


We recommend generating invoices using as few calls of the `CreateInvoice` 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 generate one invoice for several campaigns at once than to generate separate invoices by calling the method multiple times.

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/reference/PayCampaigns.md)).

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


## 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": "CreateInvoice",
   "finance_token": (string),
   "operation_num": (int),
   "param": {
      /* CreateInvoiceInfo */
      "Payments": [
         {  /* PayCampElement */
            "CampaignID": (int),
            "Sum": (float)
         }
         ...
      ]
   }
}
```

Parameters are described below.


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

||
**<sub >CreateInvoiceInfo object</sub>**
||
||
`Payments`
|
Array of `PayCampElement` objects. Each object specifies the campaign and the amount to be displayed in the payment invoice.
|
Yes
||

||
**<sub >PayCampElement object</sub>**
||
||
`CampaignID`
|
The campaign ID.
|
Yes
||
||
`Sum`
|
The amount in Yandex units to be displayed in the payment invoice.
|
Yes
||
|#


## Output data {#output}

If successful, the method returns the URL for the invoice, as shown below. If unsuccessful, an error message is returned.

```javascript
{
   "data": "https://passport.yandex.ru/passport?mode=subscribe&from=balance&retpath=http%3A%2F%2Fbalance.yandex.ru%2Fpaypreview.xml%3Frequest_id%3D14062489%26ref_service_id%3D7%26ui_type%3Dstd"
}
```


## Examples of input data {#examples}

## Python

```python
{
   'Payments': [
      {'CampaignID': 3193279, 'Sum': 500.0}
      {'CampaignID': 3193244, 'Sum': 1200.0}
   ]
}
```

## PHP

```php
array(
   'Payments' => array(
      array('CampaignID' => 3193279,'Sum' =500.0)
      array('CampaignID' => 3193244,'Sum' =1200.0)
   )
)
```

## Perl

```perl
{
   'Payments' => [
      {'CampaignID' => 3193279, 'Sum' =500.0}
      {'CampaignID' => 3193279, 'Sum' =1200.0}
   ]
}
```


