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

# correlationID を使用する

トークン化の追跡用の correlation ID を取得および設定します。

## 概要

各トークン化プロセスには、関連付けられた `correlationID` があります。トラブルシューティングに役立てるため、この値をThalesと共有できます。

この識別子は次の2つの方法で取得できます。

* 有効性チェックの成功時、またはトークン化エラーから取得します。
* 呼び出し時に独自の `correlationID` を割り当てることもできます。 `checkEligibility()` .

## SDKの統合

### checkEligibility(...)からcorrelationIDを取得する `checkEligibility(...)`

* 成功した場合 `checkEligibility(...)`
  * 有効性チェックが成功した後、 `acceptanceData.correlationID`.
  * 後で同じトークン化プロセスを追跡する必要がある場合は、この値を保存してください。
* 次のエラー発生後 `checkEligibility(...)`
  * エラーを捕捉したらすぐに `correlationID` を読み取るか、保存してください。

次の例では、 `correlationID` `checkEligibility(...)`

```swift
// digitizeCard()中にcorrelationIDを取得
let cardDigitizationService = CardDigitizationService()
let authenticationToken = Data() // グリーンフローの登録に使用するイシュアのバックエンドトークン。
let fcmToken = "FACY6074293608087656831WRF1234" // 例示用。

do {
    try await cardDigitizationService.digitizeCard(
        withTNC: termsAndConditions.accept(),
        pushToken: fcmToken, // 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 {
    // その他のエラーを処理します。
}

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

### カスタムcorrelationIDを設定する

設定できるのは `correlationID` のみです。 `checkEligibility(...)`.

次の `checkEligibility(...)` のバリエーションは、このパラメーターをサポートしています。

イシュアのバックエンド、デジタルウォレットアプリケーション、Thalesのログにまたがってトークン化プロセスを追跡する場合は、カスタム値を使用してください。

次のように、独自の識別子形式を使用することもできます。

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

#### インストゥルメントデータでカスタムcorrelationIDを設定する

```swift
// カードデータを使用したcheckEligibility()
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 {
    // その他のエラーを処理します。
}
```

#### pushSessionID を使用してカスタムの correlationID を設定する

```swift
// pushSessionID を指定した checkEligibility()
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 {
    // その他のエラーを処理します。
}
```


---

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