> 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/central-issuance/implement-central-issuance/card-order/magnetic-stripe-tracks.md).

# Magnetic stripe tracks

<div align="center"><figure><img src="/spaces/ol7FqojHqm5it3effNc4/files/buuhYg3pmiNWRcvC4duR" alt="" width="563"><figcaption><p>Magnetic stripe tracks (ISO/IEC 7813).</p></figcaption></figure></div>

D1 builds magnetic stripe Track 1, Track 2, and Track 3 during physical card personalization. You can also override any track by sending a full track value.

### How D1 selects track values

* If you provide `trackData.track1`, `trackData.track2`, or `trackData.track3`, D1 uses that value as-is.
* If you omit a track, D1 computes it from your D1 API inputs and your D1 configuration.

### Inputs used for personalization

Required D1 API inputs:

* `cardProductId`: Card product identifier configured during D1 onboarding.
* `encryptedData.pan`: Primary Account Number (PAN).
* `encryptedData.exp`: Expiry date, typically `YYMM` (for example, `2906`).

Optional D1 API inputs:

* `encryptedData.encodedName`: End user name for Track 1, pre-encoded per ISO/IEC 7813 rules.
* `encryptedData.cvv1`: CVV1 value used when your discretionary data pattern includes the `cvv` token. If omitted, D1 computes it using CVK.
* `paymentApplication.cvKeyIndex`: CVK index used when computing `cvv1`.
* `encryptedData.pvv`: PIN Verification Value (PVV) used when your discretionary data pattern includes the `pvv` token. If omitted, D1 computes it using the PIN verification key (PVK).
* `paymentApplication.pvKeyIndex`: PIN verification key index used when computing `pvv`.

Optional track overrides:

* `trackData.track1`: Full Track 1 value to use as-is.
* `trackData.track2`: Full Track 2 value to use as-is.
* `trackData.track3`: Full Track 3 value to use as-is.

### Configuration in D1

* `serviceCode`: 3‑digit service code used in Tracks 1 and 2.
* Discretionary data patterns per track (for example, `000000|cvv|000000`).
  * Use `cvv` in the pattern to inject `cvv1`.
  * Use `pvv` in the pattern to inject `pvv`.
* Key indexes (`cvKeyIndex`, `pvKeyIndex`) available for computation.

{% hint style="warning" %}
Including `pvv` in discretionary data is not standard for magstripe tracks. Only enable it if explicitly required by your configuration and risk policies.
{% endhint %}

{% hint style="info" %}
CVV1 is different from the Card security code (CSC, also known as CVV2). CVV1 appears on the magnetic stripe. CSC/CVV2 must never be stored on the card and is not part of the tracks.
{% endhint %}

{% hint style="warning" %}
Treat full track values as sensitive card data. Do not log them. Do not expose them to the end user.
{% endhint %}

### Track 1 computation (alphanumeric)

#### Format

```
%B<PAN>^<NAME>^<EXPIRY><SERVICE_CODE><DISCRETIONARY_DATA>?
```

#### How D1 builds it

1. Use `trackData.track1` if provided.
2. Otherwise, compute using:
   * `pan`, `exp`, `encodedName` from the API
   * `serviceCode` configured in D1
   * Track 1 discretionary data pattern configured in D1
   * `cvv1` if referenced by the pattern (`cvv` token)
     * Use the provided `cvv1`, or compute it via CVK (`cvKeyIndex`)
   * `pvv` if referenced by the pattern (`pvv` token)
     * Use the provided `pvv`, or compute it (`pvKeyIndex`)

#### Example

Inputs:

* `pan`: 5413330089012345
* `exp`: 2906
* `encodedName`: DOE/ALICE
* `serviceCode`: 201 (configured in D1)
* Track 1 discretionary pattern: `000000|cvv|000000`
* Computed `cvv1` (via `cvKeyIndex=3`): 123

Result:

```
%B5413330089012345^DOE/ALICE^2906201000000123000000?
```

Discretionary data = `000000` + `cvv1` + `000000` → `000000123000000`.

### Track 2 computation (numeric only)

#### Format

```
;<PAN>=<EXPIRY><SERVICE_CODE><DISCRETIONARY_DATA>?
```

#### How D1 builds it

1. Use `trackData.track2` if provided.
2. Otherwise, compute using:
   * `pan`, `exp` from the API
   * `serviceCode` configured in D1
   * Track 2 discretionary data pattern configured in D1
   * `cvv1` if referenced by the pattern (`cvv` token)
   * `pvv` if referenced by the pattern (`pvv` token)

#### Example

Inputs:

* `pan`: 5413330089012345
* `exp`: 2906
* `serviceCode`: 201 (configured in D1)
* Track 2 discretionary pattern: `00000|cvv|00000`
* Computed `cvv1`: 123

Result:

```
;5413330089012345=29062010000012300000?
```

Discretionary data = `00000` + `cvv1` + `00000` → `0000012300000`.

### Track 3 computation

{% hint style="info" %}
Track 3 is uncommon in most card programs. Enable it only if your card product requires it.
{% endhint %}

#### Format

```
;<PAN>=<BODY>?
```

#### How D1 builds it

1. Use `trackData.track3` if provided.
2. Otherwise, compute using `pan` from the API and a Track 3 body configured in D1.

#### Example

* `pan`: 5413330089012345
* `body` (configured in D1): 123456789012345

Result:

```
;5413330089012345=123456789012345?
```


---

# 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:

```
GET https://docs.payments.thalescloud.io/central-issuance/implement-central-issuance/card-order/magnetic-stripe-tracks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
