---
title: attributionToken()
framework: AdServices
role: symbol
role_heading: Type Method
platforms: [iOS 14.3+, iPadOS 14.3+, Mac Catalyst 14.3+, macOS 11.1+, visionOS 1.0+]
path: adservices/aaattribution/attributiontoken()
---

# attributionToken()

Generates a token.

## Declaration

```swift
class func attributionToken() throws -> String
```

## Discussion

Discussion The token that the framework returns is a Base64 encoded string and has a 24-hour TTL. You can provide the token to a Mobile Measurement Provider (MMP), or app developers can use it to make a POST API call to fetch attribution records within the 24-hour TTL window. Use a single token in the request body and use a content-type of text/plain in the header, as the following example shows: POST https://api-adservices.apple.com/api/v1/ --header 'Content-Type: text/plain' \ --data-raw

G9i5hC8lQJeGOfmS+MFycll/025oJEjtpZ+rs4AUkDEJh52fT8RrjwIR/h+2JOpXz4MRdmtcemL8WTTHfNN52tjqjbWupke40AAAAVADAAAAvQAAAIAgQF1+XF4Tl2IZ7Bw/M6ufUHt+UcIhuBeJT8YenB2v36bnZKEjvq/IH8rqXkRELTHdyiqOYtpy837+UjF/NjE6t1/l7sIn71b0t3FEXJd8QOtl3Bi6iQyJgGeN8w8X0MK1PDqz9nLJtRD/wl+p112qR2YrMDyyKnwNrbfRhnGB9AAAAB7wAXlwNHelWf5RT2bzSJcGflqELMCGoDEHIl7jF6kAAACfAb9ylY8ffdbTlyJODQYQ/6V9qbaBAAAAhgUBW39MQI1A0SZgNmZFz4KPaF94BxBzd4rDkjr/eSeuaXWCmEW3ZhBzE/MOM17hAPBVlDhTPcZ/2ybr3WYIkfb+AAg/7jxGpDXgTtco3fzTytnZpEaI5SenXHALIexQAUTBsfBW2HCMQuTRo+7anoWkf69656ZAWcSc3DEQ1CAkUSKO9X7iAAABBEQQBQA= important: A 404 response can occur if you make an API call too quickly after receiving a valid token. A best practice is to initiate retries at intervals of 5 seconds, with a maximum of three attempts. For details about error codes, see AAAttributionError. Response codes  |   |   |   |   |  Attribution payloads The attribution record is a data dictionary with key-value pairs that correspond to your Apple Ads campaigns and app downloads from devices running iOS 14 and later. Run reports to review detailed campaign metadata in the Apple Ads Platform API or Apple Ads Advanced. note: If you receive test data in your payload responses, check to make sure your app isn’t in developer mode. AdServices will return a test payload when developer mode is on: {   "attribution": true,   "orgId": 1234567890,   "campaignId": 1234567890,   "conversionType": "Download",   "clickDate": "2020-04-08T17:17Z",   "claimType": "Click",   "adGroupId": 1234567890,   "countryOrRegion": "US",   "keywordId": 123222,   "adId": 542317136,   "supplyPlacement": "APPSTORE_SEARCH_RESULTS" } Tap-through payload example A payload for tap-through attribution resembles the following: {   "attribution": true,   "orgId": 40669820,   "campaignId": 542370539,   "conversionType": "Download",   "clickDate": "2024-10-08T17:17Z",   "claimType": "Click",   "adGroupId": 542317095,   "countryOrRegion": "US",   "keywordId": 87675432,   "adId": 542317136,   "supplyPlacement": "APPSTORE_SEARCH_RESULTS" } View-through payload example A payload for view-through attribution resembles the following: {   "attribution": true,   "orgId": 40669820,   "campaignId": 542370539,   "conversionType": "Download",   "impressionDate": "2024-10-08T17:17Z",   "claimType": "Impression",   "adGroupId": 542317095,   "countryOrRegion": "US",   "keywordId": 87675432,   "adId": 542317136,   "supplyPlacement": "APPSTORE_SEARCH_RESULTS" } Pre-order payload example A payload for pre-order attribution on tap-throughs resembles the following: {   "attribution": true,   "orgId": 40669820,   "campaignId": 542370539,   "conversionType": "PreOrder",   "clickDate": "2020-04-08T17:17Z",   "claimType": "Click",   "adGroupId": 542317095,   "countryOrRegion": "US",   "keywordId": 87675432,   "adId": 542317136,   "supplyPlacement": "APPSTORE_SEARCH_RESULTS" } A payload for pre-order attribution on view-throughs resembles the following: {   "attribution": true,   "orgId": 40669820,   "campaignId": 542370539,   "conversionType": "PreOrder",   "impressionDate": "2020-04-08T17:17Z",   "claimType": "Impression",   "adGroupId": 542317095,   "countryOrRegion": "US",   "keywordId": 87675432,   "adId": 542317136,   "supplyPlacement": "APPSTORE_SEARCH_RESULTS" } Attribution payload descriptions  |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |   |  |  supplyPlacement descriptions  |   |   |   |   |
