Uploading expenses as multipart/form-data

Uploads expenses.

Warning

The Yandex Direct data is sent to Yandex Metrica automatically, so you don't have to upload it manually. Uploading a data file will create duplicates with the automatically sent data, making the report incorrect.

Data is passed as multipart/form-data in the file parameter in CSV format. In the first line of the request, pass the names of the columns.

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 if TrafficSource is 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_medium label value.
  • UTMCampaign: String, utm_campaign label 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. You need to remember this when you upload or delete data.

Request

POST

https://api-metrika.yandex.net/management/v1/counter/{counterId}/expense/upload

Path parameters

Name

Description

counterId*

Type: integer<int32>

ID of the counter for which you want to upload expenses.
Example: 2215573

Query parameters

Name

Description

comment

Type: string

Comment.

provider

Type: string

A service that sends data to Yandex Metrica (provider). If not set, the value default is used.

Body

multipart/form-data
{
    "file": null
}

Name

Description

file*

Type: string<binary>

Responses

200 OK

OK

Body

application/json
{
    "uploading": {
        "id": 0,
        "create_time": "2022-12-29T18:02:01Z",
        "source_quantity": 0,
        "provider": "string",
        "comment": "string",
        "type": "string",
        "status": "string"
    }
}

Name

Description

uploading*

Type: ExpenseUploading

Information about expense uploads.

ExpenseUploading

Information about expense uploads.

Name

Description

comment

Type: string

Comment.

create_time

Type: string<date-time>

Upload time.

id

Type: integer<int64>

Upload ID.

provider

Type: string

Data provider name.

source_quantity

Type: integer<int32>

Number of rows in the source file.

status

Type: string

Upload status:

  • UPLOADED: Upload complete.
  • IN_PROGRESS: Upload in progress.
  • PROCESSED: Upload processed.

type

Type: string

Upload type:

  • EXPENSES: Expenses.
  • REMOVES: Deleting expenses.

No longer supported, please use an alternative and newer version.