Validate Apple Store Purchase

POSThttps://app.botsi.com/api/v1/web-api/purchases/apple-store/validate

Validates an in-app purchase or subscription completed through the Apple App Store.

Follow the notes below for a successful request:
  • Trigger this endpoint after a successful purchase or restore event on the client. The server validates the transaction with Apple and associates it with the corresponding user profile, paywall, and AI Pricing model for accurate conversion tracking and attribution.

  • Identify the user by providing either customerUserId or profileId. At least one is required to return the correct result.

Notes:
  • transactionId and originalTransactionId must come from StoreKit (or StoreKit 2).

  • paywallId, isExperiment, and aiPricingModelId must match the values returned by Get Paywall.

  • Use environment: production for live apps and sandbox for testing.

  • The optional source field can be used to indicate whether the purchase comes from a restore flow, direct purchase, or observation.

Finding Required IDs

If you are having trouble finding transaction details, refer to the following StoreKit objects.

StoreKit
  • For transactionId and originalTransactionId, use the SKPaymentTransaction object.

  • For sourceProductId, use SKPaymentTransaction.payment.productIdentifier.

  • For originalPrice use the SKProduct object.

StoreKit2
  • For transactionId, originalTransactionId, and sourceProductId, use the Transaction object.

  • For originalPrice use the Product object.

Critical: Experiment Attribution

While paywallId, isExperiment, and aiPricingModelId are technically optional, you should always include them if the purchase originated from a paywall fetched via the Get Paywall endpoint. These fields link the purchase to the correct experiment or control group.

Without them, Botsi cannot attribute the revenue to the right variant. This means experiment results become unreliable, and the AI model will train on incomplete conversion data — degrading future pricing predictions.

Request Body

application/json

ParameterTypeRequiredDescription
profileIdstringOptionalProvide profileId or customerUserId
customerUserIdstringRecommendedYour internal user ID. Provide either profileId or customerUserId
productIdstringRequiredApple product identifier. Example: premium_monthly
transactionIdstringRequiredStoreKit transaction ID. Example: 2000000123456789
originalTransactionIdstringRequiredOriginal transaction ID. Example: 2000000123456789
paywallIdintegerRecommendedFrom Get Paywall response (data.id). Required for correct revenue attribution.
isExperimentbooleanRecommendedMust match data.isExperiment from Get Paywall. Required for experiment vs. control attribution.
aiPricingModelIdintegerRecommendedMust match data.aiPricingModelId from Get Paywall. Ties the purchase to the AI model for training.
placementIdstringOptionalPlacement ID used to fetch the paywall
pricenumberOptionalPurchase price. Example: 9.99
currencystringOptionalISO 4217 code. Example: USD
environmentstringOptional"production" or "sandbox"
sourcestringOptionalPurchase source: "purchase", "restore", "observation"

Example Request

{
  "profileId": "0072102a-c00c-4ea5-9271-1b6e975f2d63",
  "productId": "premium_monthly",
  "transactionId": "2000000123456789",
  "originalTransactionId": "2000000123456789",
  "paywallId": 42,
  "isExperiment": true,
  "aiPricingModelId": 32,
  "environment": "production"
}

cURL Example

curl -X POST "https://app.botsi.com/api/v1/web-api/purchases/apple-store/validate"      -H "Authorization: {{secret_key}}"      -H "Content-Type: application/json"      -d '{
       "profileId": "0072102a-c00c-4ea5-9271-1b6e975f2d63",
       "productId": "premium_monthly",
       "transactionId": "2000000123456789",
       "originalTransactionId": "2000000123456789",
       "paywallId": 42,
       "isExperiment": true,
       "aiPricingModelId": 32,
       "environment": "production"
     }'

Response

200Purchase validated

A successful request confirms the validation and returns the updated user profile associated with the purchase.

{
  "ok": true,
  "data": {
    "profileId": "0072102a-c00c-4ea5-9271-1b6e975f2d63",
    "customerUserId": "user-123",
    "paid": true,
    "country": "US",
    "platform": "ios"
  }
}

Try It Out

https://app.botsi.com/api/v1/web-api
Response
Click "Send API Request" to see the response here.