Promise Dates
Use the Promise API to get an estimated delivery date to display during conversion and checkout to reduce uncertainty that leads to cart abandonment and improve customer delivery satisfaction.
Overview
parcelLab provides an API you can call to get forecasted delivery dates. This date can be used to display a delivery date promise on the product details page or at checkout. It can be shown in a format you want on your website so customers can see when a product should arrive before buying it.
Get Promise Date
Details of how the v2/prediction endpoint can be used to generate a forecasted delivery date in the parcelLab system are described below.
Request Parameters
Call GET https://api.parcellab.com/v2/prediction. This storefront endpoint uses the user query parameter to select a Promise-enabled account. It does not require an API token in the URL or headers.
user
Required. Your parcelLab account ID.
destination
Required. ISO 3166-1 alpha-3 country code, such as GBR; <postal_code>_<country_code>, such as SW1A1AA_GBR; or the shopper's IPv4 or IPv6 address.
fallbackCountry
Optional. A three-letter country code, such as USA, used when an IP destination cannot resolve or has no matching delivery methods. Only valid with an IP address in destination.
warehouse
Optional. Warehouse name, ID, or configured alias.
courier
Optional. Carrier code or configured alias.
courierServiceLevel
Optional. A service-level value configured for the delivery method.
lang
Optional. Language for localized result text.
The warehouse, carrier, and service-level filters accept comma-separated values. Multiple values within one filter are alternatives; different filters must all match. Use values from your Promise configuration.
Postal Codes with Spaces
For GET /v2/prediction, format destination as <postal-code>_<COUNTRY>, using the uppercase three-letter country code. Keep leading zeros. You can send the postal code with or without spaces and punctuation: the API removes every character except letters, digits, and _ before it validates the value.
Address postal code
Country
destination value
SW1A 1AA
United Kingdom
SW1A1AA_GBR
K1A 0B1
Canada
K1A0B1_CAN
02108
United States
02108_USA
02108-1234
United States
021081234_USA
For example:
SW1A 1AA_GBR and SW1A1AA_GBR resolve to the same destination, as do 02108-1234_USA and 021081234_USA. For a nine-digit US ZIP code, only the first five digits are used. If you send a space, URL-encode it, for example destination=SW1A%201AA_GBR, or use your HTTP client's query-parameter encoder. The compact values above need no space encoding. Keep postal codes as strings and retain normal formatting in customer addresses.
Replace YOUR_ACCOUNT_ID with your Promise-enabled account ID.
Use an IP Address
Before the shopper supplies a delivery address, you can send their IPv4 or IPv6 address in destination. For example:
For IPv6, use your HTTP client's query-parameter encoder. For example, 2001:4860:4860::8888 becomes:
These are example IP addresses. Replace them with the shopper's IP address. The API uses the country and postal code from the IP lookup with the same location rules as an explicit destination. If the lookup returns a country without a postal code, the API uses a country-level location. Successful IP lookups can be reused for up to six hours.
IP geolocation estimates a location. It does not confirm the delivery address. Use an explicit country and postal code when the shopper supplies them, and request a new prediction.
Set a Fallback Country
To use a country-level location when the IP lookup fails or has no matching delivery methods, add fallbackCountry:
The API selects the location as follows:
If the IP location has matching delivery methods, the API uses that location. This applies even when the IP resolves to a different country from
fallbackCountry.If the IP lookup fails or the IP location has no matching delivery methods, the API uses the fallback country. It discards the IP location's postal code and region and selects methods for the country-level location.
The API generates predictions for the selected methods. If those methods return no predictions, the API keeps the selected location and returns an empty
predictionarray. An empty generated result does not trigger another fallback.
Your account must have Promise enabled. The warehouse, carrier, and service-level filters also apply to the fallback. A fallback country does not guarantee a prediction.
Use a valid three-letter country code, such as USA or DEU. Two-letter codes, unknown codes, postal-code destinations, and multiple fallback values are invalid. Supplying fallbackCountry with an explicit country or postal-code destination returns HTTP 400. Remove fallbackCountry when you switch to an explicit destination.
Without fallbackCountry, an IP lookup that cannot resolve a valid location returns HTTP 404. A resolved location with no matching delivery methods returns HTTP 200 with success: true and an empty prediction array.
Recommended Widget Usage with IP Addresses
For installation, configuration, styling, and the JavaScript API, see the Promise UI Plugin guide.
The Promise UI reference implementation provides an embeddable widget that calls this API. Use the examples below for a product detail page or checkout.
Replace YOUR_ACCOUNT_ID with your parcelLab account ID. Set data-country to the three-letter country code for your main customer market. For an IP request, the widget sends this value as fallbackCountry.
If you already have the shopper's delivery address, set data-postal-code and data-country to that address. A supplied postal code takes priority over IP Fetch. Otherwise, leave data-postal-code empty. The widget first checks for a saved shopper selection, then uses IP Fetch. If the public IP lookup fails, it requests a prediction for the configured country.
Load the production script once per page.
With IP Fetch enabled, the widget gets the shopper's public IP from https://api64.ipify.org and sends it to the Promise API. If your site uses a Content Security Policy, allow that host and https://api.parcellab.com in connect-src.
The screenshots show example predictions. Dates, cutoff times, carriers, and locations depend on the API response.
Product Detail Page: Estimate with Cutoff
Show the earliest estimated delivery date and the order cutoff. Hide the carrier and location controls to keep the widget small. The widget still uses the known, saved, resolved, or fallback destination.

