Skip to main content

Import av Orderhistorik

Here you can learn how to import order history data for your subscribers

Updated over a week ago

Introduction

If you have access to a file containing your customers’ order history from your current or a previous e-commerce platform, you can import that data into your Rule account via our open API, allowing you to register your customers’ past purchases in the system.


IMPORTANT

An order history import should always be performed first, before importing any other subscribers into the account.

Otherwise, the order data may end up in the wrong chronological order, and duplicate orders may be created.

This is an advanced feature and requires careful attention, following each step closely, and preferably some prior knowledge of file imports via API.


File Format

The import is done using a file that can usually be exported from your e-commerce system.

Ideally, the file should contain a maximum of 50,000 rows. If the file is larger, you can split it into several smaller files and import them one after another.


Remember that column headers must be included in every file you import so that the data is correctly placed.

The file must be saved in CSV format with comma separation.


File Structure

These two columns are required regardless of the other content in the file:

  • Email address – An email address is required for the system to create the subscriber.

  • Phone number – This column must exist in the file, but the rows may be left empty if phone numbers are not available for your subscribers.

In addition to these, you may include any further data. However, if you plan to integrate your Rule account with an e-commerce platform, we recommend using column headers that match those used by that platform for future order calls.


For example, if the total order amount is labeled “Price” in your import file but sent as “TotalAmount” from your e-commerce platform, the same value will end up in different fields depending on whether it was imported here or fetched automatically from the platform.

For order data specifically, each order must be placed on its own row in the import file, and all products in the order must be placed in a single field.

If this structure is not followed, separate order entries may be created in the subscriber profile for each product in the order.

For example: Product ID and SKU as shown below.


Postman

To import the file, we recommend using the application Postman.

You can read more and download the application from their official website:
Postman Download


API Key

For Postman to upload the order data to your account, you need to generate an API key.

You can do this under “Developers” in your account settings by clicking “New API Key”.


Import Process

Now that your file, API key, and Postman are ready, we can begin the import process. Follow the steps below:

  1. Start Postman

  2. Create a new request by clicking “New” and selecting “HTTP”

  3. Choose request type "POST" and add the following URL:
    https://app.rule.io/api/v2/subscribers/historical-import

  4. Go to “Body” and add the following keys:

    • file - Set the type to File, then upload your file using “Select files”.

    • email_field - Enter the column header in your file that contains the customers’ email addresses.

    • phone_field - Enter the column header that contains the customers’ phone numbers.
      (This column may be empty if phone numbers are unavailable.)

    • separator - Specify how values are separated in the file. Enter “;”
      (Even if the CSV file uses comma separation, Postman requires a semicolon here.)

    • tags - Determines which tag the members will be assigned. We recommend “OrderCompleted” as it is the standard tag for incoming order data.

  5. Go to the “Authorization” tab
    Select Type: API Key and paste the API key you generated in your settings into the “Value” field.

  6. Submit the Request

    Double-check all previous steps, then click “Send”.
    Important: The request may take some time to process. Click Send only once and allow the system to complete the import.​

  7. Optional: Save the request
    If you plan to import multiple files, you can save the request in Postman and reuse it for subsequent imports.

  8. Verify the Data in Rule

    Allow time for the import to finish, then verify that all data has been imported correctly.

  9. Done!
    If all data has been imported and placed correctly in your account, you're finished — your order history from your previous system is now in your Rule account.


Did this answer your question?