Introduction
The CommerceJet API is organized around REST. Our API has predictable resource-oriented URLs, accepts json-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
Authentication
To authorize, use this code:
# With shell, you can just pass the correct header with each request
curl "api_endpoint_here" \
-H "Accept: application/json"
-H "Content-Type: application/json"
-H "Authorization: Bearer APPLICATION_TOKEN"
Make sure to replace
APPLICATION_TOKEN
with your API key.
CommerceJet uses API keys to allow access to the API. You can register them in ">_ Applications" section in the main website.
CommerceJet expects for the API key to be included in all API requests to the server in a header that looks like the following:
Authorization: Bearer APPLICATION_TOKEN
Countries
List
curl "https://account-name.commercejet.com/api/v1/countries" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"iso_code": "CA",
"name": "Canada"
},
{
"id": 2,
"iso_code": "US",
"name": "United States"
}
]
}
This endpoint retrieves a list of all available countries.
HTTP Request
GET https://account-name.commercejet.com/api/v1/countries
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Country. |
iso_code | string |
Two-letter Country code ISO 3166-1 alpha-2 |
name | string |
Country name. |
Customers
List
curl "https://account-name.commercejet.com/api/v1/customers" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 2,
"name": "John Doe",
"company": "Candy Factory",
"country_id": 2,
"state_id": 51,
"city": "Seattle",
"address1": "4862 Camden Street",
"address2": "Unit 12",
"zip_code": "89501",
"email": "test@example.com",
"phone_number": "+15555555555",
"created_at": "2021-03-17 16:53:03"
},
...
],
"meta": {
"current_page": 1,
"last_page": 3,
"per_page": 20,
"total": 53
}
}
This endpoint retrieves a list of all Customers.
HTTP Request
GET https://account-name.commercejet.com/api/v1/customers
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Customer. |
name | string |
Customer full name. |
company | string |
Customer company name. |
country_id | integer |
Resource ID of customer Country. |
state_id | integer |
Resource ID of customer State. |
city | string |
Customer City name. |
address1 | string |
Customer Addres Line 1. |
address2 | string |
Customer Addres Line 1. |
zip_code | string |
Customer ZIP Code. |
string |
Customer contact email address. | |
phone_number | string |
Customer contact phone number. |
created_at | string |
Date and time at which the Customer was created. Format: Y-m-d H:i:s |
Order Channels
List
curl "https://account-name.commercejet.com/api/v1/order-channels" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"name": "EDI"
},
{
"id": 2,
"name": "Integration"
}
]
}
This endpoint retrieves a list of all available order channels.
HTTP Request
GET https://account-name.commercejet.com/api/v1/order-channels
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Order Channel. |
name | string |
Order Channel name. |
Shipping Carriers
List
curl "https://account-name.commercejet.com/api/v1/shipping-carriers" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"name": "FedEx"
},
{
"id": 2,
"name": "UPS"
}
]
}
This endpoint retrieves a list of all available Shipping Carriers.
HTTP Request
GET https://account-name.commercejet.com/api/v1/shipping-carriers
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Shipping Carrier. |
name | string |
Shipping Carrier full name. |
Size Unit Categories
List
curl "https://account-name.commercejet.com/api/v1/size-unit-categories" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"name": "Warehouse"
},
{
"id": 2,
"name": "Product"
}
]
}
This endpoint retrieves a list of all available Size Unit Catgories.
HTTP Request
GET https://account-name.commercejet.com/api/v1/size-unit-categories
Query Parameters
none
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Size Unit Category. |
name | string |
Size Unit Category full name. |
Size Units
List
curl "https://account-name.commercejet.com/api/v1/size-units" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 4,
"category_id": 2,
"name": "Prod SizeU 2",
"abbreviation": "ps2"
},
{
"id": 1,
"category_id": 1,
"name": "Square feet",
"abbreviation": "ft²"
}
]
}
This endpoint retrieves a list of all available Size Units.
HTTP Request
GET https://account-name.commercejet.com/api/v1/size-units
Query Parameters
Parameter | Type | Description |
---|---|---|
category_id | integer |
Resource ID of the Size Unit Category. |
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Size Unit. |
category_id | integer |
Resource ID of the Size Unit Category. |
name | string |
Size Unit full name. |
abbreviation | string |
Size Unit abreviation. |
States
List
curl "https://account-name.commercejet.com/api/v1/states" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 60,
"country_id": 1,
"name": "Alberta",
"abbreviation": "AB"
},
{
"id": 3,
"country_id": 2,
"name": "American Samoa",
"abbreviation": "AS"
}
]
}
This endpoint retrieves a list of all available States.
HTTP Request
GET https://account-name.commercejet.com/api/v1/states
Query Parameters
Parameter | Type | Description |
---|---|---|
country_id | integer |
Resource ID of the Country. You can filter the results by Country. |
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the State. |
country_id | integer |
Resource ID of the Country. |
name | string |
State full name. |
abbreviation | string |
State abbreviation. |
Terms
List
curl "https://account-name.commercejet.com/api/v1/terms" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"name": "Term One"
},
{
"id": 2,
"name": "Term Two"
}
]
}
This endpoint retrieves a list of all available Terms.
HTTP Request
GET https://account-name.commercejet.com/api/v1/terms
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Term. |
name | string |
Term full name. |
Trading Partner Types
List
curl "https://account-name.commercejet.com/api/v1/trading-partner-types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"name": "Type One"
},
{
"id": 2,
"name": "Type Two"
}
]
}
This endpoint retrieves a list of all available Trading Partner types.
HTTP Request
GET https://account-name.commercejet.com/api/v1/trading-partner-types
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Trading Partner Type. |
name | string |
Type full name. |
Trading Partners
List
curl "https://account-name.commercejet.com/api/v1/trading-partners" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"active": true,
"name": "Trading partner 1",
"type_id": 2,
"order_channel_id": 2,
"shipping_window_days": 100,
"vendor_number": "445",
"terms_id": null,
"credit_limit": 10900,
"credit_override": true,
"notes": "Some note on trading partner level",
"created_at": "2021-04-23 17:19:47"
},
...
]
}
This endpoint retrieves a list of all available Trading Partners.
HTTP Request
GET https://account-name.commercejet.com/api/v1/trading-partners
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Trading Partner. |
active | boolean |
Flag to determine if the Trading Partner is active or not. |
name | string |
Full name of the Trading Partner. |
type_id | integer or null |
Trading Parter Type Resource ID. See reference |
order_channel_id | integer or null |
Order Channel Resouce ID. See reference |
shipping_window_days | integer or null |
TODO_TODO. |
vendor_number | integer or null |
TODO_TODO. |
terms_id | integer or null |
Terms Resouce ID. See reference |
credit_limit | integer or null |
TODO_TODO. |
credit_override | boolean |
Flag to determine if the credit limit can be overridden or not. |
notes | string |
Free text that can be added to Trading Partner. |
created_at | string |
Date and time at which the resouce was created. Format: Y-m-d H:i:s |
Warehouses
List
curl "https://account-name.commercejet.com/api/v1/warehouses" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 14,
"name": "Warehouse Dallas-1",
"warehouse_type_id": 1,
"size": 54,
"size_unit_id": 3,
"country_id": 2,
"state_id": 51,
"city": "Seattle",
"address1": "Addr 1",
"address2": "Addr 2",
"zip_code": "12345",
"email": "john.doe@test.com",
"phone_number": "+15555555555",
"fax_number": "+15555555555"
},
{
"id": 2,
"name": "Warehouse Toronto-1",
"warehouse_type_id": 2,
"size": 3,
"size_unit_id": 5,
"country_id": 2,
"state_id": 51,
"city_id": "Miami",
"address1": "A1",
"address2": "A2",
"zip_code": "23456",
"email": "test@test.com",
"phone_number": "+5555555555",
"fax_number": ""
}
]
}
This endpoint retrieves a list of all available Warehouses.
HTTP Request
GET https://account-name.commercejet.com/api/v1/warehouses
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer |
Resource ID of the Warehouse. |
name | string |
Full name of the Warehouse. |
warehouse_type_id | integer |
Resource ID of the Warehouse Type. |
size | integer |
Size of the warehouse. |
size_unit_id | integer |
Resource ID of the Size Unit. |
country_id | integer |
Resource ID of the Country. |
state_id | integer |
Resource ID of the State. |
city | string |
Warehouse City name. |
address1 | string |
Address Line 1 of the Warehouse. |
address2 | string |
Address Line 2 of the Warehouse. |
zip_code | string |
ZIP code of the Warehouse. |
string |
Contact email address. | |
phone_number | string |
Contact phone number. |
fax_number | string |
Contact Fax number. |
Warehouse Types
List
curl "https://account-name.commercejet.com/api/v1/warehouse-types" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
The above command returns JSON structured like this:
{
"data": [
{
"id": 1,
"name": "Warehouse type A",
"created_at": "2021-03-04 22:34:19"
},
{
"id": 2,
"name": "Warehouse type B",
"created_at": "2021-02-13 20:59:14"
}
]
}
This endpoint retrieves a list of all available warehouse types.
HTTP Request
GET https://account-name.commercejet.com/api/v1/warehouse-types
Query Parameters
None
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer | Resource ID of the warehouse Type. |
name | string | Warehouse Type name. |
created_at | string | Date and time at which the resouce was created. |
Create
curl "https://account-name.commercejet.com/api/v1/warehouse-types" \
-X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer APPLICATION_TOKEN"
-d '{ ... request body ... }'
Request body example.
{
"name": "Warehouse Type New"
}
The above command returns JSON structured like this:
{
"id": 3,
"name": "Warehouse Type New",
"created_at": "2021-02-13 20:59:14"
}
This endpoint creates a new Warehouse Type.
HTTP Request
POST https://account-name.commercejet.com/api/v1/warehouse-types
Request Body Parameters
Parameter | Type | Max Length | Description |
---|---|---|---|
name | string | 255 | Warehouse Type name. |
Response Attributes
Parameter | Type | Description |
---|---|---|
id | integer | Resource ID of the Warehouse Type. |
name | string | Warehouse Type name. |
created_at | string | Date and time at which the resouce was created. Format: Y-m-d H:i:s |
Errors
The CommerceJet API uses the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. |
401 | Unauthorized -- Your API key is invalid. |
402 | Payment Required -- Your subscription is no longer valid. |
403 | Forbidden -- You don't have enough privileges to access this resource. |
404 | Not Found -- The specified resource could not be found. |
405 | Method Not Allowed -- You tried to access a resource with an invalid method. |
406 | Not Acceptable -- You requested a format that isn't json. |
410 | Gone -- The resource requested has been removed from our servers. |
422 | Unprocessable Entity -- Most likely it's a validation error. |
429 | Too Many Requests -- The number of requests per time unit is too high. |
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. |