Uploading orders (JSON)

Uploads orders.

The data is submitted within the POST request body in JSON format. Learn more about the format of transmitted data.

For Yandex Metrica to process information about orders, you need to transmit customer data. Yandex Metrica links customer information to sessions, and order data to sessions and customers. This is required to calculate and display statistics.

Note

You can transmit data for up to 100,000 orders per customer.

Sample request body
--data '{
        "orders": [
            {
                "id": "704",
                "client_uniq_id": "J3QQ4-H7H2V-2HCH4-M3HK8-6M8VW",
                "client_type": "CONTACT",
                "order_status": "IN_PROGRESS",
                "create_date_time": "2022-09-21 09:48:23",
                "update_date_time": "2022-10-15 10:48:34",
                "cost": 4000,
                "revenue": 5000,
                "goals": [
                        {
                            "goal_action_id": "goal_id1",
                            "price": 123.5
                        }
                ],
                "products": {
                    "pear": 10,
                    "apple": 30
                }
            },
            {
                "id": "706",
                "client_uniq_id": "ZYX4-H7H2V-2HCH4-M3HK8-6M8VW",
                "client_type": "CONTACT",
                "order_status": "PAID",
                "create_date_time": "2022-09-30 10:48:23",
                "cost": 10000,
                "revenue": 13000,
                "goals": [
                        {
                            "goal_action_id": "goal_id2",
                            "price": 123.5
                        }
                ],
                "products": {
                    "apple": 30,
                    "cherry": 20
                }
            }
        ]
}'

Request

POST

https://api-metrika.yandex.net/cdp/api/v1/counter/{counterId}/data/orders/json

Path parameters

Name

Description

counterId

Type: integer

ID of the counter for which you want to upload orders.

Query parameters

Name

Description

merge_mode

Type: string

Data saving mode. For any value, pass all required fields, even ones that aren't modified.

  • SAVE: All previously transmitted data is completely replaced with new data. Details.
  • UPDATE: Only the data that you're currently uploading is updated. Details.
  • APPEND: New data is added to previously uploaded data. Details.

Example: SAVE

Body

application/json
{
  "orders": [
    {
      "attribute_values": [
        {}
      ],
      "revenue": 9223372036854,
      "cost": 9223372036854,
      "currency": "example",
      "goals": [
        {
          "goal_action_id": "example",
          "price": 0.5
        }
      ],
      "yclid": 0,
      "purchase_id": "example",
      "create_date_time": "2025-01-01T00:00:00Z",
      "id": "example",
      "client_uniq_id": "example",
      "client_type": "example",
      "update_date_time": "2025-01-01T00:00:00Z",
      "finish_date_time": "2025-01-01T00:00:00Z",
      "order_status": "example",
      "products": {},
      "user_comment": "example"
    }
  ]
}

Name

Description

orders

Type: OrderRow[]

List of orders.

Min items: 1

Example
[
  {
    "attribute_values": [
      {}
    ],
    "revenue": 9223372036854,
    "cost": 9223372036854,
    "currency": "example",
    "goals": [
      {
        "goal_action_id": "example",
        "price": 0.5
      }
    ],
    "yclid": 0,
    "purchase_id": "example",
    "create_date_time": "2025-01-01T00:00:00Z",
    "id": "example",
    "client_uniq_id": "example",
    "client_type": "example",
    "update_date_time": "2025-01-01T00:00:00Z",
    "finish_date_time": "2025-01-01T00:00:00Z",
    "order_status": "example",
    "products": {},
    "user_comment": "example"
  }
]

CdpGoalExternal

Goals and their costs in the order.

Name

Description

goal_action_id

Type: string

ID of the JS goal.

Example: example

price

Type: number

Goal cost in the order.

Example
{
  "goal_action_id": "example",
  "price": 0.5
}

OrderRow

List of orders.

Name

Description

client_type

Type: string

Type of customer who placed this order.

Possible values:

  • CONTACT
  • COMPANY

Example: example

client_uniq_id

Type: string

