Webhooks
Webhooks are an important service that enable near realtime updates for every trip ordered through the API to be pushed to a web URL defined in your application’s settings. The Developer App settings page can be found below by modifying the URL below with your applications CLIENT_ID.
https://developer.uber.com/dashboard/app/<CLIENT_ID>/settings
¶ Introduction
Webhooks are a communication standard that makes it easy to get push notifications as an event happens. Unlike APIs where you call an endpoint for data, you provide a callback URL where you will be notified as events happen. For example, when an Uber ride is ordered through the API, Uber can send information through HTTP POST to your callback URL. Your callback URL can then execute code based on the POST.
Webhooks can be sent more than once and the delivery is not guaranteed to be in order. To defend against this behavior, a resource_href is provided in the body of the POST to get the most update-to-date information on each resource.
¶ Configure your Webhook
To enable webhooks, log in to the developer dashboard and go the Settings tab for your app. Under the Ride Requests section, add your webhook URL and Signing Key, then click save. The Developer App settings page can also be found below by modifying the URL below with your applications CLIENT_ID.
https://developer.uber.com/dashboard/app/<CLIENT_ID>/settings
You can enter any URL you’d like to have events sent to, but this should be a dedicated https page on your server. You can also enter any Signing Key you would like to verify the sender. Some clients use the app secret for this purpose, but that is not required.
¶ Retry Attempts
If for some reason the Uber API cannot reach the webhook URL you specified either due to networking issues or application issues on your end, the webhooks service will retry to make a request.
We have implemented an exponential back-off algorithm with a back-off multiplier of 30 seconds which will make up to 7 attempts. This means we will attempt to request your webhook URL up to 7 times across roughly 1 hour.
¶ Webhook Headers
The Uber API will insert specialized headers for all requests made to your webhook URL to help your application utilize them appropriately.
Header | Description |
---|---|
X-Environment |
Indicates if this request is coming from the production or sandbox API. |
X-Uber-Signature |
SHA256 hash of the request body, computed using the app’s signing key as the key. |
¶ Webhook Security
Webhook messages are signed so that your app can verify that the sender is Uber. Webhooks requests contain an X-Uber-Signature
header. The value of this field is a hexadecimal HMAC signature of the webhook HTTP request body, using signing key of primary webhook url as a key and SHA256 as the hash function.
Python Example
digester = hmac.new(signing_key, webhook_body, hashlib.sha256)
return digester.hexdigest()
¶ POST Parameters
Webhooks sent from Uber’s servers will follow a standard format so that your application can easily understand what action it may want to take based on the contents of the payload.
¶ Available Webhooks
Endpoint | Description |
---|---|
health.status_changed | Event indicating that the status of a trip has changed. |
health.driver_location | Event indicating the updated real-time location of the driver for a trip. |
health.trip_message | Event indicating that the driver for the trip has sent a message. |
health.receipt_ready | Event indicating that a receipt has been created for the trip. |