Uploading In-App Revenue events

Transmits data about purchases.

Usage example: You can send In-App Revenue events to AppMetrica via the Post API if purchases in your app are not made through Google Play or AppStore and are not tracked on the client side. If you track subscription data inside the app on your own or use a third-party service, you can transmit subscription data via the Post API.

Purchase events received via the Post API are used when calculating all metrics and are also available in funnels and cohorts.

Important. Revenue events received via the Post API are not validated and are always considered valid.

Event properties can be passed in parameters or in the body of the request. When you pass data in the body, you should add .csv to the URL of the request. For more information, see Sample request.

To bind an event to a user, you should use one of the following fields in the API request:

  • profile_id
  • appmetrica_device_id
Attention. The Post API has restrictions on loading data. For more information, see Restrictions.

Request format

POST https://api.appmetrica.yandex.ru/logs/v1/import/revenue
 ? post_api_key=<string>
 & application_id=<int>
 & profile_id=<string>
 & appmetrica_device_id=<int>
 & revenue_event_type=<string>
 & event_timestamp=<int>
 & price=<decimal>
 & currency=<string>
 & product_id=<string>
 & [quantity=<int>]
 & [payload=<string>]
 & [transaction_id=<int>]
 & [order_id=<int>]
 & [session_type=<string>]
 & [ios_ifa=<string>]
 & [ios_ifv=<string>]
 & [google_aid=<string>]
 & [windows_aid=<string>]
 & [os_name=<string>]
 & [os_version=<string>]
 & [device_manufacturer=<string>]
 & [device_model=<string>]
 & [device_type=<string>]
 & [device_locale=<string>]
 & [app_version_name=<string>]
 & [app_package_name=<string>]
 & [connection_type=<string>]
 & [operator_name=<string>]
 & [mcc=<int>]
 & [mnc=<int>]
 & [device_ipv6=<string>]
post_api_key *Token for data uploading. You can get it in the Settings section of your application.
application_id *Unique numeric identifier for the application in AppMetrica.
profile_id *User profile ID. The Post API allows you only to upload data for identifiers that were previously sent via the SDK. Required if no appmetrica_device_id is specified.
Attention. Do not pass the value with the appmetrica_device_id parameter. The server accepts only one of these parameters.
appmetrica_device_id *Hash from the unique identifier of the device set by AppMetrica. The Post API allows you only to upload data for identifiers that were previously sent via the SDK. Required if no profile_id is specified.
Attention. Do not pass the value with the profile_id parameter. The server accepts only one of these parameters.
revenue_event_type *Purchase event type. List of available types:
  • one_time_purchase: Making a one-time purchase.
  • trial_started: Starting a subscription with a trial period.
  • intro_started: Starting a subscription with an intro offer.
  • promo_started: Starting a subscription with a promo offer.
  • subscription_converted: Paying the full subscription fee after an introductory offer.
  • subscription_started: Starting a subscription without introductory offers.
  • subscription_renewed: Paying for a new subscription period.
  • cancellation: Canceling a subscription. After this event, the user may have a paid period left, but no more fees will be charged.
  • uncancellation: Subscription activation event from Apple ID settings.
  • expired: The subscription expired.
  • billing_issues: Error when paying for subscription renewal.
  • refund: A refund for a subscription or a one-time purchase.
event_timestamp *Time of the event in the UNIX timestamp format.

You can upload events only if the difference between the event date (event_timestamp) and the upload date is no more than seven days.

price *

Price. Revenue amount in decimal(10.8) format (a decimal fraction with 10 digits before and 8 digits after the decimal point).

currency *Currency of the purchase. List of available currencies.
product_id *Item ID.
quantityQuantity of products purchased. Default value: 1.
payloadArbitrary payload: Additional information presented as key-value pairs. The maximum size is 30 KB. If the value exceeds this limit, it will be truncated by AppMetrica.
transaction_idUnique transaction ID.
order_idUnique order ID.
session_typeThe type of session. Possible values:
  • foreground — In the Events report AppMetrica increases the Users metric.
  • background — In the Events report AppMetrica increases the Devices metric. Such events are not included to the report with grouping by users, and into the profile card.

Default value is background.

