Create a Sales Order Manually
ShipEngine allows users to create sales orders manually via the API.
At a minimum, you will need the following pieces of information to create your sales order:
external_order_id
order_date
ship_to
for every sales order item, if any
You may also provide most of the additional information available on a sales order, as seen below.
Example
POST /v-beta/sales_orders
POST /v-beta/sales_orders HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
{
"external_order_id": "1111",
"external_order_number": "2222",
"order_source": {
"order_source_id": "9ab83300-39ba-4159-96f8-0d0ef6dfcbfa"
},
"order_date": "2019-07-25T15:24:46.657Z",
"payment_details": {
"subtotal": {
"currency": "usd",
"amount": 200
},
"estimated_shipping": {
"currency": "usd",
"amount": 10
},
"estimated_tax": {
"currency": "usd",
"amount": 5
},
"grand_total": {
"currency": "usd",
"amount": 215
}
},
"customer": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"email": "[email protected]"
},
"bill_to": {
"email": "[email protected]",
"address": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US",
"address_residential_indicator": "yes"
}
},
"ship_to": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US",
"address_residential_indicator": "yes"
},
"sales_order_items": [
{
"line_item_details": {
"name": "ball of string A",
"sku": "ball of string A"
},
"price_summary": {
"unit_price": {
"currency": "usd",
"amount": 200
}
},
"ship_to": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US",
"address_residential_indicator": "yes"
},
"quantity": 4,
"is_gift": false
}
]
}
curl -iX POST https://api.shipengine.com/v-beta/sales_orders \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '{
"external_order_id": "1111",
"external_order_number": "2222",
"order_source": {
"order_source_id": "9ab83300-39ba-4159-96f8-0d0ef6dfcbfa"
},
"order_date": "2019-07-25T15:24:46.657Z",
"payment_details": {
"subtotal": {
"currency": "usd",
"amount": 200
},
"estimated_shipping": {
"currency": "usd",
"amount": 10
},
"estimated_tax": {
"currency": "usd",
"amount": 5
},
"grand_total": {
"currency": "usd",
"amount": 215
}
},
"customer": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"email": "[email protected]"
},
"bill_to": {
"email": "[email protected]",
"address": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US",
"address_residential_indicator": "yes"
}
},
"ship_to": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US",
"address_residential_indicator": "yes"
},
"sales_order_items": [
{
"line_item_details": {
"name": "ball of string A",
"sku": "ball of string A"
},
"price_summary": {
"unit_price": {
"currency": "usd",
"amount": 200
}
},
"ship_to": {
"name": "Amanda Miller",
"phone": "555-555-5555",
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US",
"address_residential_indicator": "yes"
},
"quantity": 4,
"is_gift": false
}
]
}'
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "{`n `"external_order_id`": `"1111`",`n `"external_order_number`": `"2222`",`n `"order_source`": {`n `"order_source_id`": `"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa`"`n },`n `"order_date`": `"2019-07-25T15:24:46.657Z`",`n `"payment_details`": {`n `"subtotal`": {`n `"currency`": `"usd`",`n `"amount`": 200`n },`n `"estimated_shipping`": {`n `"currency`": `"usd`",`n `"amount`": 10`n },`n `"estimated_tax`": {`n `"currency`": `"usd`",`n `"amount`": 5`n },`n `"grand_total`": {`n `"currency`": `"usd`",`n `"amount`": 215`n }`n },`n `"customer`": {`n `"name`": `"Amanda Miller`",`n `"phone`": `"555-555-5555`",`n `"email`": `"[email protected]`"`n },`n `"bill_to`": {`n `"email`": `"[email protected]`",`n `"address`": {`n `"name`": `"Amanda Miller`",`n `"phone`": `"555-555-5555`",`n `"address_line1`": `"525 S Winchester Blvd`",`n `"city_locality`": `"San Jose`",`n `"state_province`": `"CA`",`n `"postal_code`": `"95128`",`n `"country_code`": `"US`",`n `"address_residential_indicator`": `"yes`"`n }`n },`n `"ship_to`": {`n `"name`": `"Amanda Miller`",`n `"phone`": `"555-555-5555`",`n `"address_line1`": `"525 S Winchester Blvd`",`n `"city_locality`": `"San Jose`",`n `"state_province`": `"CA`",`n `"postal_code`": `"95128`",`n `"country_code`": `"US`",`n `"address_residential_indicator`": `"yes`"`n },`n `"sales_order_items`": [`n {`n `"line_item_details`": {`n `"name`": `"ball of string A`",`n `"sku`": `"ball of string A`"`n },`n `"price_summary`": {`n `"unit_price`": {`n `"currency`": `"usd`",`n `"amount`": 200`n }`n },`n `"ship_to`": {`n `"name`": `"Amanda Miller`",`n `"phone`": `"555-555-5555`",`n `"address_line1`": `"525 S Winchester Blvd`",`n `"city_locality`": `"San Jose`",`n `"state_province`": `"CA`",`n `"postal_code`": `"95128`",`n `"country_code`": `"US`",`n `"address_residential_indicator`": `"yes`"`n },`n `"quantity`": 4,`n `"is_gift`": false`n }`n ]`n}"
$response = Invoke-RestMethod 'https://api.shipengine.com/v-beta/sales_orders' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
var myHeaders = new Headers();
myHeaders.append("Host", "api.shipengine.com");
myHeaders.append("API-Key", "__YOUR_API_KEY_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({"external_order_id":"1111","external_order_number":"2222","order_source":{"order_source_id":"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa"},"order_date":"2019-07-25T15:24:46.657Z","payment_details":{"subtotal":{"currency":"usd","amount":200},"estimated_shipping":{"currency":"usd","amount":10},"estimated_tax":{"currency":"usd","amount":5},"grand_total":{"currency":"usd","amount":215}},"customer":{"name":"Amanda Miller","phone":"555-555-5555","email":"[email protected]"},"bill_to":{"email":"[email protected]","address":{"name":"Amanda Miller","phone":"555-555-5555","address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US","address_residential_indicator":"yes"}},"ship_to":{"name":"Amanda Miller","phone":"555-555-5555","address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US","address_residential_indicator":"yes"},"sales_order_items":[{"line_item_details":{"name":"ball of string A","sku":"ball of string A"},"price_summary":{"unit_price":{"currency":"usd","amount":200}},"ship_to":{"name":"Amanda Miller","phone":"555-555-5555","address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US","address_residential_indicator":"yes"},"quantity":4,"is_gift":false}]});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v-beta/sales_orders", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.shipengine.com/v-beta/sales_orders',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify({"external_order_id":"1111","external_order_number":"2222","order_source":{"order_source_id":"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa"},"order_date":"2019-07-25T15:24:46.657Z","payment_details":{"subtotal":{"currency":"usd","amount":200},"estimated_shipping":{"currency":"usd","amount":10},"estimated_tax":{"currency":"usd","amount":5},"grand_total":{"currency":"usd","amount":215}},"customer":{"name":"Amanda Miller","phone":"555-555-5555","email":"[email protected]"},"bill_to":{"email":"[email protected]","address":{"name":"Amanda Miller","phone":"555-555-5555","address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US","address_residential_indicator":"yes"}},"ship_to":{"name":"Amanda Miller","phone":"555-555-5555","address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US","address_residential_indicator":"yes"},"sales_order_items":[{"line_item_details":{"name":"ball of string A","sku":"ball of string A"},"price_summary":{"unit_price":{"currency":"usd","amount":200}},"ship_to":{"name":"Amanda Miller","phone":"555-555-5555","address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US","address_residential_indicator":"yes"},"quantity":4,"is_gift":false}]})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.shipengine.com/v-beta/sales_orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v-beta/sales_orders"
payload = "{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v-beta/sales_orders")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v-beta/sales_orders");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v-beta/sales_orders")
.method("POST", body)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v-beta/sales_orders"
method := "POST"
payload := strings.NewReader("{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}
#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.shipengine.com/v-beta/sales_orders"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "{\n \"external_order_id\": \"1111\",\n \"external_order_number\": \"2222\",\n \"order_source\": {\n \"order_source_id\": \"9ab83300-39ba-4159-96f8-0d0ef6dfcbfa\"\n },\n \"order_date\": \"2019-07-25T15:24:46.657Z\",\n \"payment_details\": {\n \"subtotal\": {\n \"currency\": \"usd\",\n \"amount\": 200\n },\n \"estimated_shipping\": {\n \"currency\": \"usd\",\n \"amount\": 10\n },\n \"estimated_tax\": {\n \"currency\": \"usd\",\n \"amount\": 5\n },\n \"grand_total\": {\n \"currency\": \"usd\",\n \"amount\": 215\n }\n },\n \"customer\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"email\": \"[email protected]\"\n },\n \"bill_to\": {\n \"email\": \"[email protected]\",\n \"address\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"sales_order_items\": [\n {\n \"line_item_details\": {\n \"name\": \"ball of string A\",\n \"sku\": \"ball of string A\"\n },\n \"price_summary\": {\n \"unit_price\": {\n \"currency\": \"usd\",\n \"amount\": 200\n }\n },\n \"ship_to\": {\n \"name\": \"Amanda Miller\",\n \"phone\": \"555-555-5555\",\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"yes\"\n },\n \"quantity\": 4,\n \"is_gift\": false\n }\n ]\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v-beta/sales_orders")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Order source for the sales order
You can leave the order_source
empty in your request and a default api
order source will be created automatically for you if no api
order source exists. If you already have an api
order source connected to your account, it will be used if none is specified in the request. However, if you have multiple connected api
order sources, you must specify which one you'd like to use in your request.
info
Third-party order sources
You may only create sales orders via the API with an
api
order source, meaning you cannot manually create sales orders for your Amazon or Shopify order source. Sales orders from Amazon, Shopify, or any other third-party order source must be imported by connecting that order source.
Different shipping addresses for different sales order items
You may specify your ship_to
address either for the sales order as a whole, or for each individual sales order item. If you specify the ship_to
address for the sales order, the address will apply across all of the sales order items. You may also specify the ship_to
address for the sales order as well as all the items, as long as the addresses are identical.