<!--
{
  "availability" : [
    "iOS: 27.2.0 -",
    "iPadOS: 27.2.0 -",
    "macOS: 27.2.0 -",
    "tvOS: 27.2.0 -",
    "visionOS: 27.2.0 -",
    "watchOS: 27.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "StoreKit",
  "identifier" : "/documentation/StoreKit/ExternalPurchaseCustomLink/token(for:)-6pixj",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "StoreKit"
    ],
    "preciseIdentifier" : "s:8StoreKit26ExternalPurchaseCustomLinkO5token3forAC5TokenVSgAC0I4TypeV_tYaKFZ"
  },
  "title" : "token(for:)"
}
-->

# token(for:)

Returns an external purchase token of the specified token type.

```
static func token(for tokenType: ExternalPurchaseCustomLink.TokenType) async throws -> ExternalPurchaseCustomLink.Token?
```

## Parameters

`tokenType`

The type of token to request.

## Return Value

Returns an [`ExternalPurchaseCustomLink.Token`](/documentation/StoreKit/ExternalPurchaseCustomLink/Token) of the type you specify, or returns `nil` if there isn’t an active token of the specified type. This method throws a [`StoreKitError`](/documentation/StoreKit/StoreKitError) if your app isn’t eligible to use this API.

## Discussion

Use this method to request tokens when your app uses the [`ExternalPurchaseCustomLink`](/documentation/StoreKit/ExternalPurchaseCustomLink) API.

The token types you request depend on the region in which your app offers external purchases:

- For external purchases in the European Union (EU), request the `ACQUISITION` and `SERVICES` token types when your app launches, and immediately associate the tokens with a customer account on your server. You can also call this method at any other time, such as before communicating or promoting offers. The method returns a token of either token type until it expires.
- For external purchases in Brazil and Japan, request the [`withinApp`](/documentation/StoreKit/ExternalPurchaseCustomLink/TokenType/withinApp) or [`outOfApp`](/documentation/StoreKit/ExternalPurchaseCustomLink/TokenType/outOfApp) token types. Request an [`withinApp`](/documentation/StoreKit/ExternalPurchaseCustomLink/TokenType/withinApp) token type for workflows that use an alternative payment provider inside the app. Request a [`outOfApp`](/documentation/StoreKit/ExternalPurchaseCustomLink/TokenType/outOfApp) token type for workflows in which customers can complete transactions on a website, outside of the app. For more information, see [Payment options on the App Store in Brazil](https://developer.apple.com/support/payment-options-on-the-app-store-in-brazil) and [Payment options on the App Store in Japan](https://developer.apple.com/support/payment-options-on-the-app-store-in-japan), respectively.

The [`withinApp`](/documentation/StoreKit/ExternalPurchaseCustomLink/TokenType/withinApp) and [`outOfApp`](/documentation/StoreKit/ExternalPurchaseCustomLink/TokenType/outOfApp) token types for Japan and Brazil are available in iOS 27.2 and later.

> Tip: Request tokens before every potential transaction to ensure you have current tokens.

### Read and report tokens

Decode the token to read its contents, including its expiration date. For more information, see [Receiving and decoding external purchase tokens](/documentation/StoreKit/receiving-and-decoding-external-purchase-tokens). For a code example that shows requesting tokens, see [`ExternalPurchaseCustomLink`](/documentation/StoreKit/ExternalPurchaseCustomLink).

Report tokens and all transactions associated with the tokens from your server, using the <doc://com.apple.documentation/documentation/ExternalPurchaseServerAPI>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)