> 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/es/additional-features/use-correlationid.md). Agents can also search and read this documentation through its [MCP server](https://docs.payments.thalescloud.io/~gitbook/mcp).

# Usar correlationID

Obtener y establecer un ID de correlación para el seguimiento de la tokenización.

## Descripción general

Cada proceso de tokenización tiene asociado un `correlationID` que puedes compartir con Thales para facilitar la resolución de problemas.

Este identificador se puede obtener de dos maneras:

* A partir de una comprobación de elegibilidad exitosa o de un error de tokenización.
* También puedes asignar tu propio `correlationID` al llamar a `checkEligibility()` .

## Integración del SDK

### Obtener correlationID de `checkEligibility(...)`

* Después de una llamada exitosa a `checkEligibility(...)`
  * Después de una comprobación de elegibilidad exitosa, lee `acceptanceData.correlationID`.
  * Guarda este valor si necesitas hacer un seguimiento del mismo proceso de tokenización más adelante.
* Después de un error en `checkEligibility(...)`
  * Lee o guarda `correlationID` en cuanto captures el error.

En el siguiente ejemplo se explica cómo obtener `correlationID` `checkEligibility(...)`

```swift
// Get correlationID during digitizeCard()
let cardDigitizationService = CardDigitizationService()
let authenticationToken = Data() // Token del backend del emisor para la inscripción en el flujo verde.
let fcmToken = "FACY6074293608087656831WRF1234" // Solo como ejemplo.

do {
    try await cardDigitizationService.digitizeCard(
        withTNC: termsAndConditions.accept(),
        pushToken: fcmToken, // Token de Firebase Cloud Messaging (FCM)
        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
    }
}
```

### Establecer un correlationID personalizado

Puedes establecer `correlationID` solo en `checkEligibility(...)`.

Las siguientes variantes de `checkEligibility(...)` admiten este parámetro.

Usa un valor personalizado si quieres hacer un seguimiento de un proceso de tokenización en el backend del emisor, la aplicación de la cartera digital y los registros de Thales.

También puedes usar tu propio formato de identificador, por ejemplo:

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

#### Establecer un correlationID personalizado con datos del instrumento

```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.
}
```

#### Establecer un correlationID personalizado con un pushSessionID

```swift
// checkEligibility() con 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