ios_ifaDevice IFA.
ios_ifvDevice IFV.
google_aidGoogle AID.
windows_aidWindows AID.
os_nameThe name of the OS on the user's device. Possible values: ios | android | windows.
os_versionThe version of the operating system on the user's device.
device_manufacturerDevice manufacturer. For example, Apple, Samsung.
device_modelName of the device model For example, Galaxy S6, iPhone X.
device_typeThe device type detected by the AppMetrica service. Possible values: phone | tablet | phablet | tv | desktop | unknown.
device_localeThe language on the device. For example, en_US
app_version_nameThe app version in the format specified by the developer.
app_package_nameThe package name for Android, or the Bundle ID for iOS. For example, ru.yandex.sample.metrica.
connection_typeType of connection. Possible values: wifi | cell | unknown.
operator_nameName of the mobile operator. For example, MegaFon.
mccMobile country code. For example, 250
mncMobile network code. For example, 2
device_ipv6The IP address at the time of event, in the IPv6 format. For example, 2a02:6b8:: 40c:6676:baff:fea6:53d8, :: ffff:5.255.232.147
post_api_key *Token for data uploading. You can get it in the Settings section of your application.
application_id *Unique numeric identifier for the application in AppMetrica.
profile_id *User profile ID. The Post API allows you only to upload data for identifiers that were previously sent via the SDK. Required if no appmetrica_device_id is specified.
Attention. Do not pass the value with the appmetrica_device_id parameter. The server accepts only one of these parameters.
appmetrica_device_id *Hash from the unique identifier of the device set by AppMetrica. The Post API allows you only to upload data for identifiers that were previously sent via the SDK. Required if no profile_id is specified.
Attention. Do not pass the value with the profile_id parameter. The server accepts only one of these parameters.
revenue_event_type *Purchase event type. List of available types:
  • one_time_purchase: Making a one-time purchase.
  • trial_started: Starting a subscription with a trial period.
  • intro_started: Starting a subscription with an intro offer.
  • promo_started: Starting a subscription with a promo offer.
  • subscription_converted: Paying the full subscription fee after an introductory offer.
  • subscription_started: Starting a subscription without introductory offers.
  • subscription_renewed: Paying for a new subscription period.
  • cancellation: Canceling a subscription. After this event, the user may have a paid period left, but no more fees will be charged.
  • uncancellation: Subscription activation event from Apple ID settings.
  • expired: The subscription expired.
  • billing_issues: Error when paying for subscription renewal.
  • refund: A refund for a subscription or a one-time purchase.
event_timestamp *Time of the event in the UNIX timestamp format.

You can upload events only if the difference between the event date (event_timestamp) and the upload date is no more than seven days.

price *

Price. Revenue amount in decimal(10.8) format (a decimal fraction with 10 digits before and 8 digits after the decimal point).

currency *Currency of the purchase. List of available currencies.
product_id *Item ID.
quantityQuantity of products purchased. Default value: 1.
payloadArbitrary payload: Additional information presented as key-value pairs. The maximum size is 30 KB. If the value exceeds this limit, it will be truncated by AppMetrica.
transaction_idUnique transaction ID.
order_idUnique order ID.
session_typeThe type of session. Possible values:
  • foreground — In the Events report AppMetrica increases the Users metric.
  • background — In the Events report AppMetrica increases the Devices metric. Such events are not included to the report with grouping by users, and into the profile card.

Default value is background.

ios_ifaDevice IFA.
ios_ifvDevice IFV.
google_aidGoogle AID.
windows_aidWindows AID.
os_nameThe name of the OS on the user's device. Possible values: ios | android | windows.
os_versionThe version of the operating system on the user's device.
device_manufacturerDevice manufacturer. For example, Apple, Samsung.
device_modelName of the device model For example, Galaxy S6, iPhone X.
device_typeThe device type detected by the AppMetrica service. Possible values: phone | tablet | phablet | tv | desktop | unknown.
device_localeThe language on the device. For example, en_US
app_version_nameThe app version in the format specified by the developer.
app_package_nameThe package name for Android, or the Bundle ID for iOS. For example, ru.yandex.sample.metrica.
connection_typeType of connection. Possible values: wifi | cell | unknown.
operator_nameName of the mobile operator. For example, MegaFon.
mccMobile country code. For example, 250
mncMobile network code. For example, 2
device_ipv6The IP address at the time of event, in the IPv6 format. For example, 2a02:6b8:: 40c:6676:baff:fea6:53d8, :: ffff:5.255.232.147

* Required

Response codes

Code Description
200 Data has been uploaded successfully.
403 The request omitted an authorization header, or an invalid token was specified.
400 One or more required parameters were missing in the request.
Code Description
200 Data has been uploaded successfully.
403 The request omitted an authorization header, or an invalid token was specified.
400 One or more required parameters were missing in the request.

Sample request

POST /logs/v1/import/revenue.csv?post_api_key=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ012 HTTP/1.1
Host: api.appmetrica.yandex.com
Content-Length: 540i
Connection: close

appmetrica_device_id,device_model,device_type,google_aid,app_package_name,operator_name,mnc,application_id,account_id,event_timestamp,price,currency,product_id,quantity,transaction_id,order_id,revenue_event_type
1757762239877245682,iPhone X,phone,01234567-890a-bcde-f012-3456789abcde,com.yandex.sample.metrica,MegaFon,2,1111,1234567890123456789,1689943892,0.0001,usd,some_product1,1,transact1,8101,promo_started
1757762239877245682,iPhone X,phone,76543210-890a-bcde-f012-3456789abcde,com.yandex.sample.metrica,MegaFon,2,1111,9876543210987654321,1689943892,0.0001,usd,some_product2,2,transact2,1234,expired

Other Post API methods