> ## Documentation Index
> Fetch the complete documentation index at: https://developer.zamp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Syncing Historical Transactions

> If onboarding a new customer onto your platform, sync over older transactions for Zamp to determine economic nexus status.

# Overview

Part of Zamp's managed service, Zamp includes a thorough nexus analysis of any customer.

Unless a business is brand-new has made no prior transactions, Zamp will perform the nexus analysis to track when they would need to register in different jurisdictions. As a result, your integration platform should handle syncing transactions between user-determined dates.

## Endpoints Used

```text theme={null}
GET /transactions?<parameters>
GET /transactions/<id>
POST /transactions
```

## What Does the Integration Platform Need to Do?

| Action                             | Why                                                                   |
| ---------------------------------- | --------------------------------------------------------------------- |
| Fetching Existing Transaction IDs  | Ensuring duplicate transactions aren't being sent to Zamp             |
| Gathering Transaction Information  | Build *Transaction Objects* for gross amounts and address information |
| Passing Prior Transactions to Zamp | For customer's selected date range, push transactions to Zamp         |

# Recommended Workflow

<Steps>
  <Step title="Customer Determines Date Range">
    The client should navigate to a **Historical Sync** page or **Bulk Sync** page and be prompted to select a date range to sync transactions to Zamp.
  </Step>

  <Step title="Post Sync Trigger, Integration Fetches Transactions in Zamp">
    <Warning>
      Keep in mind that the integration will only return transactions that are tied to the API Key you are using. Transactions pushed from other sources will not be returned by `GET` requests.
    </Warning>

    1. Initiate a `GET /transactions` call to fetch transactions with the given parameters.
       1. Parameters are listed [here](https://developer.zamp.com/api-reference/transactions#list-all-transactions).
  </Step>

  <Step title="Review and Store Returned Transaction IDs and Names">
    The transaction fetch will return a list of transactions (and any associated tax information), along with `ID` and `name` for those transactions.
  </Step>

  <Step title="Building Transactions to Push">
    1. For the selected date range, you will build transaction objects for any transactions in the date range.
    2. For all transactions, ensure the `ID` and `name` do not match any transactions already in Zamp. 
    3. For each transaction, include as much information as possible. At minimum, include:

    | Property                           | Why                                                                                                                                                          |
    | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
    | `total`                            | Gross total of the transaction (item cost, shipping, discounts, taxes collected).                                                                            |
    | `lineItems`                        | Line item `quantity` and `amount`.                                                                                                                           |
    | `transactedAt`                     | The timestamp of when the transaction occurred.                                                                                                              |
    | `shipToAddress`                    | This will determine where this transaction would contribute to economic nexus.                                                                               |
    | `taxCollected`                     | For whichever engine or calculation source previously used, include what was collected for the customer. If `taxCollected` is zero, ensure that is included. |
    | `recalculate`                      | If Zamp does **NOT** need to calculate tax, include `"recalculate": false`.                                                                                  |
    | `entity` or `purpose` for `RESALE` | You can pass whether or not a transaction was exempt or not, which can impact economic nexus contribution.                                                   |
    | `marketplace`                      | If a transaction came through a marketplace, you can tag transactions as such.                                                                               |
  </Step>

  <Step title="Pushing Transactions">
    1. For transactions that do **NOT** exist in Zamp already, make a `POST /transactions` call for every transaction from the previous step.
           <Note>
             Zamp will return a 409 for any transaction that already exists in Zamp as a safeguard.
           </Note>
    2. Ensure every unique transaction is accepted with a `200 - Successful`.
    3. Return a breakdown to the user of:
       1. Total number of attempted transactions
       2. Number of successful transactions
       3. Number of failed transactions
       4. Number of transactions already listed in Zamp
  </Step>

  <Step title="Customer to Review Transactions in Zamp">
    Once the sync is completed, the user should be prompted to navigate to Zamp for transaction review.
  </Step>
</Steps>
