# apple/app-store-server-library-swift architecture

> Architecture diagram of the GitHub repository apple/app-store-server-library-swift, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/apple/app-store-server-library-swift
- Repository: https://github.com/apple/app-store-server-library-swift

## Overview

This is a Swift client library for Apple’s App Store Server APIs and related signed-data workflows. A server application uses the API client to make requests and receive typed responses; it can also extract a transaction ID from an app receipt before querying transaction history. Separately, signed notification, transaction, renewal, and app-transaction payloads can be verified and decoded, and offer or Advanced Commerce request signatures can be created. The README documents Retention Messaging and Advanced Commerce support; the sampled excerpts do not establish their exact internal request wiring.

Main entry points: [`Sources/AppStoreServerLibrary/SignedDataVerifier.swift`](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/SignedDataVerifier.swift) (Signed data verifier), [`Sources/AppStoreServerLibrary/AppStoreServerAPIClient.swift`](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/AppStoreServerAPIClient.swift) (API client), [`Sources/AppStoreServerLibrary/ReceiptUtility.swift`](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/ReceiptUtility.swift) (Receipt utility), [`Sources/AppStoreServerLibrary/ChainVerifier.swift`](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/ChainVerifier.swift) (Certificate chain verifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Server API"]
  node_client["API client"]
  node_receipt["Receipt utility"]
end

subgraph group_verification["Signed Data Verification"]
  node_verifier["Signed data verifier"]
  node_chain["Certificate chain verifier"]
end

subgraph group_signatures["Signature Creation"]
  node_promo_signer["Promotional offer signer"]
  node_jws_signer["JWS signature creator"]
end

subgraph group_models["Domain Payloads"]
  node_transactions["Transaction payload"]
  node_renewals["Renewal payload"]
  node_notifications["Notification payload"]
  node_app_transaction["App transaction"]
  node_consumption["Consumption request"]
  node_commerce_request["Commerce request models"]
end

node_server(("App server"))
node_apple_api["Apple server APIs"]
node_ocsp["OCSP responder"]

node_server -->|"calls"| node_client
node_client -->|"sends requests"| node_apple_api
node_apple_api -->|"returns responses"| node_client
node_server -->|"submits receipt"| node_receipt
node_receipt -->|"returns transaction ID"| node_server
node_server -->|"submits signed data"| node_verifier
node_verifier -->|"validates signature"| node_chain
node_chain -.->|"checks revocation"| node_ocsp
node_verifier -->|"decodes as"| node_transactions
node_verifier -->|"decodes as"| node_renewals
node_verifier -->|"decodes as"| node_notifications
node_verifier -->|"decodes as"| node_app_transaction
node_server -->|"requests signature"| node_promo_signer
node_server -->|"requests signature"| node_jws_signer
node_server -->|"provides request data"| node_commerce_request
node_server -->|"provides consumption data"| node_consumption

click node_client "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/AppStoreServerAPIClient.swift"
click node_receipt "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/ReceiptUtility.swift"
click node_verifier "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/SignedDataVerifier.swift"
click node_chain "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/ChainVerifier.swift"
click node_transactions "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/JWSTransactionDecodedPayload.swift"
click node_renewals "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/JWSRenewalInfoDecodedPayload.swift"
click node_notifications "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/ResponseBodyV2DecodedPayload.swift"
click node_app_transaction "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/AppTransaction.swift"
click node_consumption "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/ConsumptionRequestV1.swift"
click node_commerce_request "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/AdvancedCommerceSubscriptionModifyInAppRequest.swift"
click node_promo_signer "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/PromotionalOfferSignatureCreator.swift"
click node_jws_signer "https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/JWSSignatureCreator.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_receipt toneBlue
class node_verifier,node_chain toneAmber
class node_promo_signer,node_jws_signer,node_server,node_apple_api toneMint
class node_transactions,node_renewals,node_notifications,node_app_transaction,node_consumption,node_commerce_request toneRose
class node_ocsp toneIndigo
```

## Components

### Server API

- [API client](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/AppStoreServerAPIClient.swift): `Sources/AppStoreServerLibrary/AppStoreServerAPIClient.swift`
- [Receipt utility](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/ReceiptUtility.swift): `Sources/AppStoreServerLibrary/ReceiptUtility.swift`

### Signed Data Verification

- [Signed data verifier](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/SignedDataVerifier.swift): `Sources/AppStoreServerLibrary/SignedDataVerifier.swift`
- [Certificate chain verifier](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/ChainVerifier.swift): `Sources/AppStoreServerLibrary/ChainVerifier.swift`

### Signature Creation

- [Promotional offer signer](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/PromotionalOfferSignatureCreator.swift): `Sources/AppStoreServerLibrary/PromotionalOfferSignatureCreator.swift`
- [JWS signature creator](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/JWSSignatureCreator.swift): `Sources/AppStoreServerLibrary/JWSSignatureCreator.swift`

### Domain Payloads

- [Transaction payload](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/JWSTransactionDecodedPayload.swift): `Sources/AppStoreServerLibrary/Models/JWSTransactionDecodedPayload.swift`
- [Renewal payload](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/JWSRenewalInfoDecodedPayload.swift): `Sources/AppStoreServerLibrary/Models/JWSRenewalInfoDecodedPayload.swift`
- [Notification payload](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/ResponseBodyV2DecodedPayload.swift): `Sources/AppStoreServerLibrary/Models/ResponseBodyV2DecodedPayload.swift`
- [App transaction](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/AppTransaction.swift): `Sources/AppStoreServerLibrary/Models/AppTransaction.swift`
- [Consumption request](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/ConsumptionRequestV1.swift): `Sources/AppStoreServerLibrary/Models/ConsumptionRequestV1.swift`
- [Commerce request models](https://github.com/apple/app-store-server-library-swift/blob/main/Sources/AppStoreServerLibrary/Models/AdvancedCommerceSubscriptionModifyInAppRequest.swift): `Sources/AppStoreServerLibrary/Models/AdvancedCommerceSubscriptionModifyInAppRequest.swift`

### Other components

- **App server**
- **Apple server APIs**
- **OCSP responder**

## Connections

- App server → API client: calls
- API client → Apple server APIs: sends requests
- Apple server APIs → API client: returns responses
- App server → Receipt utility: submits receipt
- Receipt utility → App server: returns transaction ID
- App server → Signed data verifier: submits signed data
- Signed data verifier → Certificate chain verifier: validates signature
- Certificate chain verifier → OCSP responder: checks revocation
- Signed data verifier → Transaction payload: decodes as
- Signed data verifier → Renewal payload: decodes as
- Signed data verifier → Notification payload: decodes as
- Signed data verifier → App transaction: decodes as
- App server → Promotional offer signer: requests signature
- App server → JWS signature creator: requests signature
- App server → Commerce request models: provides request data
- App server → Consumption request: provides consumption data
