Uploading expenses as multipart/form-data
Uploads expenses.
Warning
You don’t need to upload Yandex Direct data — it is transmitted to Yandex Metrica automatically. If you upload a file with the data, it will duplicate the automatically transmitted data and the report will become incorrect.
Data is passed as multipart/form-data in the file parameter in CSV format. You must pass the column names in the first line of the request.
Required columns:
Date: String, a date in YYYY-MM-DD format or a range of dates in YYYY-MM-DD/YYYY-MM-DD format.UTMSource: String, utm_source label value. Optional ifTrafficSourceis passed.TrafficSource: First-level traffic source. Acceptable values are given in the table.Expenses: Number, amount of expenses, with a full stop (.) as the decimal separator.
Optional columns:
TrafficSourceDetail: Second-level traffic source. Acceptable values are given in the table.UTMMedium: String,utm_mediumlabel value.UTMCampaign: String,utm_campaignlabel value.UTMTerm: String, utm_term label value.UTMContent: String, utm_content label value.Currency: String, a three-letter ISO 4217 currency code.Clicks: Number, click count.
Note
The values of UTM tags are case-sensitive. Keep this in mind when uploading and deleting data.
Request
POST
https://api-metrika.yandex.net/management/v1/counter/{counterId}/expense/upload
Path parameters
|
Name |
Description |
|
counterId |
Type: integer ID of the counter for which you want to upload expenses. |
Query parameters
|
Name |
Description |
|
comment |
Type: string Comment. Example: `` |
|
provider |
Type: string A service that transmits data to Yandex Metrica (provider). If not set, the value Example: `` |
Body
multipart/form-data
{
"file": "example"
}
|
Name |
Description |
|
file |
Type: string<binary> Example: |
Responses
200 OK
OK
Body
application/json
{
"uploading": {
"id": 0,
"create_time": "2025-01-01T00:00:00Z",
"source_quantity": 0,
"provider": "example",
"comment": "example",
"type": "example",
"status": "example"
}
}
|
Name |
Description |
|
uploading |
Type: ExpenseUploading Information about expense uploads. Example
|
ExpenseUploading
Information about expense uploads.
|
Name |
Description |
|
comment |
Type: string Comment. Example: |
|
create_time |
Type: string<date-time> Upload time. Example: |
|
id |
Type: integer Upload ID. |
|
provider |
Type: string Data provider name. Example: |
|
source_quantity |
Type: integer Number of rows in the source file. |
|
status |
Type: string Upload status:
Example: |
|
type |
Type: string Upload type:
Example: |
Example
{
"id": 0,
"create_time": "2025-01-01T00:00:00Z",
"source_quantity": 0,
"provider": "example",
"comment": "example",
"type": "example",
"status": "example"
}