Creating a Manifest
Manifests are required by some carriers to streamline the pickup process
by allowing them to process many shipments at once. Without
a manifest, the carrier would need to scan each package individually. When picking up hundreds of packages from a warehouse,
scanning a manifest is far more efficient than scanning each individual package.
This guide walks you through creating a daily manifest.
INFO
While ShipEngine uses the term manifest, some carriers use other terminology, such as:
- Shipment Confirmation
- Shipment manifest
- SCAN form
- Order Summary
- End of Day form
Get the List of Labels
The first step in creating a manifest is determining which labels to include in the manifest and the best way to specify them
in your request to ShipEngine. Let's start with the simple case of creating a manifest for all labels that were created today.
To get a list of the labels that were created today, we will use the /v1/labels
endpoint
and pass some query parameters to filter the data. In this case we pass created_at_start
and created_at_end
. These parameters define a time range and allow us to get the list of labels that were created on a particular business day.
Without these parameters, this endpoint will return all labels.
Reminder
You must create your manifest on the same calendar date as the date on which the labels included in the
manifest were created.
Example Request
This example gets a list of all the labels that were created between the created_at_start_time
and the created_at_end_time
. It sends an HTTP GET request to the /v1/labels
endpoint and passes URL parameters
to filter the labels that are returned.
GET /v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
curl -iX GET 'https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z' \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
$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")
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z' -Method 'GET' -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 requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
};
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/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
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/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z"
payload = {}
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z")
.method("GET", null)
.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"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
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/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
[request setHTTPMethod:@"GET"];
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)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/labels?created_at_start=2020-11-05T0800:26:59.91Z&created_at_end=2020-11-05T15:26:59.91Z")!,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 = "GET"
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()
Example Response
This is an example of the response that is returned from request above. It includes two labels.
{
"labels": [
{
"label_id": "se-1049004",
"status": "completed",
"shipment_id": "se-6470112",
"ship_date": "2020-11-05T00:00:00Z",
"created_at": "2020-11-05T14:26:59.91Z",
"shipment_cost": {
"currency": "usd",
"amount": 3.18
},
"insurance_cost": {
"currency": "usd",
"amount": 0.0
},
"tracking_number": "9400111899223674205955",
"is_return_label": false,
"rma_number": null,
"is_international": false,
"batch_id": "",
"carrier_id": "se-82785",
"service_code": "usps_first_class_mail",
"package_code": "package",
"voided": false,
"voided_at": null,
"label_format": "pdf",
"display_scheme": "label",
"label_layout": "4x6",
"trackable": true,
"label_image_id": null,
"carrier_code": "stamps_com",
"tracking_status": "in_transit",
"label_download": {
"pdf": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.pdf",
"png": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.png",
"zpl": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.zpl",
"href": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.pdf"
},
"form_download": null,
"insurance_claim": null,
"packages": [
{
"package_code": "package",
"weight": {
"value": 1.00,
"unit": "ounce"
},
"dimensions": {
"unit": "inch",
"length": 0.0,
"width": 0.0,
"height": 0.0
},
"insured_value": {
"currency": "usd",
"amount": 0.00
},
"tracking_number": "9400111899223674205955",
"label_messages": {
"reference1": null,
"reference2": null,
"reference3": null
},
"external_package_id": null
}
],
"charge_event": "carrier_default"
},
"label_id": "se-1049067",
"status": "completed",
"shipment_id": "se-6470260",
"ship_date": "2020-11-05T00:00:00Z",
"created_at": "2020-11-05T16:53:41.127Z",
"shipment_cost": {
"currency": "usd",
"amount": 3.18
},
"insurance_cost": {
"currency": "usd",
"amount": 0.0
},
"tracking_number": "9400111899223674665629",
"is_return_label": false,
"rma_number": null,
"is_international": false,
"batch_id": "",
"carrier_id": "se-82785",
"service_code": "usps_first_class_mail",
"package_code": "package",
"voided": false,
"voided_at": null,
"label_format": "pdf",
"display_scheme": "label",
"label_layout": "4x6",
"trackable": true,
"label_image_id": null,
"carrier_code": "stamps_com",
"tracking_status": "in_transit",
"label_download": {
"pdf": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.pdf",
"png": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.png",
"zpl": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.zpl",
"href": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.pdf"
},
"form_download": null,
"insurance_claim": null,
"packages": [
{
"package_code": "package",
"weight": {
"value": 1.00,
"unit": "ounce"
},
"dimensions": {
"unit": "inch",
"length": 0.0,
"width": 0.0,
"height": 0.0
},
"insured_value": {
"currency": "usd",
"amount": 0.00
},
"tracking_number": "9400111899223674665629",
"label_messages": {
"reference1": null,
"reference2": null,
"reference3": null
},
"external_package_id": null
}
],
"charge_event": "carrier_default"
}
],
"total": 2,
"page": 1,
"pages": 1,
"links": {
"first": {
"href": "https://api.shipengine.com/v1/labels?created_at_end=2020-11-05T20%3A00%3A00.263Z&created_at_start=2020-11-05T00%3A00%3A00.263Z&page=1&page_size=25"
},
"last": {
"href": "https://api.shipengine.com/v1/labels?created_at_end=2020-11-05T20%3A00%3A00.263Z&created_at_start=2020-11-05T00%3A00%3A00.263Z&page=1&page_size=25"
},
"prev": {},
"next": {}
}
}
{
"labels": [
{
"label_id": "se-1049004",
"status": "completed",
"shipment_id": "se-6470112",
"ship_date": "2020-11-05T00:00:00Z",
"created_at": "2020-11-05T14:26:59.91Z",
"shipment_cost": {
"currency": "usd",
"amount": 3.18
},
"insurance_cost": {
"currency": "usd",
"amount": 0.0
},
"tracking_number": "9400111899223674205955",
"is_return_label": false,
"rma_number": null,
"is_international": false,
"batch_id": "",
"carrier_id": "se-82785",
"service_code": "usps_first_class_mail",
"package_code": "package",
"voided": false,
"voided_at": null,
"label_format": "pdf",
"display_scheme": "label",
"label_layout": "4x6",
"trackable": true,
"label_image_id": null,
"carrier_code": "stamps_com",
"tracking_status": "in_transit",
"label_download": {
"pdf": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.pdf",
"png": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.png",
"zpl": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.zpl",
"href": "https://api.shipengine.com/v1/downloads/0/VIYxvqt0CEaeE6kVeQq7DQ/label-1049004.pdf"
},
"form_download": null,
"insurance_claim": null,
"packages": [
{
"package_code": "package",
"weight": {
"value": 1.00,
"unit": "ounce"
},
"dimensions": {
"unit": "inch",
"length": 0.0,
"width": 0.0,
"height": 0.0
},
"insured_value": {
"currency": "usd",
"amount": 0.00
},
"tracking_number": "9400111899223674205955",
"label_messages": {
"reference1": null,
"reference2": null,
"reference3": null
},
"external_package_id": null
}
],
"charge_event": "carrier_default"
},
"label_id": "se-1049067",
"status": "completed",
"shipment_id": "se-6470260",
"ship_date": "2020-11-05T00:00:00Z",
"created_at": "2020-11-05T16:53:41.127Z",
"shipment_cost": {
"currency": "usd",
"amount": 3.18
},
"insurance_cost": {
"currency": "usd",
"amount": 0.0
},
"tracking_number": "9400111899223674665629",
"is_return_label": false,
"rma_number": null,
"is_international": false,
"batch_id": "",
"carrier_id": "se-82785",
"service_code": "usps_first_class_mail",
"package_code": "package",
"voided": false,
"voided_at": null,
"label_format": "pdf",
"display_scheme": "label",
"label_layout": "4x6",
"trackable": true,
"label_image_id": null,
"carrier_code": "stamps_com",
"tracking_status": "in_transit",
"label_download": {
"pdf": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.pdf",
"png": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.png",
"zpl": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.zpl",
"href": "https://api.shipengine.com/v1/downloads/0/KVAY5M7MG0GvNLCBFBbM9Q/label-1049067.pdf"
},
"form_download": null,
"insurance_claim": null,
"packages": [
{
"package_code": "package",
"weight": {
"value": 1.00,
"unit": "ounce"
},
"dimensions": {
"unit": "inch",
"length": 0.0,
"width": 0.0,
"height": 0.0
},
"insured_value": {
"currency": "usd",
"amount": 0.00
},
"tracking_number": "9400111899223674665629",
"label_messages": {
"reference1": null,
"reference2": null,
"reference3": null
},
"external_package_id": null
}
],
"charge_event": "carrier_default"
}
],
"total": 2,
"page": 1,
"pages": 1,
"links": {
"first": {
"href": "https://api.shipengine.com/v1/labels?created_at_end=2020-11-05T20%3A00%3A00.263Z&created_at_start=2020-11-05T00%3A00%3A00.263Z&page=1&page_size=25"
},
"last": {
"href": "https://api.shipengine.com/v1/labels?created_at_end=2020-11-05T20%3A00%3A00.263Z&created_at_start=2020-11-05T00%3A00%3A00.263Z&page=1&page_size=25"
},
"prev": {},
"next": {}
}
}
Create the Manifest
In the response above, you can see that two labels were returned. We can create an explicit manifest
that includes the two label_id
values from the response above.
Example Request
This example creates a manifest by making an HTTP POST request to the /v1/manifests
endpoint. It sets the values of
the label_ids
property to the label_id
values from the response above.
POST /v1/manifests HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
{
"label_ids": ["se-1049004", "se-1049067"]
}
curl -iX POST https://api.shipengine.com/v1/manifests \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '{
"label_ids": ["se-1049004", "se-1049067"]
}'
$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 `"label_ids`": [`"se-1049004`", `"se-1049067`"]`n}"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/manifests' -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({"label_ids":["se-1049004","se-1049067"]});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/manifests", 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/v1/manifests',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify({"label_ids":["se-1049004","se-1049067"]})
};
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/v1/manifests",
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 \"label_ids\": [\"se-1049004\", \"se-1049067\"]\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/v1/manifests"
payload = "{\n \"label_ids\": [\"se-1049004\", \"se-1049067\"]\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/v1/manifests")
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 \"label_ids\": [\"se-1049004\", \"se-1049067\"]\n}"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/manifests");
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 \"label_ids\": [\"se-1049004\", \"se-1049067\"]\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 \"label_ids\": [\"se-1049004\", \"se-1049067\"]\n}");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/manifests")
.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/v1/manifests"
method := "POST"
payload := strings.NewReader("{\n \"label_ids\": [\"se-1049004\", \"se-1049067\"]\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/v1/manifests"]
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 \"label_ids\": [\"se-1049004\", \"se-1049067\"]\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 \"label_ids\": [\"se-1049004\", \"se-1049067\"]\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/manifests")!,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()
Example Response
This is an example of the response that is returned from the request above. In this case, it only returns one manifest, but
it could return more than one.
Each manifest includes labels with the same
ship_date
, carrier_id
, and warehouse_id
. ShipEngine will create multiple manifests if you send labels with different
values for those properties. You might also have multiple manifests in the response if your request
includes more than 500 labels since ShipEngine only includes 500 labels per manifest.
Notice that the manifest object has an href
property that contains a URL. You can use this URL to download the manifest.
There is also a top-level href
property that is set to the href
of the first manifest if the response contains
more than one manifest. In our case, both properties contain the same value since only one manifest was created.
{
"manifests": [
{
"manifest_id": "se-11102",
"form_id": "se-11102",
"created_at": "2020-11-05T16:39:34.503Z",
"ship_date": "2020-11-05T00:00:00Z",
"shipments": 1,
"label_ids": [
"se-1049004",
"se-1049067"
],
"warehouse_id": null,
"submission_id": "9475711201080308027034",
"carrier_id": "se-82785",
"manifest_download": {
"href": "https://api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf"
}
}
],
"request_id": "95c1dbc4-0819-4f01-91c5-87183c820b54",
"errors": [],
"manifest_id": "se-11102",
"form_id": "se-11102",
"created_at": "2020-11-05T16:39:34.503Z",
"ship_date": "2020-11-05T00:00:00Z",
"shipments": 1,
"label_ids": [
"se-1049004",
"se-1049067"
],
"warehouse_id": null,
"submission_id": "9475711201080308027034",
"carrier_id": "se-82785",
"manifest_download": {
"href": "https://api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf"
}
}
{
"manifests": [
{
"manifest_id": "se-11102",
"form_id": "se-11102",
"created_at": "2020-11-05T16:39:34.503Z",
"ship_date": "2020-11-05T00:00:00Z",
"shipments": 1,
"label_ids": [
"se-1049004",
"se-1049067"
],
"warehouse_id": null,
"submission_id": "9475711201080308027034",
"carrier_id": "se-82785",
"manifest_download": {
"href": "https://api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf"
}
}
],
"request_id": "95c1dbc4-0819-4f01-91c5-87183c820b54",
"errors": [],
"manifest_id": "se-11102",
"form_id": "se-11102",
"created_at": "2020-11-05T16:39:34.503Z",
"ship_date": "2020-11-05T00:00:00Z",
"shipments": 1,
"label_ids": [
"se-1049004",
"se-1049067"
],
"warehouse_id": null,
"submission_id": "9475711201080308027034",
"carrier_id": "se-82785",
"manifest_download": {
"href": "https://api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf"
}
}
Download the Manifest
At this point, we've created the manifest.
We now have a URL where we can download the manifest, which is a PDF file.
We can enter this value directly
in a web browser to view and download the file through the browser, or
we can download it programmatically.
Example Request
This example downloads the manifest using the URL returned in the response above. Notice that you
must change the Content-Type
to application/pdf
.
GET https://api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Accept-Type: application/pdf
curl -iX GET https://api.shipengine.comhttps://api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Accept-Type: application/pdf' \
$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("Accept-Type", "application/pdf")
$response = Invoke-RestMethod 'https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf' -Method 'GET' -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("Accept-Type", "application/pdf");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Accept-Type': 'application/pdf'
}
};
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/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Accept-Type: application/pdf"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf"
payload = {}
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Accept-Type': 'application/pdf'
}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Accept-Type"] = "application/pdf"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Accept-Type", "application/pdf");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf")
.method("GET", null)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Accept-Type", "application/pdf")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
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("Accept-Type", "application/pdf")
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/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Accept-Type": @"application/pdf"
};
[request setAllHTTPHeaderFields:headers];
[request setHTTPMethod:@"GET"];
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)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/https:/api.shipengine.com/v1/downloads/0/BpP_fo0d9EiiQJ7hqDQGmA/manifest-11102.pdf")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/pdf", forHTTPHeaderField: "Accept-Type")
request.httpMethod = "GET"
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()