Skip to content

Developer notes

Technical reference for developers who customize Uber Direct Same-Day Delivery.

Item Value
Add-on id kv_uber_direct
Function prefix fn_kv_uber_direct_
Language variables kv_uber_direct.*
CSS scope .kv-uber-direct
PHP namespace Tygh\Addons\KvUberDirect
Preset shipping (generated by kv new --kind integration)
Class Role
Client\BaseClient HTTP (cURL, TLS verification, timeouts), JSON, OAuth2 client-credentials with an encrypted token cache, error mapping, masked logging
Client\Api The Uber Direct calls (below)
Client Client per company, the connection test
Mapper Pure mappings: address JSON, E.164 phone, item size, quote and delivery bodies and answers, status to state, webhook to state. Unit-tested with the examples of the documentation
Quotes The quote of a checkout: session store per company and dropoff address, saved with the order (?:kv_uber_direct_quotes), freshness rule (15 minutes minus 60 s)
RateCalculator Shipping rate: Create Quote, fee in minor units to the store currency, surcharge, ETA, 2-minute cache, 5-minute memory of a refused address, flat fallback
Shipments One row per delivery, created BEFORE the POST; create / adopt / cancel / track / webhook apply under per-order locks
Webhook x-uber-signature HMAC-SHA256 check, event ids; the controller kv_uber_direct.webhook?c=<account> stores the event as a job
Pickup Pickup address per company (saved, or the company address)
Accounts, Secret Credentials (test and live) sealed with AES-256-GCM; one account per store owner or per vendor
Config, Access Settings, owner mode, who may see and manage what
Queue, Jobs, JobException Job queue: back-off 5 min / 15 min / 1 h / 3 h / 12 h, per-job isolation, overlap lock
Log Event log with masking, filters, CSV, retention
Table Purpose
?:kv_uber_direct_accounts Credentials per company (secrets sealed), Customer ID and host per mode (extra), last connection check, token cache
?:kv_uber_direct_log Log
?:kv_uber_direct_jobs Queue
?:kv_uber_direct_shipments Deliveries: provider_ref = Uber delivery id (del_...), quote_id, client_reference, tracking_url, state, courier
?:kv_uber_direct_pickups Pickup address per company
?:kv_uber_direct_quotes The quote saved with an order (quote_id, fee, currency, expires_at, hash of the dropoff address)

PHP hooks (registered in init.php, handlers in func.php): change_order_status_post (queue the booking / cancellation at the configured statuses), place_order (save the checkout quote with the order), delete_order (drop the quote), get_order_info (storefront: tracking line for the customer). Template hooks: orders:tabs_extra (admin, the order tab), index:styles (backend and storefront CSS), orders:totals_shipping (storefront order page: tracking link). Shipping service: Tygh\Shippings\Services\KvUberDirect (service code same_day).

Official documentation: https://developer.uber.com/docs/deliveries (read 2026-11-13). “Verified” = the page we read states the path and fields; “To verify” = the public pages did not show it (the reference is rendered by a script or sits in the Postman workspace) and the shape is taken from the documented examples and the public OpenAPI summary: confirm it with the first real test account (tests/mock-server/server.js follows exactly what is written here).

Page: guides/authentication and get-started.

  • POST https://auth.uber.com/oauth/v2/token, Content-Type: application/x-www-form-urlencoded.
  • Form fields: client_id, client_secret, grant_type=client_credentials, scope=eats.deliveries.
  • Answer fields: access_token, expires_in (2592000 = 30 days), token_type (Bearer), scope. The token is cached (encrypted) and sent as Authorization: Bearer <access_token>; it cannot be refreshed, a new one is requested after it expires or after a 401. The page limits client-credential requests to 100 per hour.
  • Error codes of the endpoint: invalid_request, invalid_client, invalid_scope, server_error, unauthorized. invalid_client pauses the account (no automatic call for six hours).
  • Credentials (Customer ID, Client ID, Client Secret): Developer tab, Management section of the dashboard (get-started).
  • API: https://api.uber.com/v1/customers/<customer_id>/ (get-started). In Test mode the guide’s create-delivery example answers "live_mode": false on this host.
  • Sandbox host: not stated on the public pages (the FAQ mentions sandbox rate limits of 200 requests per 10 minutes per application and a rate limit added to the sandbox on 2025-10-27; a community report names sandbox-api.uber.com). To verify. The host is the setting API host per mode (https below uber.com, validated in Client\Api::validHost); tests redirect everything to a local mock with $config['kv_uber_direct_base_url'].

