Back to Website
Product Documentation Developers Integration Hub Customer API - List Linked Orders

Customer API - List Linked Orders

In this guide, we're going to take you through how you can list linked orders through the Kodaris API.

Video overview:

https://youtu.be/QD-nkDYei8I?si=_NCEXdhhjjpAWkUa
  1. Sign In
    • First, you will want to sign in to an account through the API.
    • Call the endpoint: POST / api/user/customer/apiKeyLogin
      • Headers
        • Accept - application/json
        • Content-Type - application/json
      • Body
        • apiKey - the api key of your api user.
      • Response
        • A response will be returned indicating whether the login was successful or not. The response will also contain your userSessionApiKey that you will need to use on future requests to get responses back as a authenticated user.
  2. Fetch an Auth Token
    • You'll need an authorization token for any API requests you make to the Kodaris API.
    • Fetch one using the endpoint: GET / api/user/customer/authToken
      • Headers
        • Accept - application/json
        • Content-Type - application/json
        • userSessionApiKey - the userSessionApiKey from the /apiKeyLogin endpoint response
      • Response
        • The returned response will contain your auth token that you will need to use on future requests.
  3. List Linked Orders
    • Now you can list an order's linked orders
    • Send an API request to endpoint: GET api/account/order/{orderID}/linkedOrders
      • Headers
        • Accept - application/json
        • Content-Type - application/json
        • userSessionApiKey - the userSessionApiKey from the /apiKeyLogin endpoint response
        • X-CSRF-TOKEN - the auth token from the /authToken endpoint response
      • Response
        • The returned response will include a list of linked orders.

Example

// Login to our account
var loginRes = kd.http.fetch({
  method: 'POST',
  url: 'https://content.kodaris.com/api/user/customer/apiKeyLogin',
  version: 2,
  body: {
    apiKey: 'xxxx'
  },
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
});

// keep our session token for future requests
var userSessionApiKey = loginRes.body.data.userSessionApiKey;

// get CRSF token for requests
var tokenRes = kd.http.fetch({
  method: 'GET',
  url: 'https://content.kodaris.com/api/user/customer/authToken',
  version: 2,
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'userSessionApiKey': userSessionApiKey
  }
});

// keep our token for future requests
var token = tokenRes.body.data;

// get linked orders for order with id=3022
var orderRes = kd.http.fetch({
  method: 'GET',
  url: 'https://content.kodaris.com/api/account/order/3022/linkedOrders',
  version: 2,
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'userSessionApiKey': userSessionApiKey,
    'X-CSRF-TOKEN': token
  }
});

kd.log('orderRes', orderRes);

-> response ->
{
    "status" : 200,
    "errors" : null,
    "body" : {
      "success" : true,
      "code" : 200,
      "messages" : { },
      "errors" : { },
      "data" : {
        "0" : {
          "orderID" : 3025,
          "organization" : "Big Company",
          "firstName" : "Ana",
          "lastName" : "Serra",
          "email1" : "ana@kodaris.com",
          "phone1" : "12345678",
          "address1" : "Atlanta, GA, USA",
          "address2" : null,
          "city" : "Atlanta",
          "state" : "GA",
          "postalCode" : "12345",
          "country" : "US",
          "countryName" : "US",
          "deliveryOrganization" : "Big Company",
          "deliveryFirstName" : "Ana",
          "deliveryLastName" : "Serra",
          "deliveryEmail1" : "ana@kodaris.com",
          "deliveryPhone1" : "12345678",
          "deliveryAddress1" : "Atlanta, GA, USA",
          "deliveryAddress2" : "",
          "deliveryCity" : "Atlanta",
          "deliveryState" : "GA",
          "deliveryPostalCode" : "12345",
          "deliveryCountry" : "US",
          "deliveryCountryName" : "US",
          "completed" : "2024-05-21 19:10:13:052",
          "orderNumber" : 2318,
          "status" : "Received",
          "notes" : "Ana Serra - 12345678",
          "purchaseOrder" : "12345",
          "extra5" : "2315-02",
          "shippingMethod" : "CPU",
          "billingAddressCode" : null,
          "deliveryAddressCode" : null,
          "trackingNumber" : null,
          "customerID" : null,
          "companyID" : 473,
          "displayPricing" : true,
          "subtotal" : 1.84,
          "shipping" : 5,
          "extraChargeTaxable" : 0,
          "extraCharge" : 0,
          "tax" : 0,
          "total" : 6.84
        },
        "1" : {
          "orderID" : 3026,
          "organization" : "Big Company",
          "firstName" : "Analia",
          "lastName" : "Serra",
          "email1" : "analia@kodaris.com",
          "phone1" : "12345678",
          "address1" : "Austin, TX, USA",
          "address2" : null,
          "city" : "Austin",
          "state" : "TX",
          "postalCode" : "12345",
          "country" : "US",
          "countryName" : "US",
          "deliveryOrganization" : "Big Company",
 ... omitted for brevity
In this article