Skip to content
Docs menu

Copy the text

Your browser did not allow copying. The text below is selected: press Ctrl+C, or ⌘C on a Mac.

Add an App Store purchase

Checks the signed transaction from StoreKit and adds its credits once. Sending the same transaction again adds nothing. Finish the transaction in StoreKit after a 200.

POSThttps://api.switchfile.io/v1/account/app-store/transactions

Needs an API key: Authorization: Bearer YOUR_API_KEY. See Authentication.

Example

curl "https://api.switchfile.io/v1/account/app-store/transactions" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "signed_transaction": "eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlF..."
  }'

Request body

  • signed_transactionstringrequired

    Transaction.jwsRepresentation from StoreKit

    10 to 64000 characters

Responses

  • 200OK
    • balancestring (integer) | integerrequired
    • creditedbooleanrequired

      false: nothing was added now, because the transaction was added before or Apple refunded it (finish it in StoreKit anyway)

    • creditsstring (integer) | integerrequired

      Credits this request added (0 when nothing was added)

    • product_idstringrequired
    • refundedbooleanrequired

      true: Apple refunded the whole purchase, so it adds no credits

    • transaction_idstringrequired
    200 application/json
    {
      "transaction_id": "2000000812345678",
      "product_id": "io.switchfile.app.credits1000",
      "credits": 1000,
      "credited": true,
      "refunded": false,
      "balance": 2240
    }
  • 401The API key is missing or not valid
    401 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-unauthenticated",
      "title": "Unauthenticated",
      "status": 401,
      "code": "UNAUTHENTICATED",
      "detail": "Missing or invalid API key."
    }
  • 403The purchase was made for another account (appAccountToken), or is a test purchase from an account that is not a test account
    403 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-transaction-not-yours",
      "title": "Transaction not yours",
      "status": 403,
      "code": "TRANSACTION_NOT_YOURS",
      "detail": "This purchase was made for another switchfile account."
    }
  • 404Does not exist for this account
    404 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-not-found",
      "title": "Not found",
      "status": 404,
      "code": "NOT_FOUND",
      "detail": "Not found."
    }
  • 409Already added to another account
    409 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-transaction-already-used",
      "title": "Transaction already used",
      "status": 409,
      "code": "TRANSACTION_ALREADY_USED",
      "detail": "This purchase was already added to another account."
    }
  • 422Not signed by the App Store, or an unknown product
    422 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-invalid-transaction",
      "title": "Invalid transaction",
      "status": 422,
      "code": "INVALID_TRANSACTION",
      "detail": "The transaction is not signed by the App Store."
    }
  • 429Too many requests or a daily quota is used up. See Retry-After
    429 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-rate-limit-exceeded",
      "title": "Rate limit exceeded",
      "status": 429,
      "code": "RATE_LIMIT_EXCEEDED",
      "detail": "Too many requests. Try again in 12 seconds."
    }
  • 503Not available right now or busy. See Retry-After
    503 application/problem+json
    {
      "type": "https://switchfile.io/docs/api/v1#errors-purchases-unavailable",
      "title": "Purchases unavailable",
      "status": 503,
      "code": "PURCHASES_UNAVAILABLE",
      "detail": "Purchases in the app are not available right now."
    }

Error bodies and codes are explained in Errors.