Shipment Requests via API: Listing, Tracking, Searching, Status, etc.
Listing Shipment Requests
There is a 100-record limit on all API calls. To illustrate, using /shipments_exact
to retrieve a list of all shipments would be unsuccessful unless there were only one hundred or fewer shipments, as only the first 100 records are returned.
Note
The /shipments_exact{id}
route returns the shipment type (‘Automated’ or ‘Manual’) as part of the response. The field is sortable. The /shipments/search-description
route returns the Type
field as a filterable field.
Obtaining Further Records
In cases where there are more than 100 shipments, iterate through the shipments based on the number of shipments provided by the total_count
parameter.
Use the optional parameters to obtain more records. For example:
// get the first 100
/shipments_exact?limit=100&offset=0
// get the second 100
/shipments_exact?limit=100&offset=100
// get the third 100
/shipments_exact?limit=100&offset=200
Single Shipment Request Tracking Example
A successful response from the shipments_exact
resource will include a shipment_id
which can be used to get the tracking information for this shipment request.
{
"shipment_id": "U89bvfKKCtQfhnqaFBrAZW",
"shipment_items": [
{
"inventory_product_id": 15,
"shipment_product_id": "MZ9bmEYFpKKviHe8nSiq4W",
"shipment_id": "U89bvfKKCtQfhnqaFBrAZW",
"product_id": 3,
"product_name": "YubiKey 5C",
"product_sku": "5060408461488",
"product_tier": 2,
"shipment_product_quantity": 16
}
],
"organization_id": "UEayb8v4LTHdAshpnk1gMd",
"user_id": "WMktp3sgPSFt4zsgpLDF46",
"country_code_2": "US",
"is_delivered": false,
"is_sent_to_fulfillment": false,
"is_shipped": false,
"recipient": "Example Inc.",
"recipient_email": "jan.lindberg@example.com",
"recipient_firstname": "Jan",
"recipient_lastname": "Lindberg",
"recipient_telephone": "555-5555",
"street_line1": "7788 Foxrun Street",
"city": "Dedham",
"region": "MA",
"postal_code": "02026",
"delivery_type": 1,
"shipment_state_code": "ShipmentStateAwaitingValidation",
"shipment_state_id": 3,
"shipment_state_message": "Awaiting Validation",
"shipment_summary_description": "Total Keys: 16 yk5c:16",
"shipment_request_date": "2020-12-10T19:56:57Z",
"shipment_updated_date": "2020-12-10T19:56:57Z",
"total_keys_shipped": 16
}
Tracking a Shipment Using the shipment_id
curl "https://api.console.yubico.com/v1/shipments_exact/Bj4pfrBJ1SCvkTbTP88Ak2" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer eyJhb..." \
Search
Some of the lines of code are very long, so it may be necessary to click in the line and scroll horizontally.
You can get a list of shipments filtered by query parameters. We introduced /search-description
on searchable resources to provide a description of the searchable fields. To look up a shipment using the parameter “Shipping error, contact support” state, for example, set the search_field
to shipment_state_id
and set the ID to 99
, which is the ID for that shipment state. (See the Shipment Status Codes table below for explanations of the various shipment states.)
Example
curl "https://api.console.yubico.com/v1/shipments_exact?search=99&search_field=shipment_state_id" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer eyJhb..."
Advanced Search
To enable advanced search, add the query string parameter &advanced_search=true
. Note that the &search
query parameters will need to respect a different structure: search=field_name::operation_type::value
. An example search with curl (--data-urlencode
is used because many characters introduced are illegal in the old query string, such as :
and |
):
curl -H "$YED_AUTHORIZATION" -G --data-urlencode 'search=shipment_request_date::range::2020-05-10T00:00:00Z|2020-12-10T00:00:00Z' --data-urlencode 'search=organization_name::like::alpha comp' --data-urlencode 'search=organization_name::exact::demo_org' 'http://api.console.local/v1/shipments_exact?offset=0&limit=10&sort_by=shipment_request_date&sort_direction=DESC&advanced_search=true'
This is the encoded URL.
GET /v1/shipments_exact?offset=0&limit=10&sort_by=shipment_request_date&sort_direction=DESC&advanced_search=true&search=shipment_request_date%3A%3Arange%3A%3A2020-05-10T00%3A00%3A00Z%7C2020-12-10T00%3A00%3A00Z&search=organization_name%3A%3Alike%3A%3Aalpha%20comp&search=organization_name%3A%3Aexact%3A%3Ademo_org HTTP/1.1
Fields with different names will be searched in an AND, while fields with the same name will be ORed, so the resulting query fragment will be:
WHERE (shipment_request_date BETWEEN ? AND ?) AND ((organizations.organization_name = ?) OR (organizations.organization_name LIKE ?)) ORDER BY shipment_request_date DESC LIMIT ?
with the following array to fill in the ?
in the fragment:
[2020-05-10 00:00:00 +0000 UTC 2020-12-10 00:00:00 +0000 UTC demo_org %alpha comp% 10]
Note
The old search will continue to work as before.
Filtering and Pagination
Refer to the API docs for the GetShipmentsExact operation .
Status
Shipment Status Codes
A shipment request can be edited at any of the states between 1 and 9. From this point on, a shipment request is either processed through to an end state, or set back to state 99.
For information on how address validation affects the success of a shipping request, see the Troubleshooting chapter.
This table is very wide; scroll horizontally to see all four columns.
shipment_state_id | shipment_state_code | shipment_state_description | shipment_state_message |
---|---|---|---|
1 | ShipmentStateIncomplete | Shipment request received
by YubiEnterprise Delivery
system but contained some
data that could not be
processed.
(2), (3) |
Incomplete Shipping Request |
2 | ShipmentStateDraft | Shipment request is being
edited and is not ready for
processing.
|
Draft |
3 | ShipmentStateAwaitingValidation | Shipment request received,
no validation done yet.
|
Awaiting Validation |
4 | ShipmentStateProcessingAddress | Shipment request locked as
it undergoes country check,
address validation, sales
tax rate lookup (US), DPL
check.
|
Processing |
5 | ShipmentStateAddressValid | Shipment request address has
been validated, ready to be
picked up by fulfillment
processor.
|
Accepted for Fulfillment |
6 | ShipmentStateAddressInvalid | Shipment request address is
invalid but an alternative
address has been found and
suggested.
(2), (3) |
Incomplete |
7 | ShipmentStateAddressFail | Shipment request address
could not be validated and
no alternative could be
found for suggesting.
(2), (3) |
Address is undeliverable
or could not be
understood
|
8 | ShipmentStateError | Shipment request has failed
processing due to
insufficient credits
or insufficient inventory.
|
Error: Processing Error,
contact Support
|
9 | ShipmentStateDPLMatch | Shipment request recipient
found on DPL, therefore it
is illegal to fulfill this
shipment request.
(4) |
Error: DPL Match |
99 | ShipmentStateShipmentError | Shipment request rejected
from ShipmentState-
ProcessingFulfillment
with “%s” error message;
could not be fulfilled by
processor.
|
Error: Shipping error,
contact Support
|
100 | ShipmentStateProcessingShipment | Shipment request was locked
at 1000hrs UTC to calculate
and deduct tax, inventory,
and credits.
(1) |
Processing: Inventory &
Tax Deductions
|
101 | ShipmentStateFulfillmentReady | Shipment request ready to be
queued for fulfillment.
|
Processing: Ready for
Fulfillment
|
102 | ShipmentStateProcessingFulfillment | Shipment sent for fulfill-
ment at 10:00am (or cutoff
time).
(1) |
Processing: Sent for
Fulfillment
|
103 | ShipmentStateShipped | Shipment sent out by
fulfillment processor and is
in transit.
|
Shipped: In transit |
104 | ShipmentStateDelivered | Shipment delivered. | Delivered |
105 | ShipmentStateLost | Shipment lost and delivery
is no longer expected.
|
Shipment Lost/Missing |
106 | ShipmentStateDeliveryException | Customs hold or undelivered
or returned shipment to
sender or any other shipping
exceptions.
|
Delivery Exception |
1025 | ShipmentStateShippingQueue | Shipment queued for
fulfillment.
|
Processing:
Queued for Fulfillment
|
2000 | ShipmentStateManualFulfillment | Shipment is being fulfilled
manually. No further action
by shipment requestor is
required.
|
Manual Processing |
(1)
Refer to Timing for cutoff times.
(2)
Incomplete Address: Secondary line information such as apartment (apt), suite, unit is missing. Therefore it is not possible to guarantee delivery to the correct recipient.
(3)
Address is Undeliverable or could not be understood: The address is either not physically deliverable or it could not be resolved to a real location.
(4)
Any shipping request with a recipient name and/or address found on the US government’s DPL (Denied Parties/Persons List) cannot be fulfilled.
Shipment Status Messages
Scroll horizontally to see the entire width of the table.
These error messages accessible via the API tell you why a given shipment request was unsuccessful. It is worth reviewing them before making any shipping requests in order to see what sort of issues might arise and thereby avoid them in the first place.
Note
As the following table is wide, you might need to scroll horizontally.
In the Explanation column, the source of the message is given: YubiEnterprise Delivery system for internal messages, US Validation for the US Postal Service, and finally, International Validation. Messages originating from the last two are simply passed on to you by YubiEnterprise Delivery.
Message | Explanation |
---|---|
InventoryProductId not specified for ProductId %d - ShipmentStateError |
YubiEnterprise Delivery system
|
Too many keys in shipment - TotalKeysShipped %d > %d - ShipmentStateError | YubiEnterprise Delivery system
|
Not enough Inventory for Shipment - ShipmentStateError | See Purchase Orders
YubiEnterprise Delivery system
|
Re-enter the address differently; some parts of it are invalid. See
the YubiEnterprise documentation for more guidance.
|
See Troubleshooting
US Validation
|
The address is invalid. See the YubiEnterprise documentation for more
guidance.
|
See Troubleshooting
US Validation
|
The address is valid. | No further explanation required
US Validation
|
Remove the ‘secondary unit designator’ (apt, suite, department, etc.)
because it is superfluous.
|
Remove the apartment number, unit, etc.:
it is considered wrong or unnecessary
US Validation
|
Enter second line information (apartment, unit, etc.).
The information in the primary line is not specific enough.
|
Add the apartment number, unit, etc.
US Validation
|
The address is a valid military address. | No further explanation required
US Validation
|
The address is a valid General Delivery address where individuals without
permanent addresses can receive mail.
|
No further explanation required
US Validation
|
The address is valid. An organization such as a government agency can
can have its own zipcode because it receives a large volume of mail.
|
No further explanation required
US Validation
|
Enter a street number; for example, for Yubico ‘Lytton Ave’ alone is not
sufficient, it needs to be ‘530 Lytton Ave’.
|
The number on the primary line, e.g., the
“185” in “185 Berry Street” is missing
|
Enter a valid street number. | The number on the primary line, e.g., the
“185” in “185 Berry Street” is not valid
US Validation
|
Enter a PO Box, Rural Route, or Highway Contract box number. | US Validation
|
Enter a valid PO Box, Rural Route, or Highway Contract box number. | US Validation
|
Enter the Private Mailbox (PMB) identifier or the # sign, followed by the
PMB number.
|
PMB number is Private Mailbox Number
US Validation
|
This address is not eligible to receive mail. | US Validation
|
The address is that of a Commercial Mail Receiving Agency (CMRA) a private
business that accepts mail for recipients, and the required private
mailbox information is present.
|
US Validation
|
The address is missing some important secondary line information
(apartment, unit, etc).
|
No further explanation required
International Validation
|
Mail is unlikely to arrive at this destination - please verify input. | No further explanation required
International Validation
|
This street could not be found within the city or postal code. | No further explanation required
International Validation
|
Invalid OrganizationId for Shipment | YubiEnterprise Delivery system |
Country Code not set for Shipment | YubiEnterprise Delivery system |
Country could not be found from CountryCode2: %s | Country code entered is not in
YubiEnterprise Delivery system list
|
Shipment has no shipment items | YubiEnterprise Delivery system |
DeliveryType not set for Shipment, defaulting to 1 - normal | YubiEnterprise Delivery system |
Invalid DeliveryType %s for Shipment | YubiEnterprise Delivery system |
InventoryType not set for Shipment, defaulting to 1 | YubiEnterprise Delivery system |
InventoryType %s not valid set for Shipment | You cannot use this InventoryType for this
shipment - YubiEnterprise Delivery system
|
Negative quantity entered for ShipmentItem with ProductId=%d defaulting to 0 | You set the quantity of the specified
ProductID to be shipped to less than zero.
YubiEnterprise Delivery system
|
Invalid ShipmentProductQuantity for ShipmentItem %d | You probably do not have sufficient
inventory - YubiEnterprise Delivery system
|
Invalid ShipmentProductLineCost for ShipmentItem %d | YubiEnterprise Delivery system |
Invalid Shipment - Total keys in shipment greater than 500 | You cannot ship more than 500 items at
once - YubiEnterprise Delivery system
|
Shipment has zero total item quantity | The number of items to be shipped must be
> than 0 - YubiEnterprise Delivery system
|
US Address is missing the state name/abbreviation in region field | No further explanation required
YubiEnterprise Delivery system
|
Bad ProductId in ShipmentProduct for NewShipmentProduct | ProductID is wrongly specified or invalid
YubiEnterprise Delivery system
|
Input for %s exceeded limit of %d characters | Specified field cannot accept the number
of characters that were entered.
YubiEnterprise Delivery system
|
Shipment of these products to this country using this delivery type is
not supported. For more information, see Delivery Policies.
|
Shipment request contravenes one or more
business rules. YubiEnterprise Delivery
system.
|
- See the USPS FAQ.
Response Request Status Codes
The responses to your requests indicate what is happening on the server side. Below are the common status codes in responses from the YubiEnterprise Delivery API, and what they mean.
Code | Meaning | Explanation |
---|---|---|
200 | OK | The request was successful and the response
body contains the representation requested
|
302 | FOUND | A common redirect response; this will
redirect to the OAUTH login page
|
400 | BAD REQUEST | API validation failed for the request |
403 | FORBIDDEN | API denied permission to fulfill the
requested resource
|
404 | NOT FOUND | The requested resource was not found |
Deprecated APIs
Deprecated | Replacement |
---|---|
GET /shipments |
GET /shipments_exact |
POST /shipments |
POST /shipments_exact |
GET /shipments/{shipmentId} |
GET /shipments_exact/{shipmentId} |
PUT /shipments/{shipmentId} |
PUT /shipments_exact/{shipmentId} |
DELETE /shipments/{shipmentId} |
DELETE /shipments_exact/{shipmentId} |
/UpdateShipmentById |
shipments_exact/{shipment_id} |
/organization/update-setting |
none |
To file a support ticket for YubiEnterprise Delivery, click Support.