Function uber_api::create_delivery

source ·
pub async fn create_delivery<T: Into<CreateDeliveryRequest>>(
    access_token: &str,
    customer_id: &str,
    create_delivery_request: T
) -> Result<(CreateDeliveryResponse, String, StatusCode, String), UberError>
Expand description

Create a delivery between two addresses.

Request Path Parameters

NameTypeDescription
customer_idstringUnique identifier for the organization. Either UUID or starts with cus_.

Request Body Parameters

NameTypeDescription
dropoff_addressstring - Structured Address(required) For single string, format is : “Street Address, City, State, Zip”
dropoff_namestring(required) Name of the place where the courier will make the dropoff.
dropoff_phone_numberstring(required) The phone number of the dropoff location.
manifeststring(required) [SOON TO BE DEPRECATED] ’manifest_items` should be used instead.
manifest_itemsManifestltem[](required) List of items being delivered.
pickup_addressstring(required) Pickup address in Street Address, City, State, Zip format.
pickup_namestring(required) Name of the place where the courier will make the pickup.
pickup_phone_numberstring(required) Name of the place where the courier will make the pickup.
deliverable_actionDeliverableActionSpecify the “happy path” action for the courier to take on a delivery. When used, delivery action can be set to “leave at door” for a contactless delivery. Cannot leave at door when signature or ID verification requirements are applied when creating a delivery. Photo confirmation of delivery will be automatically applied as a requirement to complete dropoff.
dropoff_business_namestringBusiness name of the dropoff location.
dropoff_latitudedoubleDropoff latitude coordinate.
dropoff_longitudedoubleDropoff longitude coordinate.
dropoff_notesstringAdditional instructions for the courier at the dropoff location. Max 280 characters.
dropoff_seller_notesstringAdditional instructions provided by the merchant for the dropoff. Max 280 characters.
dropoff_verificationVerificationRequirementVerification steps (i.e. barcode scanning) that must be taken before the dropoff can be completed.
manifest_referencestringReference that identifies the manifest. Use this to connect a delivery to corresponding information in your system.
manifest_total_valueintegerValue (in US cents) of the items in the delivery. i.e.: $10.99=>1099.
pickup_business_namestringBusiness name of the pickup location.
pickup_latitudedoublePickup latitude coordinate.
pickup_longitudedoublePickup longitude coordinate.
pickup_notesstringAdditional instructions for the courier at the pickup location. Max 280 characters.
pickup_verificationVerificationRequirementVerification steps (i.e. barcode scanning) that must be taken before the pickup can be completed.
quote_idstringThe ID of a previously generated delivery quote.
undeliverable_actionUndeliverableActionSpecify the “unhappy path” action for the courier to take on a delivery once a normal delivery attempt is made and a customer is not available.
pickup_ready_dttimestamp (RFC 3339)Beginning of the window when an order must be picked up. Must be less than 30 days in the future.
pickup_deadline_dttimestamp (RFC 3339)End of the window when an order may be picked up. Must be at least 10 mins later than pickup_ready_dt and at least 20 minutes in the future from now.
dropoff_ready_dttimestamp (RFC 3339)Beginning of the window when an order must be dropped off. Must be less than or equal to pickup_deadline_dt .
dropoff_deadline_dttimestamp (RFC 3339)End of the window when an order must be dropped off. Must be at least 20 mins later than dropoff_ready_dt and must be greater than or equal to pickup_deadline_dt.
requires_dropoff_signatureboolean[DEPRECATED] Flag to indicate this delivery requires signature capture at dropoff.
requires_idbooleanFlag to indicate this delivery requires ID check (minimum age) at dropoff
tipintegerUpfront tip amount. 0.01 of the national currency (cents in US or $0.01 )
idempotency_keystringA key which is used to avoid duplicate order creation with identical idempotency keys for the same account. The key persists for a set time frame, defaulting to 6 hours
external_store_idstring(Optional) Unique identifier used by our Partners to reference a Store or Location
return_verificationVerificationRequirementVerification steps (barcode scanning, picture, or signature) that must be taken before the return can be completed.

Request Body Parameters - Structured Address

NameTypeDescription
street_addressarray[string]Array of street address elements. For example: [“2000 Ocean Ave”, “Floor 2” ]
citystring
statestring
zip_codestring
countrystring(optional)

Request Body Parameters - ManifestItem

NameTypeDescription
namestringDescription of item.
quantityintegerQuantity of items.
sizeSizeApproximate size of item. Specifying xlarge will cause dispatch to only couriers using a car or larger (no walkers/bikes/scooters/etc…).
dimensionsDimensions[optional] Struct that contains dimensions
priceinteger[optional] The price of the item. The value passed in should be based on 0.01 unit of the local currency. For example, in the US, a value of 1 would mean a cent ($0.01), and a value of 100 would mean a dollar ($1.00).
must_be_uprightboolean[optional] Whether the item should be in upright position (box of pizza, bottle of milk etc)
weightinteger[optional] Weight in grams
perishabilityinteger[optional] Perishability represents the number of minutes before an item expires. For example, an ice cream might have a perishability of 15 minutes from pickup
preparation_timeinteger[optional] How long a given item takes to prepare (in minutes)

ManifestItem - Size

NameTypeDescription
smallstringYou can carry it with one hand e.g. bottle of water.
mediumstringYou need a tote bag to carry it e.g. retail bag.
largestringYou need two hands to carry it e.g. computer monitor.
xlargestringYou will need to make multiple trips to/from a vehicle to transport e.g. grocery order. Specifying xlarge will cause dispatch to only couriers using a car or larger (no walkers/bikes/scooters/etc…).
bigstring[DEPRECATED] Same as large.

ManifestItem - Dimensions

NameTypeDescription
lengthinteger[optional] Length in centimeters
heightinteger[optional] Height in centimeters
depthinteger[optional] Depth in centimeters

Request Body Parameters - DeliverableAction

NameTypeDescription
deliverable_action_meet_at_doorstringMeet at door delivery. This is the default if DeliverableAction is not set.
deliverable_action_leave_at_doorstringThe “happy path” action for the courier to take on a delivery. When used, delivery action can be set to “leave at door” for a contactless delivery. Cannot leave at door when signature or ID verification requirements are applied when creating a delivery. Photo confirmation of delivery will be automatically applied as a requirement to complete drop-off.

Request Body Parameters - VerificationRequirement

NameTypeDescription
signatureboolean[DEPRECATED] Flag for if a signature is required at this waypoint. signature_requirement should be used instead.
signature_requirementSignatureRequirement[]Signature requirement spec to indicate that a signature must be collected at this waypoint.
barcodesBarcodeRequirement[]Barcode values/types that must be scanned at the waypoint. Number of elements in the array is equal to the number of barcodes that must be scanned.
pincodePincodeRequirementPincode requirement spec to indicate a delivery requires pincode confirmation upon delivery
packagePackageRequirementPackage verifications required for this waypoint.
identificationIdentificationRequirementIdentification scanning/verification requirements for this waypoint…
pictureboolean

VerificationRequirement - SignatureRequirement

NameTypeDescription
enabledbooleanFlag for if a signature is required at this waypoint.
collect_signer_namebooleanFlag for if the signer’s name is required at this waypoint.
collect_signer_relationshipbooleanFlag for if the signer’s relationship to the intended recipient is required at this waypoint.

VerificationRequirement - BarcodeRequirement

NameTypeDescription
valuestringString value encoded in the barcode.
typestringType of barcode. Valid values: “CODE39”, “CODE39_FULL_ASCII”, “CODE128”, “QR”.

VerificationRequirement - PincodeRequirement

NameTypeDescription
enabledboolWhen set to true in POST requests, the delivery will require pincode entry at handoff.
valuestringThe pincode that the customer must present at dropoff. This field will be ignored in the CreateDelivery requests, and the pin code is internally generated when this requirement is present.

VerificationRequirement - PackageRequirement

NameTypeDescription
bag_countintegerNumber of bags to be picked up.
drink_countintegerNumber of drinks to be picked up.

VerificationRequirement - IdentificationRequirement

NameTypeDescription
min_ageintegerMinimum age that must be verified for this delivery.

Request Body Parameters - UndeliverableAction

NameTypeDescription
leave_at_doorstringSpecify the “unhappy path” action for the courier to take on a delivery once a normal delivery attempt is made and a customer is not available. Cannot leave at door when signature or ID verification requirements are applied when creating a delivery. Photo confirmation of delivery will be automatically applied as a requirement to complete drop-off.
returnstringSpecify the “unhappy path” action for the courier to take on a delivery once a normal delivery attempt is made and a customer is not available. This action requests the courier to return the delivery to the pickup waypoint.

Response Body Parameters

NameTypeDescription
completebooleanFlag indicating if the delivery is ongoing.
courierCourierInfoInformation about the courier. Only present when a delivery is in progress.
courier_imminentbooleanFlag indicating if the courier is close to the pickup or dropoff location.
createdtimestamp (RFC 3339)Date/Time at which the delivery was created.
currencystringThree-letter ISO currency code, in lowercase.
dropoffWaypointInfoDropoff details.
dropoff_deadlinetimestamp (RFC 3339)When a delivery must be dropped off. This is the end of the dropoff window.
dropoff_etatimestamp (RFC 3339)Estimated drop-off time.
dropoff_identifierstringThis field identifies who received delivery at the dropoff location.
dropoff_readytimestamp (RFC 3339)When a delivery is ready to be dropped off. This is the start of the dropoff window.
external_idstringAn ID for an account as stored in an external system.
feeintegerAmount in cents that will be charged if this delivery is created.
idstringUnique identifier for the delivery ( del_ + tokenize(uuid)).
kindstringThe type of object being described. Always “delivery”.
live_modebooleanFlag that indicates if this is live mode or test mode.
manifestManifestInfoA detailed description of what the courier will be delivering.
manifest_itemsManifestItem[]List of items being delivered.
pickupWaypointInfoThe pickup details for the delivery.
pickup_deadlinetimestamp (RFC 3339)When a delivery must be picked up by. This is the end of the pickup window.
pickup_etatimestamp (RFC 3339)Estimated time the courier will arrive at the pickup location.
pickup_readytimestamp (RFC 3339)When a delivery is ready to be picked up. This is the start of the pickup window.
quote_idstringID for the Delivery Quote if one was provided when creating this Delivery.
related_deliveriesRelatedDelivery[]A collection describing other jobs that share an association. i.e.: a return delivery.
statusstringThe current status of the delivery. ALLOWED VALUES: pending,pickup,pickup_complete,dropoff,delivered,canceled,returned,ongoing
tipintegerAmount in cents that will be paid to the courier as a tip.
tracking_urlstringThis url can be used to track the courier during the delivery (unauthenticated page).
undeliverable_actionstringIf a delivery was undeliverable, this field will contain the resulting action taken by the courier.
undeliverable_reasonstringIf a delivery was undeliverable, this field will contain the reason why it was undeliverable.
updatedtimestamp (RFC 3339)Date/Time at which the delivery was last updated.
uuidstringAlternative delivery identifier. “Id” field should be used for any identification purposes. “uuid” field is equally unique but loses contextual information (i.e. nothing in this identifier points out that it relates to a delivery). “uuid” is case-sensitive. Value for the “uuid” field is UUID v4 with ‘-’ characters removed.
returnWaypointInfoThe return details for the delivery.

Summary of order identifiers above

| :— | :— | :— | |ID |Description| Use case| |External Order ID (optional)| Generated by: Merchant Use your own ID structure| |UUID |Generated by: Uber. Unique order identifier created for every delivery.| When you need a single unique identifer| |Abbreviated UUID| Generated by: Uber. Last 5 digits of the UUID.| Shown as “Order ID” in Courier app| |Tokens |Generated by: Uber. We use three order tokens that track an order through 3 potential stages: Quote, delivery, and return. A token prefixed with dqt_ indicates the order is in the quote stage (A quote has been generated, but a delivery has not been created). del_ indicates the delivery stage (The delivery is in-progress), and ret_ indicates the order is in the return stage (The items are being returned to the merchant). You can track an order through its stages by referencing the same token, but prepending with the token identifier (e.g. dqt_XXXXXXXX becomes del_XXXXXXXX). These tokens are unique. | |

Response Body Parameters - CourierInfo

NameTypeDescription
namestringCourier’s first name and last initial.
ratingfloat[DEPRECATED] Courier’s rating on a scale of 1.0 to 5.0.
vehicle_typestringThe type of vehicle the courier is using. Currently support bicycle, car, van, truck, scooter, motorcycle, and walker.
phone_numberstringThe courier’s phone number. This is a masked phone number that can only receive calls or SMS from the dropoff phone number.
locationLatLngA latitude and longitude indicating courier’s location.
img_hrefstringA URL to courier’s profile image.

CourierInfo - LatLng

NameTypeDescription
latdoubleLatitude.
lngdoubleLongitude.

Response Body Parameters - WaypointInfo

NameTypeDescription
namestringDisplay name of the person/merchant at the waypoint.
phone_numberstringThe masked phone number of the waypoint.
addressstringThe address of the waypoint.
detailed_addressAddressStructured address of the waypoint.
notesstringAdditional instructions at the waypoint location.
seller_notesstringDelivery instructions provided by the seller for the courier at the waypoint location.
courier_notesstringWhen a picture is requested as proof-of-delivery, this field contains the notes provided by the courier (e.g. where the items were left).
locationLatLngGeographic location (Latitude, Longitude) associated with the waypoint.
verificationVerificationProofDetails about different verifications that have/will occur at this waypoint and any associated proof.
verification_requirementsVerificationRequirementDetails about the verification steps that have/must be taken at this waypoint.
external_store_idstringUnique identifier used by our Partners to reference a Store or Location

WaypointInfo - Address

NameTypeDescription
street_address_1string
street_address_2string
citystring
statestring
zip_codestring
countrystring
sublocality_level_1string

WaypointInfo - LatLng

NameTypeDescription
latdoubleLatitude.
lngdoubleLongitude.

WaypointInfo - VerificationProof

NameTypeDescription
signatureSignatureProofSignature information captured.
barcodesBarcodeRequirement[]Barcode values/types that were scanned.
picturePictureProofPicture captured at the waypoint.
identificationIdentificationProofIdentification information or scanning information captured.
pin_codePincodeProofPin entry data available after delivery completes.///

VerificationProof - SignatureProof

NameTypeDescription
image_urlstringThe url of the signature image.
signer_namestringThe name of the person who signed for the package.
signer_relationshipstringThe relationship of the person who signed for the package to the intended recipient.

VerificationProof - BarcodeRequirement

NameTypeDescription
valuestringString value encoded in the barcode.
typestringType of barcode. Valid values: “CODE39”, “CODE39_FULL_ASCII”, “CODE128”, “QR”.

VerificationProof - PictureProof

NameTypeDescription
image_urlstringThe url of the image taken at the waypoint.

VerificationProof - IdentificationProof

NameTypeDescription
min_age_verifiedbooleanFlag if ID was successfully verified/scanned.

VerificationProof - PincodeProof

NameTypeDescription
enteredstringValue entered during pin verification.

WaypointInfo - VerificationRequirement

NameTypeDescription
signatureboolean[DEPRECATED] Flag for if a signature is required at this waypoint. signature_requirement should be used instead.
signature_requirementSignatureRequirement[]Signature requirement spec to indicate that a signature must be collected at this waypoint.
barcodesBarcodeRequirement[]Barcode values/types that must be scanned at the waypoint. Number of elements in the array is equal to the number of barcodes that must be scanned.
pincodePincodeRequirementPincode requirement spec to indicate a delivery requires pincode confirmation upon delivery.
packagePackageRequirementPackage verifications required for this waypoint.
identificationIdentificationRequirementIdentification scanning/verification requirements for this waypoint…
pictureboolean

VerificationRequirement - SignatureRequirement

|Name Type| Description| | :— | :— | :— | |enabled |boolean| Flag for if a signature is required at this waypoint.| |collect_signer_name |boolean| Flag for if the signer’s name is required at this waypoint.| |collect_signer_relationship |boolean| Flag for if the signer’s relationship to the intended recipient is required at this waypoint.|

VerificationRequirement - BarcodeRequirement

NameTypeDescription
valuestringString value encoded in the barcode.
typestringType of barcode. Valid values: “CODE39”, “CODE39_FULL_ASCII”, “CODE128”, “QR”.

VerificationRequirement - PincodeRequirement

NameTypeDescription
enabledboolWhen set to true in POST requests, the delivery will require pincode entry at handoff.
valuestringThe pincode that the customer must present at dropoff. This is a read-only field available in GET requests that will contain the internally generated pincode.

VerificationRequirement - PackageRequirement

NameTypeDescription
bag_countintegerNumber of bags to be picked up.
drink_countintegerNumber of drinks to be picked up.

VerificationRequirement - IdentificationRequirement

NameTypeDescription
min_ageintegerMinimum age that must be verified for this delivery.

Response Body Parameters - ManifestInfo

NameTypeDescription
referencestringReference that identifies the manifest.
descriptionstring[DEPRECATED] A detailed description of what the courier will be delivering. It is better to consume the description of each item in ManifestItem.name.
total_valueintegerValue of the items in the delivery, in local currency (as defined by the pickup location). e.g. $10.99 => 1099 for items in the US.

Response Body Parameters - ManifestItem

NameTypeDescription
smallstringYou can carry it with one hand e.g. bottle of water.
mediumstringYou need a tote bag to carry it e.g. retail bag.
largestringYou need two hands to carry it e.g. computer monitor.
xlargestringYou will need to make multiple trips to/from a vehicle to transport e.g. grocery order. Specifying xlarge will cause dispatch to only couriers using a car or larger (no walkers/bikes/scooters/etc…).
bigstring[DEPRECATED] Same as large.

Response Body Parameters - RelatedDelivery

NameTypeDescription
idstringUnique identifier for the delivery.
relationshipstringIndicating the nature of the delivery identified in related_deliveries. “original” for the forward leg of the trip, and “returned” for the return leg of the trip.

Endpoint Specific Errors

Http Status CodeCodeMessage
409duplicate_deliveryAn active delivery like this already exists. A pointer to the other delivery is provided.
400invalid_paramsThe parameters of your request were invalid.
400unknown_locationThe specified location was not understood.
400address_undeliverableThe specified location is not in a deliverable area.
400expired_quoteThe price quote specified has expired.
400used_quoteTThe price quote specified has expired.
400mismatched_price_quoteThe price quote specified doesn’t match the delivery.
400missing_paymentYour account’s payment information has not been provided.
400pickup_ready_time_not_specifiedPickup ready time must be specified when passing in pickup/dropoff windows.
400pickup_window_too_smallThe pickup window needs to be at least 10 minutes long.
400dropoff_deadline_too_earlyThe dropoff deadline needs to be at least 20 minutes after the dropoff ready time.
400dropoff_deadline_before_pickup_deadlineThe dropoff deadline needs to be after the pickup deadline.
400dropoff_ready_after_pickup_deadlineThe dropoff ready time needs to be at or before the pickup deadline.
400pickup_ready_too_earlyThe pickup ready time cannot be in the past.
400pickup_deadline_too_earlyThe pickup deadline time needs to be at least 20 minutes from now.
400pickup_ready_too_lateThe pickup ready time needs to be within the next 30 days.
402customer_suspendedYour account is passed due. Payment is required.
403customer_blockedYour account is not allowed to create deliveries.
422address_undeliverable_limited_couriersThe specified location is not in a deliverable area at this time because all couriers are currently busy.
429customer_limitedYour account’s limits have been exceeded.
500unknown_errorAn unknown error happened.