POST /api/v2/server-side-api/purchase/set/transaction/

Set transaction

Creates a new transaction for an end user of your app in Adapty and provides access level. The transaction created by this method will appear in your analytics and Event Feed and will be sent to all integrations.

Header parameters

adapty-customer-user-idstring

The unique ID of the customer in your system. Either adapty-customer-user-id or adapty-profile-id is required.

adapty-profile-idstring

The unique ID of the profile in your system. Your best option if you are working with anonymous profiles. Either adapty-customer-user-id or adapty-profile-id is required.

Request body

Option 1 — object

Transaction data for a one-time purchase

purchase_typestringrequired

Type of purchase

One of: "one_time_purchase"

storestringrequired

Store where the purchase was made. Common values include app_store, play_store, stripe, paddle, or any custom store identifier

environmentstring

Environment where the purchase was made

One of: "Production", "Sandbox"

store_product_idstringrequired

Product ID in the store

store_transaction_idstringrequired

Transaction ID in the store

store_original_transaction_idstringrequired

Original transaction ID in the store

is_family_sharedboolean

Whether the purchase is family shared

priceobjectrequired
countrystringrequired

Country code

currencystringrequired

Currency code

valuenumberrequired

Price value

purchased_atstringrequired

When the purchase was made

variation_idstring

Variation ID for A/B testing

offerobject
categorystringrequired

Offer category

One of: "introductory", "promotional", "offer_code", "win_back"

typestringrequired

Offer type

One of: "free_trial", "pay_as_you_go", "pay_up_front"

idstring

Offer ID

refunded_atstring

When the purchase was refunded

cancellation_reasonstring

Reason for cancellation

One of: "billing_error", "cancelled_by_developer", "new_subscription_replace", "price_increase", "product_was_not_available", "refund", "unknown", "upgraded", "voluntarily_cancelled", "adapty_revoked"

Option 2 — object

Transaction data for a subscription purchase

purchase_typestringrequired

Type of purchase

One of: "subscription"

storestringrequired

Store where the purchase was made. Common values include app_store, play_store, stripe, paddle, or any custom store identifier

environmentstring

Environment where the purchase was made

One of: "Production", "Sandbox"

store_product_idstringrequired

Product ID in the store

store_transaction_idstringrequired

Transaction ID in the store

store_original_transaction_idstringrequired

Original transaction ID in the store

is_family_sharedboolean

Whether the purchase is family shared

priceobjectrequired
countrystringrequired

Country code

currencystringrequired

Currency code

valuenumberrequired

Price value

purchased_atstringrequired

When the purchase was made

variation_idstring

Variation ID for A/B testing

offerobject
categorystringrequired

Offer category

One of: "introductory", "promotional", "offer_code", "win_back"

typestringrequired

Offer type

One of: "free_trial", "pay_as_you_go", "pay_up_front"

idstring

Offer ID

refunded_atstring

When the purchase was refunded

cancellation_reasonstring

Reason for cancellation

One of: "billing_error", "cancelled_by_developer", "new_subscription_replace", "price_increase", "product_was_not_available", "refund", "unknown", "upgraded", "voluntarily_cancelled", "adapty_revoked"

originally_purchased_atstringrequired

When the subscription was originally purchased

expires_atstringrequired

When the subscription expires

renew_statusbooleanrequired

Whether the subscription will renew

renew_status_changed_atstring

When the renewal status was changed

billing_issue_detected_atstring

When billing issue was detected

grace_period_expires_atstring

When grace period expires

Responses

Transaction recorded successfully

Schema
dataobjectrequired
app_idstringrequired

The internal ID of your app

profile_idstringrequired

Adapty profile ID

customer_user_idstringrequired

The ID of your user in your system

total_revenue_usdnumberrequired

A float value representing the total revenue in USD earned in the profile

segment_hashstringrequired

Internal parameter

timestampintegerrequired

Response time in milliseconds, needs for resolve a race condition

custom_attributesarray of objectrequired

A maximum of 30 custom attributes to the profile are allowed to be set

keystringrequired

The key must be a string with no more than 30 characters. Only letters, numbers, dashes, points, and underscores allowed

valuestring | numberrequired

The attribute value must be no more than 50 characters. Only strings and floats are allowed as values

access_levelsarray of objectrequired

Array of Access level objects. Empty array if the customer has no access levels

access_level_idstring

Access level identifier

storestring

Store where the access level was purchased

store_product_idstring

Product ID in the store

store_base_plan_idstring

Base plan ID in the store

store_transaction_idstring

Transaction ID in the store

store_original_transaction_idstring

Original transaction ID in the store

offerallOf

Offer details, if a promotional or introductory offer was applied

categorystring

Offer category

One of: "introductory", "promotional", "offer_code", "win_back"

typestring

Offer type

One of: "free_trial", "pay_as_you_go", "pay_up_front"

idstring

Offer ID

starts_atstring

When the access level starts

purchased_atstring

When the access level was purchased

originally_purchased_atstring

When the access level was originally purchased

expires_atstring

When the access level expires

renewal_cancelled_atstring

When renewal was cancelled

billing_issue_detected_atstring

When billing issue was detected

is_in_grace_periodboolean

Whether the access level is in grace period

cancellation_reasonstring

Reason for cancellation

subscriptionsarray of objectrequired

Array of Subscription objects. Empty array if the customer has no subscriptions

storestring

Store where the subscription was purchased

store_product_idstring

Product ID in the store

store_base_plan_idstring

Base plan ID in the store

store_transaction_idstring

Transaction ID in the store

store_original_transaction_idstring

Original transaction ID in the store

offerallOf

Offer details, if a promotional or introductory offer was applied

categorystring

Offer category

One of: "introductory", "promotional", "offer_code", "win_back"

typestring

Offer type

One of: "free_trial", "pay_as_you_go", "pay_up_front"

idstring

Offer ID

environmentstring

Environment (Sandbox, Production)

purchased_atstring

When the subscription was purchased

originally_purchased_atstring

When the subscription was originally purchased

expires_atstring

When the subscription expires

renewal_cancelled_atstring

When renewal was cancelled

billing_issue_detected_atstring

When billing issue was detected

is_in_grace_periodboolean

Whether the subscription is in grace period

cancellation_reasonstring

Reason for cancellation

non_subscriptionsarray of objectrequired

Array of Non-Subscription objects. Empty array if the customer has no purchases

purchase_idstring

Unique purchase identifier

storestring

Store where the purchase was made

store_product_idstring

Product ID in the store

store_base_plan_idstring

Base plan ID in the store

store_transaction_idstring

Transaction ID in the store

store_original_transaction_idstring

Original transaction ID in the store

purchased_atstring

When the purchase was made

environmentstring

Environment (Sandbox, Production)

is_refundboolean

Whether this is a refund

is_consumableboolean

Whether this is a consumable purchase

Bad request

Schema
errorsarray of objectrequired
sourcestring

Source of the error

errorsarray of string

Array of error messages

error_codestringrequired

Short error name

status_codeintegerrequired

HTTP status code

Unauthorized

Schema
errorsarray of objectrequired
sourcestring

Source of the error

errorsarray of string

Array of error messages

error_codestringrequired

Short error name

status_codeintegerrequired

HTTP status code

Profile not found

Schema
errorsarray of objectrequired
sourcestring

Source of the error

errorsarray of string

Array of error messages

error_codestringrequired

Short error name

status_codeintegerrequired

HTTP status code

Internal server error