Introduction
Welcome to the LionEnergy API. As a registered user (with a username and password) you have all the credentials you need to start using the API.
To the left you'll find our menu and the ability to search our documentation. We've included cURL, python, and javascript examples of how to communicate with our API to the right.
Please review the Deprecated section to the left to stay compliant with the API. All deprecated code will be supported until it's expiration date listed in each section.
Authentication
To authorize, use this code:
# With cURL, you can just pass the correct header with each request
# You Basic Token is generated as a base64 encoded username and password.
curl "api_endpoint_here" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Basic yourBasicTokenGoesHere" \
import requests
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic yourBasicTokenGoesHere'
}
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
Make sure to replace
yourBasicTokenHere
with your API token.
LionEnergy API uses Basic Authorization to authenticate each user.
An Authorization header must contain the word Basic
followed by your unique authorization token.
the API token must be included in all API requests to the server in a header that looks like the following:
Authorization: Basic yourBasicTokenGoesHere
A basic authorization token is generated from a base64 encoded combination of your username and password. These can be generated by postman or similar services. Alternatively, use this Base64 Basic Auth Generator.
Orders
Get All Orders
curl --location --request GET 'https://api.lionenergy.com/orders' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Basic yourBasicTokenGoesHere" \
import requests
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic yourBasicTokenGoesHere'
}
url = "https://api.lionenergy.com/orders"
response = requests.request("GET", url, headers = headers)
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.lionenergy.com/orders", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"tranid": "SO12345",
"recordtype": "salesorder",
"entity": {
"id": null,
"name": "Example Company Name",
},
"otherrefnum": "987354321",
"createddate": null,
"lastmodifieddate": "12/7/2020",
"memo": "Please send soon!",
"trandate": "12/7/2020",
"status": {
"slug": "pending_approval",
"name": "Pending Approval",
},
"state": {
"level": "0",
"slug": "pending_pick",
"name": "Pending Pick",
},
"custbody_is_high_priority": "F",
"custbody_is_bin_transferred": null,
"custbody_is_will_call_order": null,
"custbody_is_replacement_order": null,
"custbody_reason_for_return": null,
"custbody_created_by": null,
"custrecord_hours_pending": null,
"custbody_order_source": "portal_api",
"custbody_test_order": false,
"shippingAddress": {
"shipaddress": "Jane Jones\n1802 Arkansas Ave\nBrown TX 77550\nUnited States",
"shipaddressee": null,
"shipaddress1": null,
"shipaddress2": null,
"shipcity": null,
"shipstate": null,
"shipzip": null,
"shipcountrycode": null,
"shipemail": null,
"shipphone": null,
}
},
{
"id": 2,
"tranid": "SO123465",
"recordtype": "salesorder",
"entity": {
"id": null,
"name": "Example Company Name",
},
"otherrefnum": "987354555",
"createddate": null,
"lastmodifieddate": "12/7/2020",
"memo": "Lion Energy is the best!",
"trandate": "12/7/2020",
"status": {
"slug": "pending_fulfillment",
"name": "Pending Fulfillment",
},
"state": {
"level": "0",
"slug": "picked",
"name": "Picked",
},
"custbody_is_high_priority": "F",
"custbody_is_bin_transferred": null,
"custbody_is_will_call_order": null,
"custbody_is_replacement_order": null,
"custbody_reason_for_return": null,
"custbody_created_by": null,
"custrecord_hours_pending": null,
"custbody_order_source": "portal_api",
"custbody_test_order": false,
"shippingAddress": {
"shipaddress": "Sam Jones\n1802 Arkansas Ave\nBrown TX 77655\nUnited States",
"shipaddressee": null,
"shipaddress1": null,
"shipaddress2": null,
"shipcity": null,
"shipstate": null,
"shipzip": null,
"shipcountrycode": null,
"shipemail": null,
"shipphone": null,
}
}
]
}
This endpoint retrieves the latest 5000 orders.
HTTP Request
GET https://api.lionenergy.com/orders?type=CUSTOMERPO&q=PO12345?date_start=11%2F18%2F2020&date_end=11%2F18%2F2020
Query Parameters
Query Parameters | Optional | Description |
---|---|---|
type | true | Available Types: [CUSTOMERPO, RMANUMBER, SONUMBER, SHIPPINGANY, TRACKINGNUMBER] |
q | true | If you've specified a type, the q (query) will hold the value you'd like to search for that type. While all query parameters are optional,
q needs to be paired with type or the system will throw a 500 BadQueryStringException .
?type=CUSTOMERPO&q=123456
|
date_start | true | The beginning date for a range of orders. Expects (mm-dd-yyyy) format.
?date_start=11%2F18%2F2020
|
date_end | true | The end date for a range of orders. Expects (mm-dd-yyyy) format.
?date_end=11%2F18%2F2020
|
Create a New Order
import requests
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic yourBasicTokenGoesHere'
}
url = "https://api.lionenergy.com/orders"
payload = "{\n
\"shipaddressee\": \"John Doe\",\n
\"shipaddress1\": \"123 Somewhere St.\",\n
"shipaddress2\": \"Apt. 123\",\n
\"shipcity\": \"Austin\",\n
\"shipstate\": \"TX\",\n
\"shipcountrycode\": \"US\",\n
\"shipemail\": \"johndoe@example.com\",\n
\"shipphone\": \"555-555-5555\",\n
\"memo\": \"This is a note for my order.\",\n
\"entity\": 6473,\n
\"otherrefnum\": \"PO123456\",\n
\"products\": [\n
{\n
\"sku\": \"23974FTP\",\n
\"quantity\": 3\n
},\n
{\n
\"upc\": \"098324809234098\",\n
\"quantity\": 2\n
}\n
]\n
}"
response = requests.request("POST", url, headers = headers, data = payload)
curl --location --request POST 'https://api.lionenergy.com/orders' \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Basic yourBasicTokenGoesHere" \
--data-raw "{
"shipaddressee": "John Doe",
"shipaddress1": "123 Somewhere St.",
"shipaddress2": "Apt. 123",
"shipcity": "Austin",
"shipstate": "TX",
"shipcountrycode": "US",
"shipemail": "johndoe@example.com",
"shipphone": "555-555-5555",
"memo": "This is a note for my order.",
"entity": 6473,
"otherrefnum": "PO123456",
"products": [
{
"sku": "23974FTP",
"quantity": 3
},
{
"upc": "098324809234098",
"quantity": 2
}
]
}"
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
var myHeaders = JSON.stringify({
"shipaddressee":"John Doe",
"shipaddress1":"123 Somewhere St.",
"shipaddress2":"Apt. 123",
"shipcity":"Austin",
"shipstate":"TX",
"shipcountrycode":"US",
"shipemail":"johndoe@example.com",
"shipphone":"555-555-5555",
"memo":"This is a note for my order.",
"entity":6473,
"otherrefnum":"PO123456",
"products":[
{
"sku":"23974FTP",
"quantity":3
},
{
"upc":"098324809234098",
"quantity":2
}
]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.lionenergy.com/orders", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The above command returns JSON structured like this:
{
"message": "Order Created Successfully. Order Id: 123456",
"data": {
"id": 123456,
"tranid": "SO12345",
"recordtype": "salesorder",
"entity": {
"id": null,
"name": "Example Company Name",
},
"otherrefnum": "987354321",
"createddate": "12/3/2020 1:09 pm",
"lastmodifieddate": "12/3/2020 1:09 pm",
"memo": "Customer will order more",
"trandate": "11/18/2020",
"status": {
"slug": "pending_approval",
"name": "Pending Approval",
},
"state": {
"level": "0",
"slug": "pending_pick",
"name": "Pending Pick",
},
"custbody_is_high_priority": "F",
"custbody_is_bin_transferred": null,
"custbody_is_will_call_order": null,
"custbody_is_replacement_order": null,
"custbody_reason_for_return": null,
"custbody_created_by": {
"id": "555",
"name": "John Employee",
},
"custrecord_hours_pending": null,
"custbody_order_source": "portal_api",
"custbody_test_order": false,
"shippingAddress": {
"shipaddress": "Jane Jones\n1802 Arkansas Ave\nBrown TX 77550\nUnited States",
"shipaddressee": "Jane Jones",
"shipaddress1": "1802 Arkansas Ave",
"shipaddress2": null,
"shipcity": "Brown",
"shipstate": "TX",
"shipzip": "77550",
"shipcountrycode": "US",
"shipemail": "jane@example.com",
"shipphone": "555-555-5555",
}
"products": [
{
"id": "1960",
"description": "Lion Cub GO - Portable Power Unit, 150W, 120Wh",
"sku": "50170121",
"upc": null,
"custcol_rma_serial_number": null,
"custcol_outbound_tracking": null,
"quantity": 3,
"quantitypicked": null,
"quantityshiprecv": null,
"custcol_carrier_tracking_number": null,
},
{
"id": "1962",
"description": "Lion GO 20 - Hard Solar Panel, 20W, 12V",
"sku": "50170123",
"upc": null,
"custcol_rma_serial_number": null,
"custcol_outbound_tracking": null,
"quantity": 2,
"quantitypicked": null,
"quantityshiprecv": null,
"custcol_carrier_tracking_number": null,
}
]
}
}
This endpoint creates a new order.
HTTP Request
POST https://api.lionenergy.com/orders
URL Parameters
Parameter | Required | Type | Description |
---|---|---|---|
shipaddressee | TRUE |
string |
The name of the customer |
shipaddress1 | TRUE |
string |
The street address of the customer |
shipaddress2 | FALSE |
string |
Any additional street address information of the customer |
shipcity | TRUE |
string |
The city of the customer |
shipstate | TRUE |
string |
The state of the customer |
shipzip | TRUE |
string |
The zip of the customer |
shipcountrycode | TRUE |
string |
The country of the customer (common: US, CA) |
shipemail | FALSE |
string |
The email of the customer |
shipphone | FALSE |
string |
The phone number of the customer |
memo | FALSE |
string |
Internal notes for the order records. Not sent to customer. |
entity | TRUE |
integer |
ID of the company being purchased from (must be one of the company IDs in your organization) |
otherrefnum | TRUE |
string |
Your PO or similar internal reference number. |
products | TRUE |
array |
Array of objects containing quantity and sku/upc of the products being ordered. |
Get a Specific Order
import requests
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic yourBasicTokenGoesHere'
}
url = "https://api.lionenergy.com/orders/<ID>"
response = requests.request("GET", url, headers = headers)
curl --location --request GET 'https://api.lionenergy.com/orders/<ID>' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Basic yourBasicTokenGoesHere" \
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.lionenergy.com/orders/<ID>", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The above command returns JSON structured like this:
{
"data": {
"id": 1,
"tranid": "SO12345",
"recordtype": "salesorder",
"entity": {
"id": null,
"name": "Example Company Name",
},
"otherrefnum": "987354321",
"createddate": "12/3/2020 1:09 pm",
"lastmodifieddate": "12/3/2020 1:09 pm",
"memo": "Customer will order more",
"trandate": "11/18/2020",
"status": {
"slug": "pending_approval",
"name": "Pending Approval",
},
"state": {
"level": "0",
"slug": "pending_pick",
"name": "Pending Pick",
},
"custbody_is_high_priority": "F",
"custbody_is_bin_transferred": null,
"custbody_is_will_call_order": null,
"custbody_is_replacement_order": null,
"custbody_reason_for_return": null,
"custbody_created_by": {
"id": "555",
"name": "John Employee",
},
"custrecord_hours_pending": null,
"custbody_order_source": "portal_api",
"custbody_test_order": false,
"fulfillments": [
{
"id": "1843769",
"tranid": "IF119844",
"trandate": "3/26/2020",
"status": " Shipped",
}
],
"returns": [
{
"id": "1843769",
"tranid": "RMA13003",
"recordtype": null,
"trandate": null,
"entity": {
"id": null,
"name": null,
},
"otherrefnum": null,
"createddate": null,
"lastmodifieddate": null,
"memo": null,
"trandate": null,
"status": {
"slug": null,
"name": null,
},
"createdfrom": null,
"custbody_rma_notes": null,
"custbody_is_high_priority": null,
"custbody_is_bin_transferred": null,
"custbody_is_will_call_order": null,
"custbody_is_replacement_order": null,
"custbody_do_not_send_rma_materials": null,
"custbody_reason_for_return": null,
"custbody_reason_for_return_id": null,
"custbody_reason_for_return_id": null,
"custbody_reason_for_return_name": null,
"custbody_created_by": {
"id": null,
"name": null,
},
"custrecord_hours_pending": null,
}
],
"shippingAddress": {
"shipaddress": "Jane Jones\n1802 Arkansas Ave\nBrown TX 77550\nUnited States",
"shipaddressee": "Jane Jones",
"shipaddress1": "1802 Arkansas Ave",
"shipaddress2": null,
"shipcity": "Brown",
"shipstate": "TX",
"shipzip": "77550",
"shipcountrycode": "US",
"shipemail": "jane@example.com",
"shipphone": "555-555-5555",
}
"products": [
{
"id": "1960",
"description": "Lion Cub GO - Portable Power Unit, 150W, 120Wh",
"sku": "50170121",
"upc": null,
"custcol_rma_serial_number": null,
"custcol_outbound_tracking": null,
"quantity": 3,
"quantitypicked": null,
"quantityshiprecv": null,
"custcol_carrier_tracking_number": null,
},
{
"id": "1962",
"description": "Lion GO 20 - Hard Solar Panel, 20W, 12V",
"sku": "50170123",
"upc": null,
"custcol_rma_serial_number": null,
"custcol_outbound_tracking": null,
"quantity": 2,
"quantitypicked": null,
"quantityshiprecv": null,
"custcol_carrier_tracking_number": null,
}
]
}
}
This endpoint retrieves a specific order.
HTTP Request
DELETE https://api.lionenergy.com/orders/<ID>
URL Parameters
Parameter | Description |
---|---|
ID | The ID of the order to retrieve |
Delete a Specific Order
import requests
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic yourBasicTokenGoesHere'
}
url = "https://api.lionenergy.com/orders/delete/<ID>"
response = requests.request("DELETE", url, headers = headers)
curl --location --request DELETE 'https://api.lionenergy.com/orders/delete/<ID>' \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Basic yourBasicTokenGoesHere" \
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
var requestOptions = {
method: 'DELETE',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.lionenergy.com/orders/delete/<ID>", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The above command returns JSON structured like this:
{
"message": "The order was deleted successfully.",
"data": {
"id": 5925083,
}
}
This endpoint deletes a specific order.
HTTP Request
DELETE https://api.lionenergy.com/orders/delete/<ID>
URL Parameters
Parameter | Description |
---|---|
ID | The ID of the order to delete |
Fulfillments
Get Batched Fulfillments
import requests
headers = {
'Content-Type' : 'application/json',
'Accept' : 'application/json',
'Authorization' : 'Basic yourBasicTokenGoesHere'
}
url = "https://api.lionenergy.com/fulfillmnets/batch"
payload = "{\n
\"entity\": \"1235\",\n
\"otherrefnums\": [\n
\"PO-125234\",\"2LKASDF84\",\"23NJUCRE43\",\"PO-A230JR3EW32\"\n
]\n
}"
response = requests.request("POST", url, headers = headers, data = payload)
curl --location --request POST 'https://api.lionenergy.com/fulfillments/batch' \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--header "Authorization: Basic yourBasicTokenGoesHere" \
--data-raw "{
"entity": 1253,
"otherrefnums" : [
"PO-125234","2LKASDF84","23NJUCRE43","PO-A230JR3EW32"
]
}"
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Accept", "application/json");
var myHeaders = JSON.stringify({
"entity": 1253,
"otherrefnum": [
"PO-125234",
"2LKASDF84",
"23NJUCRE43",
"PO-A230JR3EW32"
]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.lionenergy.com/fulfillments/batch", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
The above command returns JSON structured like this:
{
"data": [
{
"otherrefnum": "FSD85131",
"netsuite_id": 1234266,
"status": "Partially Shipped",
"fulfillments": {
"packages": [
{
"packageItems": {
"59170100": {
"id": "2854",
"sku": "59170100",
"upc": "810026142970",
"quantity": "4",
"description": "Patriot Power Cell"
},
"59300023":{
"id": "2080",
"sku": "59300023",
"upc": "810026143465",
"quantity": "1",
"description": "4Patriot Catalog",
},
"59300024":{
"id": "2081",
"sku": "59300024",
"upc": "18100488",
"quantity": "1",
"description": "4Patriot Letter"
}
},
"custrecord_packages_carrier": "UPS",
"custrecord_packages_service": "UPS SurePost",
"custrecord_packages_tracking": "1Z198A5FYW02805643"
}
]
},
"is_fulfilled": 1
}
]
}
This endpoint retrieves multiple fulfillments
HTTP Request
POST https://api.lionenergy.com/fulfillments/batch
Body Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
entity | TRUE |
string |
The entity of the order |
otherrefnums | TRUE |
array |
Array of otherrefnum's for each order. |
Errors
A 422 Error code returns JSON structured like this:
{
"message": "The order could not be saved.",
"errors": {
"shipaddressee": [
"The shipaddressee field is required.",
],
"shipzip": [
"The shipzip field is required.",
],
"entity": [
"The selected entity is invalid.",
],
},
"status_code": 422,
}
A 406 Error code returns JSON structured like this:
{
"message": "Your API request headers must contain Accept:application/json and Content-Type:application/json",
"status_code": 406,
}
A 500 Error code returns JSON structured like this:
{
"message": "An internal error has occured.",
"status_code": 500,
}
Another 422 Error code returns JSON structured like this:
{
"message": "The order could not be saved.",
"errors": {
"error": [
"The address has registered as a P.O. Box. You have un-mailable product(s).
SKUs Not Allowed: 2051 and 2337",
],
},
"status_code": 422,
}
The Lion Energy API returns an errors
array when validation has failed stopping the process from completing.
These errors are human readable and can help with rapid development by informing you what data is missing from the request body.
The Lion Energy API returns the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is incorrect or the user account lacks the appropriate permissions. |
403 | Forbidden -- The resource requested is hidden to your access. |
404 | Not Found -- The specified resource could not be found. |
405 | Method Not Allowed -- You tried to access a resource with an invalid method ['GET', 'POST', 'PUT', 'DELETE'] . |
406 | Not Acceptable -- You don't have the correct headers. |
410 | Gone -- The resource requested has been removed from our servers. |
422 | User Error -- The resource could not be retrieved/saved/updated/deleted successfully. See errors. |
429 | Too Many Requests |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |
Deprecation
Feature | Description | Implemented | Mandatory |
---|---|---|---|
Order Routes |
All order routes have been changed to orders to follow convention of current and upcoming routes.
Any CRUD system will end in the plural form of the resource. ie: returns , fulfillments , etc.
|
12/09/20 | 06/09/21 |
Order Create Route Change |
The order create route has been changed from a POST to order/create to just a simple POST to orders .
This change was made to stay consistent with the following convention for routes where "resources" represents the plural name of the resource you're
interacting with.
|
12/09/20 | 06/09/21 |
Create Order Request Body |
Creating a new order with the API now requires a different naming convention for the parameters of the request body.
Please see Create an Order for details. The older parameters are supported but require that the
customer_order_date be included to trigger the code to run off the deprecated parameters.
|
12/09/20 | 06/09/21 |