> 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).

# Usar correlationID

## Descripción general

Cada proceso de tokenización tiene un `correlationID` que puedes compartir con Thales para ayudar con 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 comprobación exitosa `checkEligibility(...)`
  * Después de una comprobación de elegibilidad exitosa, lee `acceptanceData.correlationID`.
  * Guarda este valor si necesitas rastrear el mismo proceso de tokenización más adelante.
* Después de un error en `checkEligibility(...)`
  * Leer o guardar `correlationID` en cuanto se capture el error.

El siguiente ejemplo explica cómo obtener `correlationID` `checkEligibility(...)`

```swift
// Obtener correlationID durante digitizeCard()
let cardDigitizationService = CardDigitizationService()
let authenticationToken = Data() // Token del backend del emisor para la inscripción en el flujo verde.
let fcmToken = "FACY6074293608087656831WRF1234" // Solo un 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 {
    // Gestionar otros errores.
}

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(...)`.

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

Usa un valor personalizado cuando quieras rastrear un proceso de tokenización en el backend del emisor, la aplicación de monedero 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() con datos de la tarjeta
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 {
    // Gestionar otros errores.
}
```

#### 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 {
    // Gestionar otros errores.
}
```


---

# 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/es/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.