Checkout: Editable Location and Delivery-by Date
Show the postal code and country from the IP response and let the shopper change them. The location icon marks an approximate location based on IP data or the fallback country. If no postal code is available, the widget shows the country and Add ZIP. Supply the checkout address instead when it is known.
Show the selected delivery method's latest estimated arrival date with "delivery by" wording and the carrier name. Hide the cutoff during checkout.
Replace the three SELECTED_* values below with the configured carrier, service level, and warehouse for the selected checkout shipping option. Initialize the widget only after that option is known. Use filters that identify that method, rather than a list of available methods.

The product-page example selects the method with the earliest earliest date. The checkout example restricts the request to the selected shipping option and displays its latest date. data-date-mode="by" controls the displayed date; it does not select the shipping option.
For checkout changes, initialize through the JavaScript API with the same settings and retain the returned widget instance. In your checkout's shipping-selection handler, call update() with all three filters together. Here, selectedShippingOption is your checkout's mapping to configured Promise values:
Changing HTML attributes alone does not update an active widget. If the selected option has no matching prediction, omit its delivery date instead of removing the filters to show another method.
Shopper changes through the ZIP or country controls skip further IP lookups. A country change clears the previous ZIP. The widget saves these manual selections for 30 days after the last change and reuses them on later visits when the page supplies no postal code. Public IP values and automatic locations are not saved in browser storage.
Select a Prediction
The prediction array can contain several delivery methods. Select the entry that matches the warehouse, carrier, and service level offered at checkout. The first entry is not a guarantee of the fastest or preferred service. Check success and whether the array contains a matching entry before displaying a date. An empty array has no date to display.
Integration Flow: Send, Read, and Save
Estimate before an address is known
Send user, destination=<shopper-IP>, and optionally fallbackCountry.
Read location.country and location.zip to show an approximate destination. Keep it separate from the delivery address.
Shopper supplies or confirms a destination
Send destination=<postal-code>_<ISO3-country>, or only the country if no postal code is available. Remove fallbackCountry.
Save a manual country and postal-code choice together if you want to reuse it. Clear the previous postal code when the country changes. Request a new prediction.
Display a matching shipping option
Read the selected prediction[] entry's prediction.earliest, latest, or mostLikely.
Use latest for "delivery by", or earliest and latest from the same entry for a range. Select the method offered at checkout.
Shopper places the order
Save the displayed ISO date or range, selected method, confirmed destination, and top-level requestId with the order.
Keep the promise shown at checkout. Do not replace it silently with a later prediction.
Create a v2 tracking
Send the saved date as announced_delivery_date and the saved request ID as customFields.requestID if this custom field is configured for your integration.
Use your normal authenticated tracking integration. The prediction request does not create a tracking or save the promise on the order.
Use the confirmed checkout address ahead of saved choices or IP estimates. Request a new prediction when the destination or shipping method changes and before the order is placed. Save ISO dates rather than localized text or cutoff durations. Treat location.zip values of null or "0" as no postal code. If no matching prediction is available, omit the date and let the shopper correct the destination.
The reference widget saves manual destination choices for 30 days, but it does not save the checkout promise to your order system. Its public API does not expose the selected prediction or response request ID. Use a custom API integration or extend the reference implementation to retain these values for the order. A custom integration must also manage destination storage itself. Keep automatic IP locations in temporary page state. See the product flow and field mapping, including how to send a v2 prediction through the v4 Order API.
Result Structure
Successful responses contain a prediction array. Every response from this endpoint includes location, which is either a resolved location or null. The requestId is for tracing and troubleshooting purposes only.
For example, this response shows a resolved location with no predictions:
country
String
Resolved ISO 3166-1 alpha-3 country code, such as DEU.
region
String
Resolved region used to select delivery methods, such as DE-BY. For a country-level location, this is the two-letter country code, such as DE.
zip
String or null
Normalized postal code. A country-level location uses null for countries with postal-code validation, or the string "0" for countries without it.
For IP and explicit destinations, location shows the location used to select delivery methods. When the fallback is used, it shows the fallback location. For example, a USA fallback has country: "USA", region: "US", and zip: null.
location is null before destination resolution or if resolution fails. If an error occurs after resolution, the response retains the resolved location. A non-null location does not guarantee a prediction or a successful response.
Each entry in the prediction array represents one delivery method, including a delivery prediction like the following structure:
Delivery Prediction Details
The details included in a delivery prediction are described in the following table.
min
Integer
The minimum number of expected courier working days until delivery. Note: The value for minimum and maximum can be equal.
max
Integer
The maximum number of expected courier working days until delivery.
Note: The value for minimum and maximum can be equal.
likely
Integer
The most likely number of expected courier working days until delivery.
earliest
ISO 8601 date format: YYYY-MM-DD
The earliest expected delivery date taking into consideration working days of the courier, holidays in the destination, and warehouse cut-off and handling times.
latest
ISO 8601 date format: YYYY-MM-DD
The latest expected delivery date taking into consideration working days of the courier, holidays in the destination, and warehouse cut-off and handling times.
earliestLocale
Defaults to dddd, MMM DDD, YYYY
Localized representations of the earliest expected delivery date in the specified format.
latestLocale
Defaults to dddd, MMM DDD, YYYY
Localized representations of the latest expected delivery date in the specified format.
mostLikelyLocale
Defaults to dddd, MMM DDD, YYYY
Localized representations of the most likely delivery date in the specified format.
cutoff
Integer
The time in minutes until cut-off for the estimated delivery dates.
cutoffLocale
String
Localized representations of the cut-off. Can be used within a sentence like "Order within [2 hours | an hour | 20 minutes] to receive your order by [Saturday, Mar 23rd, 2022]".
Handle Errors and Empty Results
Check both the HTTP status and success. An HTTP 200 response can contain success: false. Some error responses do not include prediction.
Invalid fallbackCountry, or fallback supplied with a non-IP destination
400
success: false, location: null, and error: "Invalid fallbackCountry: use an ISO3 country with an IP destination".
Account does not have Promise enabled
401
success: false, location: null, and error: "Access denied.". A fallback does not bypass this check.
Destination cannot resolve, with no fallback supplied
404
success: false, location: null, and error: "Nothing found.". This also applies when IP lookup is unavailable.
No matching methods, or selected methods produce no predictions
200
success: true, the selected location, and prediction: [].
Prediction generation fails
200
success: false, error: "Could not generate prediction", and prediction: []. The response retains location if it was resolved.
If there is no prediction to display, let the shopper enter their country and postal code and request a new prediction without fallbackCountry.
Sample Calls
The sample API calls below show different information in the request (for example: home delivery as the courier service type) for the delivery prediction.
Request: GET https://api.parcellab.com/v2/prediction?user=1612197&destination=DEU
Example response:
Request: GET https://api.parcellab.com/v2/prediction?user=1612197&destination=80469_DEU
Example response:
Request: GET https://api.parcellab.com/v2/prediction?user=1612197&destination=USA&courierServiceLevel=home-delivery
Example response:
For an IP request with fallbackCountry=USA, the following example shows a fallback that has no matching delivery methods. The API still returns the country-level location:
Calculating Delivery Dates for Orders with Known Dispatch Date
For orders where you know the actual dispatch date, you can calculate accurate delivery dates based on when the order will ship. This is useful for scenarios where:
An order's dispatch date is confirmed after placement
You need to provide customers with updated delivery expectations based on actual shipment dates
Customer service agents need to communicate accurate timelines for existing orders
How It Works
To calculate a delivery date for an already placed order when you know the dispatch date, use these two parameters together:
_now=<date>- set this to the known dispatch date/time in ISO 8601 UTC format (for example:2025-07-01T16:00:00.000Z)dispatchNow=true- this forces the API to skip warehouse cutoff calculations and calculate the delivery date as if the parcel ships at the exact time specified in_now
Testing Your Promise Configuration
To preview saved but unpublished changes to your Promise configuration in a staging environment:
Integrate the Promise API call to your staging environment.
Add the query parameter
&draft=trueto your Promise API call.
This will generate a promise date based on your unpublished Promise configuration, that can be used to review the effect of any configuration updates on the frontend of your staging environment.
Last updated
Was this helpful?