NOTE: This version of document is outdated and DEPRECATED! This document describes the most basic commands of ACP Shipper API, needed for sending direct mailing. There are some more commands in this API, that may be used by a shipper: for address verification, mailing tracking, creation return and collect parcels. They are described in separate documents, which is listed on http://acpapi.com/ in section “Manuals”.
Description
Endpoint url is https://acpapi.com/API/ OR http://acpapi.com/API/ (for test purposes)
Following input parameters must be sent via HTTPs POST method:
apikey=XXXXXXXXXX (required) – your personal API access key that we give to you.
command=commandName (required) – possible commands are described below.
testMode=0|1 (optional, default is 0) – run command in test environment (even if =0, test mode may always be enabled for user by administration).
+ additional parameters specific for each command.
Note: all parameters must be properly encoded, as required by HTTP standard. I.e., if request's encoding is “x-www-form-urlencoded” (header “Content-Type: application/x-www-form-urlencoded”), then all non-alphanumeric chars in parameter names and values must be replaced by char % + their hexadecimal values. E.g., char “&” must be replaced by “%26”. On practice, it is enough to replace only following characters instead all non-alphanumeric characters: %, ?, =, &, #.
API answer is standard “HTTP 200 OK” answer. Answer body contains text in XML format, specific for each command. In case of common error, such as authorization error or invalid input parameters, answer is the same for all commands:
XSD-schemes as described below XML-requests may be found here: http://acpapi.com/API/schema/
Possible Commands:
1) command=createMailing
Used for the creation of direct mailing item(s) and (optional) printable shipping label.
Specific parameters:
data=text/xml (required) – data describing mailing items for processing (see below).
label=0|1|2|3 (optional, default is 0) – create and return shipping label:
mailItem – describes particular mailing item. Can be repeated for the creation of multiple items at once (only if input parameter label=0). Container for HAWB data: goods for customer.
trackingNumber – tracking number of shipping label (USPS/UPS etc), required if input parameter label=0. Cannot be used with input parameter label≠0.
shipperItemId (optional, desired) – internal shipper's mailing item ID, max length 50 chars. If used, allows this mailing item to be pointed to this id later. Especially recommended if trackingNumber is not transmitted (input parameter label≠0) to avoid placing one mailing item twice due to connection problems, etc. Must be unique through all mailing items (direct and return/collect) for this shipper.
displayItemId (optional) – if used, will be printed on mailing label instead of shipperItemId (if input parameter label≠0).
consignee – consignee’s address.
name– person name, max length 35 chars.
companyName– company name, max length 35 chars.
(either name or companyName is required)
addressLine1, addressLine2 – address information. Combined length of these fields must not be greater than 105 chars.
city – city name, max length 35 chars.
state – state/province code, max length 2 chars.
zip – zip/postal-code, max length 10 chars.
country – country code in ISO 3166-1 alpha-2 format (US, GB, CA, …)
phone (optional) – phone number, max length 20 chars. Free form field: 123-456-9890, 1(800) 426-4968, 123456789, etc.
shipper (optional) – shipper’s address for filling in AMS. Format identical to consignee node. If transmitted, valid address required. If you have more than 1 shipper address there are additional choices:
– set up a different account for each address and omit this node;
– use shipper node in createMailing command.
returnAddress (optional) – used only for printing on shipping labels as return address. Format identical to consignee node. If transmitted, valid address required.
value – total mailing item's cost, decimal number (i.e. 1234.12).
currency – currency code in ISO 4217 format (USD, EUR, …)
weight – mailing item total weight in kilograms, decimal number (i.e. 12.345).
– conflict – conflict with already existing mailing item (e.g., by shipperItemId);
– system – internal system error.
error – text error description in case of error.
trackingNumber – shipping tracking number of label for this mailing item. If creation of shipping label was ordered (input parameter label≠0), it is the tracking number of created label (may be empty in case of error). If not (label=0), it is the tracking number transmitted in request.
shipperItemId – internal shipper's mailing item id, transmitted in request.
labelFormat – format of created label, one of PNG, PDF, EPL2.
label – base64-encoded content of created label.
destinationBag – recommended bag type for shipping this mailing item (i.e. LAX, JFK, ...). Used for sorting mailing items by destination airport on sender's side.
conflictMailItem – in case of conflict with existing mailing item (errorType=conflict), contains description of that mailing item (in case of conflict with someone's else mailing item by tracking number, contains trackingNumber child node only).
type – one of: “Direct”, “Return”, “Collect”, “Undeliverable”.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – item's current status (“New”, “Picked Up”, etc).
bagId – system bag id, in which this item is included.
shipperBagId – internal shipper's bag id.
2) command=cancelMailing
Used to cancel some of previously created direct or return/collect mailing item(s).
Specific parameters:
data=text/xml (required) – data describing canceled mailing items (see below).
Structure of XML in data parameter:
bagId – system bag id, in which this item is included.
shipperBagId – internal shipper's bag id.
3) command=createBag
Used for aggregation of direct mailing items in shipping bag (e.g., bag 1 of 10) and printing bag label. Each bag consists of 1 or more mailing items.
Specific parameters:
data=text/xml (required) – data describing created bag (see below).
label=0|1 (optional, default is 0) – return bag label (1) or not (0).
labelFormat=PNG|PDF|EPL2 (optional, default is PNG) – required label image format.
Structure of XML in data parameter:
errorType – error type in case of error. Possible values are:
– invalid – transmitted bag is invalid;
– conflict – conflict with already existing bag or current mailing items' state;
– system – internal system error.
error – text error description in case of error.
bagId – system id of this bag, for future usage in other commands, like cancelBag (may be empty in case of error).
shipperBagId – internal shipper's bag id.
labelFormat – format of created label, one of PNG, PDF, EPL2.
label – base64-encoded content of created label.
conflictBag – in case of conflict with existing bag (errorType=conflict) by shipperBagId, contains description of that bag.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – bag's current status (“New”, “Picked Up”, etc).
bagId – system bag id.
shipperBagId – internal shipper's bag id.
comment – shipper's bag comment.
mailItem – in case of conflict (errorType=conflict), describes particular mailing item requested for inclusion in the bag that can NOT be included in it for a particular reason. Repeated for each such mailing item.
errorType – error type. Possible values are:
– invalid – transmitted mailing item is invalid;
– notFound – requested mailing item not found;
– conflict – conflict with current mailing item's state;
– system – internal system error.
error – text error description.
trackingNumber – tracking number of mailing item.
shipperItemId – internal shipper's mailing item id.
conflictMailItem – in case of conflict with current mailing item's state (both bag's errorType=conflict and mailItem's errorType=conflict), contains description of current mailing item.
type – one of: “Direct”, “Return”, “Collect”, “Undeliverable”.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – item's current status (“New”, “Picked Up”, etc).
bagId – system bag id, in which this item is included.
shipperBagId – internal shipper's bag id.
4) command=cancelBag
Used to cancel previously created bag for a particular reason.
Specific parameters:
data=text/xml (required) – data describing canceled bag (see below).
Structure of XML in data parameter:
day – describes result of reopening day operation.
result – operation result, string ok or error.
errorType – error type in case of error. Possible values are:
– notFound – there are no closed days;
– conflict – conflict with last closed day's state;
– system – internal system error.
error – text error description in case of error.
dayId – system id of reopened day.
shipperDayId – internal shipper's day id.
conflictDay – in case of conflict with last closed day's state (errorType=conflict), contains description of that day.
creationDate – closing date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – day's current status (“New”, “Picked Up”, etc).
dayId – system day id.
shipperDayId – internal shipper's day id.
7) command=createDay
Closes day and generates End of Day manifest. Unlike closeDay, all included units (mail items and bags) must be specified in the request.
Specific parameters:
data=text/xml (required) – data describing created day (see below).
label=0|1 (optional, default is 0) – return End of Day manifest (1) or not (0).
bagLabels=0|1 (optional, default is 0) - return all this day's bag labels (1) or not (0).
labelFormat=PNG|PDF|EPL2 (optional, default is PNG) – required label image format.
Structure of XML in data parameter:
shipperDayId (optional, desired) – internal shipper's day id, max length 50 chars. If used, allows this day to be pointed to this id later.
bag – describes particular bag for inclusion in the day. Should be repeated for each included bag.
bagId – system id of the bag.
shipperBagId – internal shipper's bag id.
(either bagId or shipperBagId is required)
mailItem – describes particular mailing item for inclusion in the day. Should be repeated for each included mailing item that is not included in any bag.
errorType – error type in case of error. Possible values are:
– invalid – transmitted day is invalid;
– conflict – conflict with already existing day or current bags/mailing items' state;
– system – internal system error.
error – text error description in case of error.
dayId – system id of this day, for future usage in other commands, like cancelDay (may be empty in case of error).
shipperDayId – internal shipper's day id.
labelFormat – format of created label, one of PNG, PDF, EPL2.
label – base64-encoded content of created label.
conflictDay – in case of conflict with existing day (errorType=conflict) by shipperDayId, contains description of that bag.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – day's current status (“New”, “Picked Up”, etc).
bagId – system day id.
shipperDayId – internal shipper's day id.
bag – individual current day's bag. If input parameter bagLabels=1 and result=ok, repeated for all bags created by createBag command in current day and contains label information. In case of conflict (errorType=conflict), repeated for all particular bags that can NOT be included in it for a particular reason.
errorType – error type (in case of error). Possible values are:
– invalid – transmitted bag is invalid;
– notFound – requested bag found;
– conflict – conflict with current bag's state;
– system – internal system error.
error – text error description.
bagId – system id of this bag
shipperBagId – internal shipper's bag id.
labelFormat – format of created label, one of PNG, PDF, EPL2.
label – base64-encoded content of created label.
conflictBag – in case of conflict with current bag's state (errorType=conflict), contains description of the bag.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – bag's current status (“New”, “Picked Up”, etc).
bagId – system bag id.
shipperBagId – internal shipper's bag id.
comment – shipper's bag comment.
mailItem – in case of conflict (errorType=conflict), describes particular mailing item requested for inclusion in the day that can NOT be included in it for a particular reason. Repeated for each such mailing item.
errorType – error type. Possible values are:
– invalid – transmitted mailing item is invalid;
– notFound – requested mailing item not found;
– conflict – conflict with current mailing item's state;
– system – internal system error.
error – text error description.
trackingNumber – tracking number of mailing item.
shipperItemId – internal shipper's mailing item id.
conflictMailItem – in case of conflict with current mailing item's state (both bag's errorType=conflict and mailItem's errorType=conflict), contains description of current mailing item.
type – one of: “Direct”, “Return”, “Collect”, “Undeliverable”.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – item's current status (“New”, “Picked Up”, etc).
bagId – system bag id, in which this item is included.
shipperBagId – internal shipper's bag id.
8) command=cancelDay
Used to cancel previously created day for a particular reason.
Specific parameters:
data=text/xml (required) – data describing canceled day (see below).
Structure of XML in data parameter:
day – describes result of canceling day operation.
result – operation result, string ok or error.
errorType – error type in case of error. Possible values are:
– invalid – transmitted day is invalid;
– notFound – requested day not found;
– conflict – conflict with current day's state;
– system – internal system error.
error – text error description in case of error.
dayId – system id of this day, the same as in request.
shipperDayId – internal shipper's day id.
conflictDay – in case of conflict with current day's state (errorType=conflict), contains description of the day.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.
status – day's current status (“New”, “Picked Up”, etc).
dayId – system day id.
shipperDayId – internal shipper's day id.
9) command=getInfo
Used to get information about all new direct mailing items and bags created in account since last closeDay operation, that have not been picked up yet (command may be used even if shipper does not use closeDay at all ad works only with mailing items). May be used to verify current account's state before requesting closeDay or for handling possible errors that may appear while working with API.
No specific parameters so far.
Structure of XML in API answer:
errorType – error type in case of error. Possible values are:
– system – internal system error.
error – text error description in case of error.
mailItem – individual current day's mailing item. Repeated for all mailing items created by createMailing command in current day.
creationDate – creation date/time in UTC, format is “yyyy-mm-ddThh:mm:ssZ”.