Est.

Server-Side Receipt Validation With App Store Server API

Verify Apple's signed data on your server, not the device's claim.

· 9 min read
Cover illustration for “Server-Side Receipt Validation With App Store Server API”
In-App Purchases and Subscriptions · December 4, 2026 · 9 min read · 1,925 words

Server-side receipt validation with the App Store Server API is an endpoint migration that changes trust. The server authenticates its requests with a JWT, verifies Apple’s JWS-signed responses, and maintains the entitlement record. A secure implementation treats the device’s transaction identifier as a lookup key, never as proof that access should be granted.

Why the old receipt model is no longer sufficient for server-side validation

The original PKCS#7 receipt flow is open to attack when the device also decides whether a purchase grants access. A client that releases paid content because a local call returned success can be told what to believe. Modified binaries, jailbroken devices, and proxy tools make it possible to forge or replay purchase claims. The weakness is the location of the authority. Moving validation to a server only helps if that server derives entitlement from verified purchase data.

Apple deprecated verifyReceipt on June 5, 2023. The endpoint still functions but receives no new features, and Apple recommends moving to the App Store Server API and App Store Server Notifications V2. Deprecation is therefore not the sole reason to migrate.

What actually changed: JWS transactions, the App Store Server API, and why the flow is structurally different

In the modern flow, the app completes a purchase, receives a transaction identifier, and sends that identifier to the developer’s server. The server uses it to query Apple directly through an authenticated GET request. The identifier is not proof of success. The server authenticates with a JWT that it signs with ES256 using an API key issued in App Store Connect, and it derives entitlement from the signed transaction data in Apple’s response.

There are two distinct verification paths. Apple’s App Store Server Library can verify JWS locally in Swift, Java, Node.js, and Python without a network call to Apple. Here, local verification checks signed data where the library runs and does not take the app’s purchase-success flag as proof. The server API path instead queries Apple for a live, authoritative response. For subscription entitlement, that query should be the primary route because the server needs current subscription state.

What to set up in App Store Connect before writing a line of server code

Every request from the server to Apple needs the API key. In App Store Connect, navigate through Users and Access, Integrations, Keys, and In-App Purchase, then generate a new key. Download the .p8 private key file immediately. Apple makes that download available exactly once. Record the Key ID and Issuer ID, and keep the private key outside both the app bundle and version control because it belongs exclusively on the server.

The credential inputs are $signingKey, containing the .p8 contents, together with $keyId, $issuerId, and $bundleId. Those values support a JWT containing the issuer, bundle ID, appstoreconnect-v1 audience, and a short expiry, with the Key ID identifying the signing key. The next step is choosing the request environment. Production requests use api.storekit.apple.com, while sandbox requests use api.storekit-sandbox.apple.com. That distinction must remain explicit throughout validation because the app’s distribution context does not by itself determine the purchase environment.

Constructing the server request and reading the JWS response

The HTTP exchange has three sequential operations. Build and sign the authentication JWT, make the GET request using the transaction identifier, and verify the JWS returned by Apple. The JWT header sets alg to ES256 and kid to {keyId}. Its payload sets iss to {issuerId}, iat to the current time, exp to the end of a short validity window, aud to appstoreconnect-v1, and bid to {bundleId}. Sign that token with the private key from the .p8 file.

The transaction request is GET /inApps/v1/transactions/{transactionId}, authenticated with an Authorization header whose value is Bearer {jwt}. The response contains signedTransactionInfo, a JWS string. Decoding alone does not establish its authenticity. The server reads the certificate chain from the JWS header and verifies it against Apple’s root CA before using the payload. Apple’s server library comes with no root CAs, so the application must supply them.

The verified payload exposes productId, purchaseDate, expiresDate, revocationDate, revocationReason, and transactionReason, with optional fields present where applicable. These fields describe the transaction, but subscriptions also need a current-state query. For that purpose, use getAllSubscriptionStatuses() with its optional status filter set to the relevant states, such as Active and InBillingGracePeriod. Filtering narrows the response to actionable subscription states. It also avoids making a full transaction-history interpretation the default route for an ordinary subscription check.

Writing the entitlement record and three implementation errors that reach production

Successful validation should produce a durable entitlement row containing the user account, product ID, purchase date, expiry date, and environment. Later subscription checks read that row, so they do not need to call Apple’s API each time. The minimum implementation is one endpoint that accepts a transaction identifier, queries Apple, writes the row, and returns the entitlement. For a developer familiar with the backend, that core flow is a day of work.

Three implementation errors need to be checked before release. The first is trusting a client-supplied boolean, since a purchase-success field remains a claim controlled by the client. The second is validating once and never updating the row, which leaves renewals, cancellations, refunds, and billing recovery disconnected from access. The third is deriving the subscription’s expiry from the local server clock, an error because Apple’s signed expiresDate supplies that expiry. Authentication-token timing and entitlement expiry serve different purposes. The server creates the JWT’s short validity window, but Apple supplies the purchase’s expiry.

Keeping entitlement state current with App Store Server Notifications V2

A validated entitlement row describes the purchase state when it was written. App Store Server Notifications V2 keeps that state up to date by sending signed lifecycle data, so the developer’s server does not need to poll for it. The payload uses the same JWS structure as the transaction response, so the existing decoding and verification path applies. The additional work is in the event handlers. Each handler must translate a verified lifecycle event into the corresponding change to the stored entitlement.