ID of the customer (uniq_id) who placed this order.

Min length: 1

Example: example

create_date_time

Type: string<date-time>

Date and time of order creation in the counter's time zone. You can't change this value.

Example: 2025-01-01T00:00:00Z

id

Type: string

Order ID.

Min length: 1

Example: example

order_status

Type: string

Order status ID. An arbitrary string. You can change the status. Specify the value that you passed when mapping statuses in the id field.

Min length: 1

Example: example

attribute_values

Type: object[]

[additional]

Type: string[]

Unique items: true

Example
[
  "example"
]

Custom attributes.

Example
[
  {}
]

cost

Type: number

Expenses.

Max value: 9223372036854

currency

Type: string

Order currency in ISO 4217 format.

Example: example

finish_date_time

Type: string<date-time>

Date and time of order completion in the counter's time zone.

Example: 2025-01-01T00:00:00Z

goals

Type: CdpGoalExternal[]

Min items: 0

Max items: 100

Example
[
  {
    "goal_action_id": "example",
    "price": 0.5
  }
]

products

Type: object

[additional]

Type: integer

Products in the order.

Products in the order.

Example
{}

revenue

Type: number

Revenue. Total value of the order.

Max value: 9223372036854

update_date_time

Type: string<date-time>

Date and time of order update in the counter's time zone. If the parameter is not passed, the value is inserted automatically.

Example: 2025-01-01T00:00:00Z

user_comment

Type: string

Comment on the order.

Min length: 0

Max length: 1000

Example: example

Example
{
  "attribute_values": [
    {}
  ],
  "revenue": 9223372036854,
  "cost": 9223372036854,
  "currency": "example",
  "goals": [
    {
      "goal_action_id": "example",
      "price": 0.5
    }
  ],
  "create_date_time": "2025-01-01T00:00:00Z",
  "id": "example",
  "client_uniq_id": "example",
  "client_type": "example",
  "update_date_time": "2025-01-01T00:00:00Z",
  "finish_date_time": "2025-01-01T00:00:00Z",
  "order_status": "example",
  "products": {},
  "user_comment": "example"
}

Responses

200 OK

OK

Body

application/json
{
  "uploading": {
    "uploading_id": "example",
    "datetime": "2025-01-01T00:00:00Z",
    "api_validation_status": "example",
    "elements_count": 0,
    "entity_type": "example",
    "entity_subtype": "example",
    "uploading_format": "example",
    "uploading_source": "example",
    "api_validation_errors": [
      "example"
    ],
    "uploading_title": "example"
  }
}

Name

Description

uploading

Type: UploadingMetaExternal

Upload information

Example
{
  "uploading_id": "example",
  "datetime": "2025-01-01T00:00:00Z",
  "api_validation_status": "example",
  "elements_count": 0,
  "entity_type": "example",
  "entity_subtype": "example",
  "uploading_format": "example",
  "uploading_source": "example",
  "api_validation_errors": [
    "example"
  ],
  "uploading_title": "example"
}

UploadingMetaExternal

Upload information

Name

Description

api_validation_status

Type: string

Upload validation status:

  • PASSED: Validation passed.
  • FAILED: Validation failed.

Example: example

datetime

Type: string<date-time>

Upload time.

Example: 2025-01-01T00:00:00Z

elements_count

Type: integer

Number of elements within the upload.

entity_type

Type: string

Entity type:

  • SYSTEM: System entity, such as contacts or orders.
  • CUSTOM_LIST: Custom list.
  • SYSTEM_LIST: System list, such as products.

Example: example

uploading_format

Type: string

Upload format. Possible values:

  • JSON
  • CSV

Example: example

uploading_id

Type: string

Upload ID.

Example: example

uploading_source

Type: string

Upload source. Possible values: API

Example: example

Example
{
  "uploading_id": "example",
  "datetime": "2025-01-01T00:00:00Z",
  "api_validation_status": "example",
  "elements_count": 0,
  "entity_type": "example",
  "uploading_format": "example",
  "uploading_source": "example"
}

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