In this guide, we're going to take you through how you can create a customer API user and authenticate to the Kodaris API.
Video overview:
1. Sign in to your Kodaris system as a customer
2. Navigate to the customer portal
3. Navigate to 'Employees' and click 'Add API User'
4. In the popup window, enter your API user's name and, optionally, a description. Then click 'Create'
5. After your API user is created, be sure to copy and save the API key. This is the only time the API key will be shown. Once copied, click 'Set Permissions'
6. You should be redirected to the details screen for your new API user. Here, you'll want to scroll down to the 'Permissions' section and set the permissions for your API user.
Your API user is all set! You can now authenticate to the Kodaris API.
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 orders under our company account
var orderRes = kd.http.fetch({
method: 'POST',
url: 'https://content.kodaris.com/api/account/order/list',
version: 2,
body: {
page: 0,
size: 10
},
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" : {
"size" : 10,
"number" : 0,
"totalElements" : 431,
"isLast" : false,
"totalPages" : 44,
"isFirst" : true,
"hasPrevious" : false,
"hasNext" : true,
"numberOfElements" : 10,
"offset" : null,
"content" : {
"0" : {
"orderID" : 3137,
"organization" : "Ocean Rd.",
"firstName" : null,
"lastName" : null,
"email1" : "elizabeth@kodaris.com",
"phone1" : "(123) 123-1234",
"address1" : "123 Ocean Rd.",
"address2" : "",
"city" : "Some City",
"state" : "CT",
"postalCode" : "12345",
"country" : "US",
"countryName" : "US",
"deliveryOrganization" : "Ocean Rd.",
"deliveryFirstName" : null,
"deliveryLastName" : null,
"deliveryEmail1" : "elizabeth@kodaris.com",
"deliveryPhone1" : "(123) 123-1234",
"deliveryAddress1" : "123 Ocean Rd.",
"deliveryAddress2" : null,
"deliveryCity" : "Some City",
"deliveryState" : "CT",
"deliveryPostalCode" : "12345",
"deliveryCountry" : "US",
"deliveryCountryName" : "US",
"completed" : null,
"orderNumber" : null,
"status" : "Initialized",
"notes" : null,
"purchaseOrder" : null,
"extra5" : null,
"shippingMethod" : null,
"billingAddressCode" : "2088_3007billing_1",
"deliveryAddressCode" : "2088_3007billing_1",
"trackingNumber" : null,
"customerID" : 1184,
"companyID" : 473,
"displayPricing" : true,
"subtotal" : 63.04,
"shipping" : null,
"extraChargeTaxable" : null,
"extraCharge" : null,
"tax" : null,
"total" : null
},
"1" : {
"orderID" : 3231,
"organization" : "Ocean Rd.",
"firstName" : null,
"lastName" : null,
"email1" : "jane.doe@kodaris.com",
"phone1" : "(123) 123-1234",
"address1" : "123 Ocean Rd.",
"address2" : "",
"city" : "Some City",
"state" : "CT",
"postalCode" : "12345",
"country" : "US",
"countryName" : "US",
"deliveryOrganization" : "Ocean Rd.",
"deliveryFirstName" : null,
"deliveryLastName" : null,
"deliveryEmail1" : "jane.doe@kodaris.com",
"deliveryPhone1" : "(123) 123-1234",
"deliveryAddress1" : "123 Ocean Rd.",
"deliveryAddress2" : null,
"deliveryCity" : "Some City",
"deliveryState" : "CT",
"deliveryPostalCode" : "12345",
"deliveryCountry" : "US",
"deliveryCountryName" : "US",
"completed" : null,
"orderNumber" : null,
"status" : "Initialized",
"notes" : null,
"purchaseOrder" : null,
"extra5" : null,
"shippingMethod" : null,
"billingAddressCode" : "2088_3007billing_1",
"deliveryAddressCode" : "2088_3007billing_1",
"trackingNumber" : null,
"customerID" : 1122,
"companyID" : 473,
"displayPricing" : true,
"subtotal" : 105.93,
"shipping" : null,
"extraChargeTaxable" : null,
"extraCharge" : null,
"tax" : null,
"total" : null
}
... omitted for brevity