How Can I Use the Simplified Transaction Import Rest API?

How Can I Use the Simplified Transaction Import Rest API?


This article is about the simplified transaction import REST API. Click here for more options.

Importing Sales Transactions
To import transaction data, follow these 2 steps:
  • Step 1 - Get your API key
  • Step 2 - Import transactions by making a POST call for each transaction

Step 1 - Get Your API Key
To obtain your API key:
  • Login to your workspace
  • On the left pane, click on "My Account > My Profile"
  • Click on the "Security" tab (if needed)
  • Copy the API key

Step 2 - Import Transactions
To import transactions:
  • Prepare a POST call to https://salescookie.com/app/Api/CreateTransaction
  • Set HTTP header X-ApiKey to your API key
  • Submit CSV data as POST content, such as:
  • {
      "date":"2019-07-04T02:47:42.1442597Z",
      "uniqueId":"id-123",
      "revenue":1.3,
      "profit":-2.5,
      "currency":"USD",
      "transactionStatus":"closed won",
      "customer":"Candy By Mail",
      "product":"Lemon Cake",
      "owner1":"John Doe",
      "owner2":"Jane Doe",
      "owner3":"Bob Smith",
      "team1":"USA",
      "team2":"Washington",
      "team3":"98004",
      "quantity":3,
      "costPerUnit":3.14,
      "taxes":6.54,
      "otherText1":"additional data",
      "otherText2":"more data",
      "otherText3":"even more data",
      "otherNumeric1":123.45,
      "otherNumeric2":54.321,
      "otherNumeric3":-98.76,
      "otherDate1":"2019-01-03T06:03:01Z",
      "otherDate2":"2019-05-10T08:05:09Z",
      "otherDate3":"2019-09-04T12:17:33Z"

Sample Code
The following samples show how to make calls (using C#) for a given API key, adding a transaction.

// Add a transaction
 dynamic expando = new ExpandoObject(); 
 expando.date = DateTime.UtcNow; 
 expando.uniqueId = "id-123"; 
 expando.revenue = 3.5; 
 expando.currency = "USD"; 
 expando.transactionStatus = "Closed Won"; 
 expando.customer = "Candy By Mail"; 
 expando.product = "Lemon Cake"; 
 expando.owner1 = "John Doe"; 
 expando.team1 = "Oregon"; 
 expando.quantity = 3; 
 expando.costPerUnit = 1.21; 
 expando.taxes = 0.14; 
 expando.otherText1 = "hello"; 
 expando.otherNumeric1 = 123.45; 
 expando.otherDate1 = DateTime.UtcNow; 
 string json = JsonConvert.SerializeObject(expando); 
 string url = "https://salescookie.com/app/Api/CreateTransaction";
 WebClient webClient = new WebClient(); 
 webClient.Headers.Add("X-ApiKey", apiKey); 
 string result = webClient.UploadString(url, json); 

Updating Transactions
Step 2 is typically used to create transactions. However, you can also use step 2 to update existing transactions (i.e. transactions you previously imported).

To update transactions however, each transaction must have a unique ID. Therefore, make sure you always set the "uniqueId" property in transactions you create.

That's it - the system will handle your import as a create or update depending on whether it can find a matching unique ID.

    • Related Articles

    • How Can I Use the Full Transaction Import Rest API?

      This article is about the full transaction import REST API. Click here for more options. Importing Sales Transactions To import transaction data, follow these 3 steps: Step 1 - Get your API key Step 2 - Prepare for import by mapping your fields to ...
    • How Can I Use The Transaction Import API?

      The data import API allows you to create (or update) sales transactions within Sales Cookie using HTTP requests. Three options are available to import sales transactions using an API: Use the CSV Upload API (easiest) Manually upload a sample CSV file ...
    • How Can I Use The CSV Upload API?

      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 ...
    • How Can I Programmatically Import Sales Transactions?

      For non-programmatic import options, click here. Three options are available: You can use a Web Endpoint. Using this model, you deploy a web page, from which we securely pull transaction data. We will query your web page at least every hour. You can ...
    • How Can I Import Transactions?

      For programmatic import options, click here. You can use the following methods to add transactions: Manually or automatically from CSV files Manually upload CSV files containing sales transactions Automatically by having us fetch CSV files from FTP ...