Fetching Current Tokens from TMP API
After collecting deviceAccountIdentifiers from PassKit, the application should send them to the TMP API to retrieve the current token status.
Use the endpoint:
POST /issuer/push-provisioning/tokens/searches
For Apple Pay, the request must include walletType: APPLE_PAY and tokenUniqueReferences, where tokenUniqueReferences should contain the previously collected deviceAccountIdentifiers. The response contains token data such as externalCardId, tokenStatus, and processStatus.
Example Request Body
{
"walletType": "APPLE_PAY",
"tokenUniqueReferences": [
"8YUZErg1CWsPG5uVa",
"9XVAfh2DXWtQH6wWb"
]
}
Swift Example
import Foundation
struct GetTokensRequest: Encodable {
let walletType: String
let tokenUniqueReferences: [String]
}
struct TokenResponse: Decodable {
let tokenUniqueReference: String?
let panUniqueReference: String?
let externalCardId: String?
let tokenStatus: String?
let authorizationPath: String?
let processStatus: String?
}
let requestBody = GetTokensRequest(
walletType: "APPLE_PAY",
tokenUniqueReferences: deviceAccountIdentifiers
)
let url = URL(string: "https://your-tmp-api-base-url/issuer/push-provisioning/tokens/searches")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try JSONEncoder().encode(requestBody)
let (data, response) = try await URLSession.shared.data(for: request)
guard let httpResponse = response as? HTTPURLResponse,
httpResponse.statusCode == 200 else {
throw URLError(.badServerResponse)
}
let tokens = try JSONDecoder().decode([TokenResponse].self, from: data)