---
title: "Set transaction"
method: POST
path: "/api/v2/server-side-api/purchase/set/transaction/"
tags: ["Purchase"]
---

# Set transaction

`POST /api/v2/server-side-api/purchase/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.

**Updating an existing subscription:** To update `billing_issue_detected_at` or `renew_status_changed_at` without generating a new `subscription_renewed` event, reuse the existing `store_transaction_id` (under the same `store_original_transaction_id`). Submitting any new `store_transaction_id` is treated as a new transaction and fires a `subscription_renewed` event.

## Headers

- `adapty-customer-user-id` string
- `adapty-profile-id` string

## Request body

- union
  - OneTimePurchaseDTO — Transaction data for a one-time purchase
    - `purchase_type` 'one_time_purchase', required — Type of purchase
    - `store` string, required — Store where the purchase was made. Common values include `app_store`, `play_store`, `stripe`, `paddle`, or any custom store identifier
    - `environment` 'Production' | 'Sandbox' — Environment where the purchase was made
    - `store_product_id` string, required — Product ID in the store
    - `store_transaction_id` string, required — Transaction ID in the store. Maximum 50 characters. PayPal and some custom-store transaction IDs can exceed this — trim or hash the value before submitting, otherwise the request fails.
    - `store_original_transaction_id` string, required — Original transaction ID in the store
    - `is_family_shared` boolean — Whether the purchase is family shared
    - `price` PriceDTO, required
      - `country` string, required — Country code in ISO 3166-1 alpha-2 format, for example `US`
      - `currency` string, required — Currency code in ISO 4217 format, for example `USD`
      - `value` number, float, required — Price value
    - `purchased_at` string, date-time, required — When the purchase was made
    - `variation_id` string, nullable — Variation ID for A/B testing
    - `offer` OfferDTO
      - `category` 'introductory' | 'promotional' | 'offer_code' | 'win_back', required — Offer category
      - `type` 'free_trial' | 'pay_as_you_go' | 'pay_up_front', required — Offer type
      - `id` string, nullable — Offer ID
    - `refunded_at` string, date-time, nullable — When the purchase was refunded
    - `cancellation_reason` 'billing_error' | 'cancelled_by_developer' | 'new_subscription_replace' | 'price_increase' | 'product_was_not_available' | 'refund' | 'unknown' | 'upgraded' | 'voluntarily_cancelled' | 'adapty_revoked', nullable — Reason for cancellation
  - SubscriptionDTO — Transaction data for a subscription purchase
    - `purchase_type` 'subscription', required — Type of purchase
    - `store` string, required — Store where the purchase was made. Common values include `app_store`, `play_store`, `stripe`, `paddle`, or any custom store identifier
    - `environment` 'Production' | 'Sandbox' — Environment where the purchase was made
    - `store_product_id` string, required — Product ID in the store
    - `store_transaction_id` string, required — Transaction ID in the store. Maximum 50 characters. PayPal and some custom-store transaction IDs can exceed this — trim or hash the value before submitting, otherwise the request fails.
    - `store_original_transaction_id` string, required — Original transaction ID in the store
    - `is_family_shared` boolean — Whether the purchase is family shared
    - `price` PriceDTO, required
      - `country` string, required — Country code in ISO 3166-1 alpha-2 format, for example `US`
      - `currency` string, required — Currency code in ISO 4217 format, for example `USD`
      - `value` number, float, required — Price value
    - `purchased_at` string, date-time, required — When the purchase was made
    - `variation_id` string, nullable — Variation ID for A/B testing
    - `offer` OfferDTO
      - `category` 'introductory' | 'promotional' | 'offer_code' | 'win_back', required — Offer category
      - `type` 'free_trial' | 'pay_as_you_go' | 'pay_up_front', required — Offer type
      - `id` string, nullable — Offer ID
    - `refunded_at` string, date-time, nullable — When the purchase was refunded
    - `cancellation_reason` 'billing_error' | 'cancelled_by_developer' | 'new_subscription_replace' | 'price_increase' | 'product_was_not_available' | 'refund' | 'unknown' | 'upgraded' | 'voluntarily_cancelled' | 'adapty_revoked', nullable — Reason for cancellation
    - `originally_purchased_at` string, date-time, required — When the subscription was originally purchased
    - `expires_at` string, date-time, required — When the subscription expires
    - `renew_status` boolean, required — Whether the subscription will renew
    - `renew_status_changed_at` string, date-time, nullable — When the renewal status was changed
    - `billing_issue_detected_at` string, date-time, nullable — When billing issue was detected
    - `grace_period_expires_at` string, date-time, nullable — When grace period expires

## Response `200`

Transaction recorded successfully

- ProfileResponse
  - `data` Profile, required
    - `app_id` string, uuid, required — The internal ID of your app
    - `profile_id` string, uuid, required — Adapty profile ID
    - `customer_user_id` string, nullable, required — The ID of your user in your system
    - `total_revenue_usd` number, float, required — A float value representing the total revenue in USD earned in the profile
    - `segment_hash` string, required — Internal parameter
    - `timestamp` integer, required — Response time in milliseconds, needs for resolve a race condition
    - `custom_attributes` CustomAttribute[], required — A maximum of 30 custom attributes to the profile are allowed to be set
      - `key` string, required — The key must be a string with no more than 30 characters. Only letters, numbers, dashes, points, and underscores allowed
      - `value` union, required — The attribute value must be no more than 50 characters. Only strings and floats are allowed as values
        - string
        - number
    - `access_levels` AccessLevel[], required — Array of Access level objects. Empty array if the customer has no access levels
      - `access_level_id` string — Access level identifier
      - `store` string — Store where the access level was purchased
      - `store_product_id` string — Product ID in the store
      - `store_base_plan_id` string, nullable — Base plan ID in the store
      - `store_transaction_id` string — Transaction ID in the store
      - `store_original_transaction_id` string — Original transaction ID in the store
      - `offer` OfferDTO
        - `category` 'introductory' | 'promotional' | 'offer_code' | 'win_back', required — Offer category
        - `type` 'free_trial' | 'pay_as_you_go' | 'pay_up_front', required — Offer type
        - `id` string, nullable — Offer ID
      - `starts_at` string, date-time, nullable — When the access level starts
      - `purchased_at` string, date-time — When the access level was purchased
      - `originally_purchased_at` string, date-time — When the access level was originally purchased
      - `expires_at` string, date-time, nullable — When the access level expires
      - `renewal_cancelled_at` string, date-time, nullable — When renewal was cancelled
      - `billing_issue_detected_at` string, date-time, nullable — When billing issue was detected
      - `is_in_grace_period` boolean — Whether the access level is in grace period
      - `cancellation_reason` string, nullable — Reason for cancellation
    - `subscriptions` Subscription[], required — Array of Subscription objects. Empty array if the customer has no subscriptions
      - `store` string — Store where the subscription was purchased
      - `store_product_id` string — Product ID in the store
      - `store_base_plan_id` string, nullable — Base plan ID in the store
      - `store_transaction_id` string — Transaction ID in the store
      - `store_original_transaction_id` string — Original transaction ID in the store
      - `offer` OfferDTO
        - `category` 'introductory' | 'promotional' | 'offer_code' | 'win_back', required — Offer category
        - `type` 'free_trial' | 'pay_as_you_go' | 'pay_up_front', required — Offer type
        - `id` string, nullable — Offer ID
      - `environment` string — Environment (Sandbox, Production)
      - `purchased_at` string, date-time — When the subscription was purchased
      - `originally_purchased_at` string, date-time — When the subscription was originally purchased
      - `expires_at` string, date-time, nullable — When the subscription expires
      - `renewal_cancelled_at` string, date-time, nullable — When renewal was cancelled
      - `billing_issue_detected_at` string, date-time, nullable — When billing issue was detected
      - `is_in_grace_period` boolean — Whether the subscription is in grace period
      - `cancellation_reason` string, nullable — Reason for cancellation
    - `non_subscriptions` NonSubscription[], required — Array of Non-Subscription objects. Empty array if the customer has no purchases
      - `purchase_id` string, uuid — Unique purchase identifier
      - `store` string — Store where the purchase was made
      - `store_product_id` string — Product ID in the store
      - `store_base_plan_id` string, nullable — Base plan ID in the store
      - `store_transaction_id` string — Transaction ID in the store
      - `store_original_transaction_id` string — Original transaction ID in the store
      - `purchased_at` string, date-time — When the purchase was made
      - `environment` string — Environment (Sandbox, Production)
      - `is_refund` boolean — Whether this is a refund
      - `is_consumable` boolean — Whether this is a consumable purchase

## Other responses

- `400` — Bad request
- `401` — Unauthorized
- `404` — Profile not found
- `500` — Internal server error

---

[API](https://skmtc.dev/adapty/apis/adapty-server-side-api.md) · [All operations](https://skmtc.dev/adapty/apis/adapty-server-side-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/adapty/adapty-server-side-api/revisions/abdc1c773a17/schema)
