# Import loyalty data

> If you are replacing an existing loyalty system with Talon.One, you can import all loyalty points and loyalty cards from the old system into Talon.One.

> For the complete documentation index, see [llms.txt](https://docs.talon.one/llms.txt).

:::tip Overview
- You can import loyalty data programmatically using the [Import loyalty points][importLP] and/or [Import loyalty cards][importLC] endpoints.
- You can also import loyalty points and loyalty cards directly from the UI.
:::

## Prerequisites

1. You have created a [profile-based loyalty program](/docs/product/loyalty-programs/profile-based/create-pb-programs.md) and a [card-based loyalty program](/docs/product/loyalty-programs/card-based/create-cb-programs.md) in Talon.One.
1. You have [created a Management API key](/docs/product/account/dev-tools/manage-mapi-keys.md#create-a-management-api-key)
   that allows access to the [Import loyalty points][importLP] and/or [Import loyalty cards][importLC] endpoints.

## Import loyalty points

### Step 1: Collect the existing loyalty points

From your legacy loyalty system, export the existing loyalty points in any format available, ideally as CSV.

This step depends on your loyalty system, which usually offers an API, a CSV export
functionality, or a way to export points directly from the database.

### Step 2: Generate a CSV file to import the loyalty points

Talon.One requires your loyalty points to be provided as a CSV file:

- Use the following sample to create a loyalty points CSV file to import into a customer profile.

  ```csv title="Loyalty point CSV structure"
  customerprofileid,amount,startdate,expirydate,subledgerid,reason
  URNGV8294NV,100,2020-11-10T23:00:00Z,2020-11-11T23:00:00Z,subledger1,appeasement
  ```

  :::note
  See the column descriptions in the [Import loyalty points][importLP] docs.
  :::

- Use the following sample to create a loyalty points CSV file to import into a loyalty card:

  ```csv title="Loyalty card CSV structure"
  identifier,amount,startdate,expirydate,subledgerid,reason
  summer-loyalty-card-0543,100,2020-11-10T23:00:00Z,2020-11-11T23:00:00Z,subledger1,appeasement
  ```

  :::note
  See the column descriptions in the [Import loyalty cards][importLC] docs.
  :::

### Step 3: Import the loyalty points

You can import loyalty points into a customer profile or into a loyalty card
programmatically using the
[Import loyalty points](/management-api#tag/Loyalty/operation/importLoyaltyPoints)
endpoint, or directly from the UI.

#### Import loyalty points programmatically

Send a request to the [Import loyalty points](/management-api#tag/Loyalty/operation/importLoyaltyPoints)
endpoint with your generated CSV file as the payload. Assuming you have your CSV file
saved in the same folder, the curl request looks as follows:

```bash
curl https://example.talon.one/v1/loyalty_programs/$YOUR_LOYALTYPROGRAMID}/import_points \
 -H "authorization: ManagementKey-v1 $YOUR_API_KEY" \
 -F "file=@/path/to/yourfile.csv"
```

#### Import loyalty points from the UI

When you import loyalty points, they are added to potential existing points for a given
customer profile.

1. On the leftmost menu, click <Loyalty className="icon"/> **Loyalty**.
1. Click the name of the program where you want to import points.
1. At the top right of the dashboard, click **Manage Loyalty Data** >
   **Import Loyalty Points**.
1. In the pop-up that appears, click **Upload a CSV file** to select the CSV file of
   loyalty points from your computer.
1. Click **Import Loyalty Points**.

## Import loyalty cards

### Step 1: Collect the existing loyalty cards

From your legacy loyalty system, export the existing loyalty cards in any format available.

:::note
This step depends on your loyalty system, which usually offers an API, a CSV export
functionality, or a way to export cards directly from the database.
:::

### Step 2: Generate a CSV file to import the loyalty cards

Talon.One requires your loyalty cards to be provided as a CSV file.

Use this sample to create a loyalty cards CSV file to import into a card-based loyalty
program:

```csv
identifier,state,customerprofileids
123-456-789AT,active,JaneDoe;UserA
```

:::note
The sample contains all supported columns. The `customerprofileids` column is optional.
See the column descriptions in the [Import loyalty cards](/management-api#tag/Loyalty-cards/operation/importLoyaltyCards) docs.
:::

### Step 3: Import the loyalty cards

You can import loyalty cards into a card-based loyalty program programmatically using the
[Import loyalty cards](/management-api#tag/Loyalty-cards/operation/importLoyaltyCards)
endpoint, or directly from the UI.

#### Import loyalty cards programmatically

Send a request to the [Import loyalty cards](/management-api#tag/Loyalty-cards/operation/importLoyaltyCards)
endpoint, with your generated CSV file as the payload. Assuming you have your CSV file
saved in the same folder, the curl request looks as follows:

```bash
curl https://example.talon.one/v1/loyalty_programs/$YOUR_LOYALTYPROGRAMID}/import_cards \
 -H "authorization: ManagementKey-v1 $YOUR_API_KEY" \
 -F "file=@/path/to/yourfile.csv"
```

#### Import loyalty cards from the UI

1. Click the name of the card-based loyalty program where you want to import cards.
1. On the left-side menu of the program, click **Loyalty Cards**.
1. At the top right of the page, click **Import Cards/Points** > **Import Loyalty Cards**.
1. In the pop up that appears, click **Upload a CSV file** and select the CSV file with
   the cards you want to import.
1. Click **Import Cards**.

:::note
The readiness of your cards depends on the status and Customer ID info in the imported CSV
file. Read more about [managing loyalty cards](/docs/product/loyalty-programs/card-based/manage-loyalty-cards.md).
:::

## Related links

- [Manage loyalty data](/docs/product/loyalty-programs/profile-based/manage-pb-lp-data.md)
- [Manage loyalty cards](/docs/product/loyalty-programs/card-based/manage-loyalty-cards.md)

[importLP]: /management-api#tag/Loyalty/operation/importLoyaltyPoints
[importLC]: /management-api#tag/Loyalty-cards/operation/importLoyaltyCards
