> For the complete documentation index, see [llms.txt](https://docs.payments.thalescloud.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/additional-features/use-correlationid.md).

# Use correlationID

## Overview

Each Tokenization process has an associated `correlationID` that you can share with Thales to help with troubleshooting.

This identifier can be obtained in two ways:

* From a successful eligibility check or from a Tokenization error.
* You can also assign your own custom `correlationID` when calling `checkEligibility()` .

## SDK integration

### Get correlationID from `checkEligibility(...)`

* After successful `checkEligibility(...)`
  * After a successful eligibility check, read `acceptanceData.correlationID`.
  * Store this value if you need to trace the same Tokenization process later.
* After error on `checkEligibility(...)`
  * Read or store `correlationID` as soon as the error is caught.

The following example explains how to get `correlationID` `checkEligibility(...)`

```swift
// Get correlationID during digitizeCard()
let cardDigitizationService = CardDigitizationService()
let authenticationToken = Data() // Issuer backend token for green flow enrollment.
let fcmToken = "FACY6074293608087656831WRF1234" // Example only.

do {
    try await cardDigitizationService.digitizeCard(
        withTNC: termsAndConditions.accept(),
        pushToken: fcmToken, // Firebase Cloud Messaging (FCM) token
        language: "en",
        authenticationToken: authenticationToken
    )
} catch let error as CardDigitizationService.Error {
    let returnedCorrelationID = error.correlationID
} catch let error as CardDigitizationService.DigitizeError {
    let returnedCorrelationID = error.correlationID
} catch {
    // Handle other errors.
}

for await state in await cardDigitizationService.eventStream {
    switch state {
    case let .digitizationApproved(digitalCardID):
        _ = digitalCardID
        return
    case let .errorEncountered(error):
        if let error = error as? CardDigitizationService.Error {
            let returnedCorrelationID = error.correlationID
        } else if let error = error as? CardDigitizationService.DigitizeError {
            let returnedCorrelationID = error.correlationID
        }
        return
        default:
        break
    }
}
```

### Set a custom correlationID

You can set `correlationID` only in `checkEligibility(...)`.

The following `checkEligibility(...)` variants support this parameter.

Use a custom value when you want to trace a Tokenization process across the issuer backend, the digital wallet application, and Thales logs.

You can also use your own identifier format, for example:

```
ORDER-12345-SESSION-67890
```

#### Set a custom correlationID with instrument data

```swift
// checkEligibility() with card data
let encryptedDataComponent = CardDigitizationService.InstrumentDataComponents(
    publicKey: pubKey,
    identifier: pubKeyIdentifier,
    pan: pan,
    expiryDate: expiryDate,
    cvv: cvv
)
let instrumentData = encryptedDataComponent.instrumentData()
let eligibilityData = "<eligibilityData>"
let correlationID = "<correlationID>"

do {
    let cardDigitizationService = try await CardDigitizationService()
    let acceptanceData = try await cardDigitizationService.checkEligibility(
        eligibilityData,
        instrumentData: instrumentData,
        correlationID: correlationID
    )
    let returnedCorrelationID = acceptanceData.correlationID
    let tnc = acceptanceData.termsAndConditions
} catch let error as CardDigitizationService.Error {
    let returnedCorrelationID = error.correlationID
} catch let error as CardDigitizationService.EligibleError {
    let returnedCorrelationID = error.correlationID
} catch {
    // Handle other errors.
}
```

#### Set a custom correlationID with a pushSessionID

```swift
// checkEligibility() with pushSessionID
let eligibilityData = "<eligibilityData>"
let pushSessionID = "<pushSessionIDFromIssuerBackend>"
let correlationID = "<correlationID>"

do {
    let cardDigitizationService = try await CardDigitizationService()
    let acceptanceData = try await cardDigitizationService.checkEligibility(
        eligibilityData,
        pushSessionID: pushSessionID,
        correlationID: correlationID
    )
    let returnedCorrelationID = acceptanceData.correlationID
    let tnc = acceptanceData.termsAndConditions
} catch let error as CardDigitizationService.Error {
    let returnedCorrelationID = error.correlationID
} catch let error as CardDigitizationService.EligibleError {
    let returnedCorrelationID = error.correlationID
} catch {
    // Handle other errors.
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.payments.thalescloud.io/nfc-wallet-sdk-ios/additional-features/use-correlationid.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
