This article is about CSV transaction upload API. This is by far the easiest way to upload sales transactions, and it is also blazing fast. About 1-3 lines of code are required to upload transactions. All you need to do is prepare a CSV file and then POST it via HTTP. Click here for more options.
Automating Transaction Uploads
To automatically import transaction data, follow these 3 steps: - Step 1 - Upload Sample CSV Data
- Step 2 - Get Upload URL
- Step 3 - Automatically Upload CSV Data
Step 1 - Upload Sample CSV Data
To import sample CSV data:
- Login to your workspace
- On the left pane, click on "Transactions > Add Transactions"
- Manually upload a CSV file with sample sales data
Step 2 - Get Upload URL
- One the upload is complete, click on "Transactions > All Transactions"
- Click on any of your uploaded transactions
- Click on the "Metadata" tab
- Copy the upload URL
Step 3 - Automatically Upload CSV Data
You now have the ability to programmatically upload transaction CSV data. First, make sure CSV data you upload programmatically has the exact same format as the CSV file used in step 1 (same header names, same field order, no extra spaces in headers, etc.).
To upload CSV data, simply POST CSV file content to your URL which should look like this:
The configuration hash represents the expected format while the API key grants access.
That's it - your programmatically uploaded CSV data is converted to transactions. We will accept posted data immediately, and start ingesting in the background.
Recommendations
Here are some tips to make the best use of the upload API:
Upload data at a reasonable cadence
- For example, upload daily or every few hours (NOT each time a single record is updated)
- Excessive uploads will result in throttling errors
Upload data using reasonable batch sizes
- For example, upload few MBs at a time (NOT 100 MBs)
- Excessive uploads will result in throttling errors
Use a reasonable HTTP timeout
- Please ensure your HTTP POST uses a sufficient timeout (ex: 30 seconds)
- Your timeout should be sufficient to allow us to accept sent data (this data will be processed in the background)
- Note that there is often a separate connection timeout vs. request timeout so you may need to specify both
Don't forget to include headers in each upload
- Remember to do this if you batch CSV data
Implement simple retry logic such as exponential back-off
- Although rare, 500 errors may happen due to network timeouts
- Note that we accept posted data immediately, and start ingesting in the background
- Issue monitoring alerts if the upload fails after all retries have been exhausted
Consider sending all records created OR updated in the last N days
- This means that the same records will be pushed repeatedly
- However, this is quite harmless, and it keeps your upload logic simple and robust
- For example, if your upload process stops running for 2 days, the next upload will "catch up"
- It also means you don't need to track precisely what has been uploaded / not uploaded
Make sure your CSV conforms 100% to the agreed upon format
- Any change to the data (ex: new fields, different order) requires a new upload URL
Normalize dates and numbers within your CSV
- Please refer to the information below