POST /v1/customers/{customer_id}/delivery_quotes (get-started).

  • Request: pickup_address, dropoff_address: each a JSON-encoded string {"street_address": ["20 W 34th St", "Floor 2"],"state":"NY","city":"New York","zip_code":"10001","country":"US"}. Optional (change log 2023-05-09 on phone format): pickup_phone_number, dropoff_phone_number in E.164. The FAQ asks for apartment or unit numbers as a separate street line and for the same address format in quote and delivery (otherwise a “delivery location changed” error): Mapper::address() builds one format for both, Quotes::cartDropoff() and Shipments::dropoffAddress() use the same fields.
  • Answer fields: kind (delivery_quote), id (dqt_...), created, expires (15 minutes after created; FAQ: valid for 15 minutes), fee (minor units, 558 = 5.58), currency (usd), currency_type, dropoff_eta, duration (minutes), pickup_duration, dropoff_deadline.
  • Used: id, fee, currency, expires, dropoff_eta, duration, pickup_duration (Mapper::quote).

Create Delivery (verified for the fields listed)

Section titled “Create Delivery (verified for the fields listed)”

POST /v1/customers/{customer_id}/deliveries (get-started, guides/robocourier).

Field we send Source
quote_id get-started: “it is essential to include the quote_id obtained from the previous step”
pickup_name, pickup_address, pickup_phone_number, pickup_notes get-started, robocourier sample
dropoff_name, dropoff_address, dropoff_phone_number, dropoff_notes get-started, robocourier sample
manifest_items[]: name, quantity, size (small, medium, large, xlarge; the examples show small and large) get-started, SDK guide, webhook example
manifest_reference, external_id, idempotency_key robocourier sample payload (“idempotency_key”, “external_id”, “manifest_reference”). Our value is kv<token>-<order id>-<attempt>. The change log mentions a default dedupe duration of 60 minutes for the key (to verify the exact rule)
tip (minor units) robocourier sample ("tip": 500)
undeliverable_action (return default, leave_at_door) robocourier page, “Undeliverable actions”
dropoff_verification (signature, picture) robocourier sample ("dropoff_verification": {"signature": true}); change log 2024-07-01 for type / no_sobriety_check (not sent)
test_specifications.robo_courier_specification.mode = "auto" robocourier page; sent only in Test mode when the setting is on

Not sent (deliberately): manifest_items.weight (the unit is not stated on the pages we read), price, coordinates (Uber geocodes; a coordinate more than 1 km from the address is overwritten per the FAQ), pickup / dropoff windows (pickup_ready_dt etc., guides/delivery-window; this product books on-demand couriers).

