# Migrate Stored Cards to Firstoken

If your organization currently stores card data in your own systems, migrating it to the Firstoken vault eliminates raw card storage and replaces it with persistent tokens. From that point forward, you use tokens — not card numbers — to initiate payments, reducing your PCI DSS scope significantly.

There are two ways to migrate:

| Method                  | Best for                                         | Requires development? |
| ----------------------- | ------------------------------------------------ | --------------------- |
| **SFTP File Migration** | Large existing card databases, batch migration   | No                    |
| **Tokenization API**    | Real-time card onboarding, incremental migration | Yes                   |

This guide covers SFTP File Migration. For the API-based approach, see [Permanent Tokenization](https://claude.ai/api/permanent-tokenization).

***

### SFTP File Migration

You export your stored card records to a flat file, send it to Firstoken through a secure SFTP connection, and receive a processed file back — with every card number replaced by a persistent Firstoken token. No development is required on your side.

This is the fastest path to migrating a large card base. Once you receive the output file, you update your records and the migration is done.

```mermaid
sequenceDiagram
    participant C as Your System
    participant S as Firstoken SFTP Server
    participant P as Firstoken
    participant O as Output

    C->>C: Export card records to file
    C->>C: Encrypt file with Firstoken PGP public key
    C->>S: Upload file to your assigned input path
    S->>P: File received — processing starts
    P->>P: Tokenize card numbers
    P->>O: Output file written (tokens replace card numbers)
    C->>O: Retrieve output file
    C->>C: Replace card numbers with tokens in your system
```

***

### Getting Started

SFTP File Migration is configured by Firstoken. To get started, contact our Support Team with the following information:

| Item                     | Description                                                                                          |
| ------------------------ | ---------------------------------------------------------------------------------------------------- |
| File format              | Delimited (CSV, pipe-separated, etc.) or fixed-position                                              |
| Delimiter                | If delimited: the character separating fields (e.g. `,`)                                             |
| Field mapping            | Which column or position contains card number, expiration date, cardholder name, CVV (if applicable) |
| Date format              | Format used for expiration date (e.g. `MMYY`, `YYYY-MM`)                                             |
| Approximate record count | Estimated number of cards to migrate                                                                 |
| SSH public key           | Public key your system will use to authenticate to the SFTP server                                   |

Firstoken will provide you with:

* SFTP hostname and your assigned input and output paths
* PGP public key to encrypt your file before upload
* Confirmation of field mapping before processing begins

***

### Uploading Your File

#### 1. Prepare your file

Export your card records to a flat file. One record per card, using the format agreed upon with Firstoken. For example, a comma-delimited file might look like:

```
4111111111111111,12,2027,John Doe
5500005555555559,09,2026,Jane Smith
```

#### 2. Encrypt the file

Encrypt your file using the PGP public key Firstoken provides. Files that are not encrypted will not be processed.

```bash
gpg --output migration_file.gpg \
    --encrypt \
    --recipient "Firstoken - Your Company Name" \
    migration_file.csv
```

#### 3. Upload via SFTP

Connect to the Firstoken SFTP server and upload the encrypted file to your assigned input path.

| Environment | Host                         |
| ----------- | ---------------------------- |
| Staging     | `files-staging.firstoken.co` |
| Production  | `files.firstoken.co`         |

```bash
sftp -i your_private_key your_username@files.firstoken.co
sftp> put migration_file.gpg
```

***

### Receiving the Output

Once processing is complete, Firstoken writes the output file to your assigned output path. The file preserves your original structure — card numbers are replaced with persistent Firstoken tokens:

```
tok_live_4xKj9mN2pQr7vZ,12,2027,John Doe
tok_live_8bTf3hW6sLx1cY,09,2026,Jane Smith
```

Each token maps to the card in the same row of your input file. Use the output file to update your records, replacing stored card numbers with their corresponding tokens.

***

### FAQ

| Question                                      | Answer                                                                                                                                             |
| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| Do I need to build anything?                  | No. The only steps on your side are preparing the file, encrypting it, and uploading via SFTP.                                                     |
| Can I migrate in batches?                     | Yes. Each uploaded file is processed independently. Split large datasets across multiple files if needed.                                          |
| What if the same card appears more than once? | Firstoken issues the same persistent token for the same card number every time. Duplicates across files or batches will resolve to the same token. |
| What happens if a record has an error?        | Records that cannot be processed are written to a separate error output. Firstoken will confirm the error format during onboarding.                |
| Can I test before migrating production data?  | Yes. Firstoken can configure access to the staging environment for validation before you run the production migration.                             |
| How do I get started?                         | Contact our Support Team with the information listed under Getting Started.                                                                        |


---

# Agent Instructions: 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://firstoken.gitbook.io/api-docs/guides/migrate-stored-cards-to-firstoken.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.
