Overview
¶ Employee Trip Sandbox API Overview
The Sandbox API provides a way to test the endpoints and user flows without actually requesting a real trip.
All requests made to the Sandbox environment are ephemeral.
To use the Sandbox, make calls to https://sandbox-api.uber.com.
Note: Sandbox APIs can only be used on test organizations.
Environment | Host |
---|---|
Production | https://api.uber.com |
Sandbox | https://sandbox-api.uber.com |
The Sandbox environment relies on the concept of “runs” to create interactive test trips and mock driver behavior. A run will create temporary drivers that will disappear after 8 hours.
Look for Try It tags throughout the documentation for sandbox examples.
¶ Mocking trips
¶ Getting started
¶ 1. Create a run
First call /v2/employees/sandbox/run to create a run.
This will setup temporary test drivers that will exist for 8 hours.
The run_id
will be re-usable as long as you want to make test trips in the same city for the duration of the run.
Ensure that the driver locations are in a city Uber operates in.
This can be verified using /v2/employees/trips/estimates.
Choose a product_id
corresponding to a product available in the chosen driver location.
curl -i -X POST "https://sandbox-api.uber.com/v2/employees/sandbox/run" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"product_id": "0d439f19-6ff4-45a5-a9f7-044f1242cd65",
"drivers": [
{
"location": {
"latitude": 28.5744836,
"longitude": 77.1526162
}
}
]
}'
Once this call is made, it may take up to a minute for the mock setup to complete.
¶ 2. Obtain the test driver driver_ids
After waiting a minute, call v2/employees/sandbox/run/:run_id.
This will return the test driver_ids
that you will need for /v2/employees/sandbox/driver-state.
If this call failed, it means that the run creation failed and the inputs for POST /run
were probably invalid.
The driver is automatically changed to a GO_ONLINE
state but will GO_OFFLINE
after 5 minutes if there is no driver activity.
¶ 3. Obtain the product_id
You will need to query /v2/employees/trips/estimates to get a product_id
that corresponds to the parent_product_type_id
you chose in /v2/employees/sandbox/run.
Make sure that the product_id
does NOT have "no_cars_available": true
.
If the product_id
shows "no_cars_available": true
, then drivers may have gone offline, and you will need to use /v2/employees/sandbox/driver-state to change the driver’s state to GO_ONLINE
.
If you want to create a trip with upfront fare enforced, you can also use the fareID
in the /v2/employees/trips/estimates response to then pass into /v2/employees/trips.
¶ 4. Create a trip
Call /v2/employee/trips with the sandbox URL to create a trip.
The product_id
used to create the trip, should be the same as the product_id
chosen in step 1.
¶ 5. Update a trip
Call /v2/employee/trips{} with the sandbox URL to update a trip.
¶ 6. Accept the trip
Call /v2/employees/sandbox/driver-state with state
as ACCEPT
to accept the trip.
Once the trip is accepted, subsequently call the same API with state
as BEGIN_TRIP
and then as DROPOFF
to complete the trip.
The driver can also CANCEL
after the ACCEPT
state.
¶ Multiple trips
To make multiple subsequent trips in the same city, you can re-use the same driver_ids
.
¶ Scheduled Trips
If you are making a scheduled trip, the driver may GO_OFFLINE
before the trip is dispatched. Please set the driver state to GO_ONLINE
within a minute of the scheduled pickup time.
¶ Uber Reserve and Hourly Trips
The Sandbox environment doesn’t provide full support for simulating Uber Reserve and Hourly Rides.
It is not possible to set the driver state to ACCEPT
, and this prevents updating the destination and intermediate stops for these trips using the PUT /v2/employees/trips/{trip_id} API.
¶ Available Endpoints
Method | Endpoint | Description |
---|---|---|
POST | /v2/employees/sandbox/run | Creates a new run to setup interactive sandbox trips |
GET | v2/employees/sandbox/run/:run_id | Retrieves the run’s test driver_ids to use in /v2/employees/sandbox/driver-state. |
POST | /v2/employees/sandbox/driver-state | Changes the driver state during a run. |