A renewal handler updates the subscription after rebilling so that a row that looked expired becomes active after payment. A refund handler revokes access, while a cancellation handler updates the entitlement end date rather than treating cancellation itself as an instruction to discard the paid period. The server must apply its decision about access during grace and revoke access after grace ends where appropriate. Billing retry success must restore the paid state so that a resolved billing problem does not leave the customer locked out.

Without these handlers, even a genuine purchase record can lead to the wrong decision about access. Signature verification establishes who issued the data. Lifecycle handling determines what that data means for the user’s entitlement now.

Handling the sandbox receipt problem during App Review

Purchase restoration and sandbox fallback belong in the submission checks. A production-signed app can receive sandbox receipts during App Review, so a production-only validation server can reject reviewer purchases even when StoreKit succeeds. Apple’s guidance is to try production validation first and retry against the sandbox base URL when the response indicates that a sandbox receipt was sent to production. The purchase otherwise completes without delivering its content. That failure can produce a Guideline 2.1 rejection for an incomplete app.

Product submission state is the remaining prerequisite. The first in-app purchase must accompany the app binary and be in Ready to Submit state. A product outside that state is not returned to the reviewer’s sandbox session.

Latency, the cross-platform divergence, and what staged adoption looks like for indie projects

Latency is a real architectural constraint that requires assessment beyond an average. A developer on Apple’s forums reported that the App Store Server API took above four seconds to respond, while Apple said the average was near one hundred milliseconds. The practical response is asynchronous validation and a cached entitlement row, rather than blocking every content request on a fresh call to Apple.

Supporting both platforms adds work to keep the system running because Apple and Google use different validation paths. Teams should plan for both from the start. The PHP store-receipt-validator library supports Apple App Store Server API v2 and Google Play Developer API Android Publisher v3 in one dependency.

Indie projects can start with a small system and add to it in stages. At low user volume, the incentive to build a cracked version is limited, while receipt validation’s low request frequency can keep a StoreKit 2 implementation within the free tiers of AWS Lambda, Cloudflare Workers, or Supabase Edge Functions. Managed platforms such as Adapty offer another route, handling validation, Notifications V2, cross-platform sync, and subscription status storage behind an SDK. The trade is control for implementation speed. It is a reasonable option before scaling, rather than a reason to omit server-side entitlement authority.

Choosing a backend host and fitting receipt validation into a Swift-first stack

The validation endpoint is a small, stateless function with three requirements, namely network access, secure storage for the .p8 credentials, and write access to the entitlement table. It can run as a serverless or edge function without a full application server. Supabase Edge Functions is one place to run it. Environment variables hold the credentials, direct access to Supabase Postgres avoids a separate ORM, and the validation result and entitlement row can be written in the same database transaction.

The chista.app production build illustrates a different arrangement around the same responsibility. Its client used Swift 5.10, SwiftUI, and StoreKit 2, while FastAPI on Railway served as the backend and Supabase supplied authentication and the database. Apple’s app-store-server-library handled server-side JWS verification. At launch, the stack ran on the free tier of each service. This places validation in the backend without requiring the client and server to use the same language.

For new Swift-first projects, Supabase offers a Swift SDK, real SQL through Postgres, predictable pricing, and a path without vendor lock-in. Firebase is appropriate when real-time Firestore listeners or Crashlytics and Remote Config integration are hard requirements. The client architecture remains a separate concern. In MVVM, inject the subscription status service as a dependency. Publish entitlement state on the view model for use within a SwiftUI body.

What the WWDC 2025 updates add and what to implement now versus later

Apple’s StoreKit 2 Tech Talk shows teams how to build without a managed SDK. Apple’s WWDC 2025 StoreKit session covered new fields in AppTransaction, Transaction, and RenewalInfo, as well as how to create signed In-App Purchase requests with the App Store Server Library. These additions extend the server integration’s capabilities. They do not replace the core sequence of authenticated lookup, verified response, durable entitlement, and lifecycle updates.

Filtered getAllSubscriptionStatuses() queries are an immediate priority because they support current-state decisions without reconstructing a full transaction history. By contrast, sendConsumptionInformation() targeting Apple’s v2 endpoint is more relevant to consumable products where refund disputes are likely. It reports delivery status, consumption percentage, and refund preference, making it a lower priority for subscriptions. Toolchain compatibility also warrants an audit. Apps uploaded to App Store Connect require Xcode 26 or later with an SDK for iOS 26, and pinned server-library versions should be reviewed for compatibility.

The migration checklist starts with generating the App Store Connect API key and securely storing the .p8 on the server. Next, implement JWT construction and getTransactionInfo() for purchase validation, then use getAllSubscriptionStatuses() with an active-state filter for subscription queries. Register a Notifications V2 endpoint that handles at least DID_RENEW, REFUND, DID_FAIL_TO_RENEW, EXPIRED, and GRACE_PERIOD_EXPIRED. Finally, add the production-to-sandbox fallback before App Review. Ship that core before expanding into the newer API surface.

Diagram: Migration Checklist: Five Ordered Steps to Ship. Visualizes: The article closes with a strict sequential checklist for implementing App Store Server API validation.

Sources

  1. Support customers with StoreKit 2 and App Store Server API - Tech Talks - Videos - Apple Developer

More in In-App Purchases and Subscriptions