Answer fields read (Mapper::deliveryInfo): id (del_...), quote_id, status, courier_imminent, tracking_url (the page says not to modify it), fee, currency, live_mode, external_id, manifest.reference, courier.name, courier.location.lat/lng, undeliverable_reason, cancelation_reason.secondary_reason (CUSTOMER_CANCEL, COURIER_CANCEL, MERCHANT_CANCEL, UBER_CANCEL; the Delivery Status webhook page says primary_reason “will always be #Uber”, so it is only the fallback).

Get Delivery, List deliveries, Cancel Delivery (to verify)

Section titled “Get Delivery, List deliveries, Cancel Delivery (to verify)”
  • GET /v1/customers/{customer_id}/deliveries/{delivery_id}: Uber’s reference lists a “Get Delivery” endpoint (the Delivery Status webhook page says the delivery data can be fetched with it, and the change log names it); the path is the conventional one. To verify.
  • GET /v1/customers/{customer_id}/deliveries?limit=<n>: listed by the public OpenAPI summary of the Direct API. The filter parameters are not shown on the pages we could read, so we send limit only and match our reference ourselves (Mapper::matchDelivery: exact external_id or manifest.reference, never a loose or ignored filter). To verify.
  • POST /v1/customers/{customer_id}/deliveries/{delivery_id}/cancel: the change log (2025-12-08) says optional reason fields were added to Cancel Delivery but does not name them, so we send an empty JSON object and keep the reason in our own log. Cancellation is possible only before pickup (state pending or pickup); Uber’s answer decides, a 4xx makes the add-on read the real state. To verify.
  • Error body shape: not printed on the pages we could read. Client\Api::errorFrom reads a message (message, error_description, detail, title) and a code (code, error) generically. A 4xx other than 401, 403, 408, 425, 429 on a quote is a refusal (the method is not offered, not retried); 429 and 5xx are retried. To verify with a real answer.

Pages: guides/webhooks, Delivery Status Webhook, Courier Update Webhook. Webhooks are created in the dashboard (Developer tab), not through the API.

  • Signature: header x-uber-signature = hex HMAC-SHA256 of the raw body with the webhook’s “Webhook Signing Key” (dashboard: webhook menu > Edit). x-postmates-signature is accepted by Uber only for Delivery Status and Courier Update; we accept both names. Webhook::authenticate hashes the body as received (a parser that re-encodes & breaks the hash, as the page warns) and compares in constant time. The sample of the page (key c5c26d5a-70d6-46c7-a652-d7c09825ad29) is a unit test.
  • event.delivery_status: top level id (event id, our idempotency key), kind, delivery_id, status, live_mode, created, data{...} (delivery object). Statuses: pending, pickup, pickup_complete, dropoff, delivered, canceled, returned (the page also lists shopping_completed, ignored); courier_imminent accompanies pickup and dropoff.
  • event.courier_update: top level kind, delivery_id, location{lat,lng}, data.courier{name, location, vehicle_type, ...}; sent every 20 seconds once a courier is assigned. Position and courier name only; the state never moves from it.
  • Retries by Uber: HTTP 500, 502, 503, 504, timeouts and network errors, 10 s then 30 s, 60 s, 120 s, up to 3 events in total. For other statuses the page recommends Get Delivery: the scheduled check (Jobs::schedule) does that. The expected success status is not stated; we answer 200 OK.
  • Mode safety: the signing key that matched decides the mode (test / live); an event whose live_mode does not fit that mode is ignored (Shipments::applyEvent).

pending C (waiting) · pickup A (courier on the way; courier_imminent = arriving) · pickup_complete and dropoff T (package with the courier) · delivered D · returned P · canceled X. A state never moves backwards; D and X are final.

  1. Shipments::create takes GET_LOCK per order and inserts the row (state Q, reference) before any POST.
  2. The reference is sent as idempotency_key, external_id and manifest_reference.
  3. sent_at is stored before the POST. After a timeout, a 5xx, a cut connection or a 409 / 422 the next attempt lists deliveries and adopts the one that carries our exact reference instead of creating another.
  4. A refusal (4xx) marks the row E with the reason; a manual retry reuses the same reference.
  5. Webhooks and cron claim states under the same per-order lock; a late answer never downgrades a final state.

The base URL can be overridden for tests in config.local.php (development only; the e2e refuses to run otherwise):

$config['kv_uber_direct_base_url'] = 'http://127.0.0.1:12891';

node tests/mock-server/server.js 12891 starts a local stand-in that follows this page (token, quote with 15-minute expiry and unit check of E.164 phones and address JSON, delivery with idempotency_key dedupe, list, get, cancel, signed webhooks, failure and “answer lost” injection). node tests/e2e/e2e.mjs runs the HTTP end-to-end test against it; php tests/unit.php runs the unit tests (fixtures copied from the documentation: tests/fixtures/SOURCES.md).

Admin templates live in design/backend/templates/addons/kv_uber_direct/. Do not edit them in a store; they are replaced on update.

The add-on uses the plain text “Uber Direct” (descriptive, nominative) and no Uber logo: the public pages we read give no logo licence for integrators (the developer design guidelines point to the Uber Newsroom assets and an “Integration Design guidelines” PDF). See research/brand-assets/uber_direct/SOURCE.md.