> 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/transit-digitization/implement-apple-transit/account-based-ticketing-abt/lifecycle-management/restore-from-device.md).

# Restore from Device

The restore process is initiated directly by the user from his device. The primary goal is to re-enable a previously parked transit card, which is securely linked to the user's iCloud account, and provision it onto the device.

This section provides an overview of the workflow, including detailed steps, sequence diagrams, and potential error scenarios.

### Workflow <a href="#workflow" id="workflow"></a>

Below are the high level steps of the restore workflow:

1. **Card Account Selection**: The user selects a previously parked transit card from the "Previous Cards" list on his device for restoration.
2. **Provisioning**: The selected card undergoes the standard provisioning workflow to be reactivated on the device.
3. **Restore Outcome**: Apple sends a notification to D1 Transit with the outcome of the restore workflow.

### Sequence diagram <a href="#sequence-diagram" id="sequence-diagram"></a>

#### Card Account Selection <a href="#card-account-selection" id="card-account-selection"></a>

The user begins the restore workflow by tapping the '+' button in Wallet. Apple then makes a getStatus(referenceIdentifier) request for each parked card linked to the user's iCloud account.

D1 Transit platform determines if the card is eligibile for provisioning (i.e. check whether it's already provisioned into another device linked to same iCloud account or not)

**Error Scenarios**

**No selectable pass**

Although it's not an error, if D1 Transit platform return an unknown state for all card accounts, it indicates that the transit cards are already provisioned on another device. As a result, the restore process is halted since there are no eligible transit cards available for provisioning on the current device.

<figure><img src="/spaces/SokLBgfEhZisVFcUdPiW/files/8nYknEGvhTov7xklieoi" alt=""><figcaption></figcaption></figure>

#### Provisioning <a href="#provisioning" id="provisioning"></a>

When the user selects a transit card for provisioning, Apple sends a provisioning bundle request to retrieve the encrypted provisioning bundle.

D1 Transit platform retrieves digital card bundle data required to build the encrypted provisioning bundle, then returns it back to Apple.

Apple proceeds to provision the card onto the user's device.

#### Provisioning Outcome <a href="#provisioning-outcome" id="provisioning-outcome"></a>

Once Apple receives the provisioning bundle, the keys and data are securely extracted and stored on the applet. After completing personalization, a notification is sent to D1 Transit to report the outcome of the provisioning workflow.

**Error Scenarios**

**Card fails to provision onto device**

If provisioning fails, Apple sends a notification to D1 Transit with eventType as provisioningFailure. D1 Transit notifies Transit issuer about the failure.

The digital card is deleted from D1 Transit system and the card account can be provisioned to another device under the same iCloud account.

**No Notification Request from Apple**

D1 Transit has a timeout period after sending the provisioning bundle to Apple. If no notification is received within the specified timeframe, D1 Transit sends a getStatus(provisioningBundleIdentifier) request to Apple to check the current state of the card.

If the card's state is active, meaning the card successfully provisioned onto the device and is available for use, D1 Transit completes the workflow considering the provisioning as successful

If the card's state is not active, D1 Transit completes the worklow considering the provisioning as failed, i.e. Transit issuer is notified.

<figure><img src="/spaces/SokLBgfEhZisVFcUdPiW/files/g6ZSAxYFVKnjJlkmR4ry" alt=""><figcaption></figcaption></figure>


---

# 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/transit-digitization/implement-apple-transit/account-based-ticketing-abt/lifecycle-management/restore-from-device.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.
