POST
/v1.5/bookings/create
Allow users on your app to book an Ola ride of their choice. Just ensure their Ola account is linked through OAuth authentication. Once ride is booked and cab is allotted to the booking, the below information is made available:
Name | Data Type | Description | Type | Remark |
---|---|---|---|---|
pickup_lat | float | Latitude of the pickup location | Payload | Mandatory |
pickup_lng | float | Longitude of the pickup location | Payload | Mandatory |
category | string |
Ride category
|
Payload | Mandatory |
drop_lat | float | Latitude of the drop location | Payload | Optional (Mandatory if upfront pricing applicable) |
drop_lng | float | Longitude of the drop location | Payload | Optional (Mandatory if upfront pricing applicable) |
pickup_mode | string | Time of pickup [now, later] | Payload | Mandatory |
payment_instrument_type | string | Mode of payment [cash, ola_money] | Payload | Optional (Ola Money balance will be default) |
fare_id | string | Reference ID sent in ride estimate to lock upfront price | Payload | Optional (Mandatory if upfront pricing applicable) |
affiliate_uid | string | User-ID on your platform | Payload | Optional (Mandatory for affiliate_payments booking) |
coupon_code | string | Partner-specific offer code | Payload | Optional |
merchant_txn_id | string | Partner side transaction id
Allowed characters: [A-Z] [a-z] [0-9] [-] |
Payload | Optional |
X-APP-TOKEN | string | Unique key for the partner | Header | Mandatory |
Authorization | string | Unique key for the user (to be passed as Bearer token) | Header | Mandatory |
Once user selects category of choice and confirms for the ride to be booked, the API for booking creation can be called. If the request is correct, a booking id is first generated and sent in the response. The system then starts searching for nearby cabs to be allotted to the booking. There are two possibilities:
POST
https://devapi.olacabs.com/v1.5/bookings/create
{
"drop_lat":"12.9592",
"drop_lng":"77.6974",
"pickup_lat":"12.9523",
"pickup_lng":"77.6432",
"category": "mini",
"pickup_mode":"now"
"payment_instrument_type":"cash",
"fare_id": "1:000008:50002738-7242-4728-9644-0ae0d6fceb01",
"coupon_code": "DISC50"
"affiliate_uid": "shfjh3342",
"merchant_txn_id":"Aabc-12as123if-123123a"
}
Headers: {
authorization: Bearer 9b16121212f12ff12f12f1f12f1f12f2
x-app-token: fd5d4d3726121212f12ff12f12f1f12f1f12fa
}
{
"status": "SUCCESS",
"booking_id": "CRN123456789",
"message": "Searching for a cab.",
"merchant_txn_id":"Aabc-12as12if-123123a",
"booking_timeout": 70, // time post which driver allocation will no longer happen
"booking_timeout_unit": "SECONDS"
}
Once success is received in the response, keep polling Track Ride API (Link) to get driver allotment status. The response will show ‘booking_status’ as one of the following:
When the status is allotment pending, the users on your app can be shown a loading screen. On successful allotment, the cab/driver/otp details can be displayed on the screen. In case of no allotment, the same can be conveyed to the users asking them to try booking again.
Car category parameter sent is not valid
{
"message": "BOOKING_FAILED",
"code": "INVALID_CAR_CATEGORY"
}
Pickup lat-lng are in a city where Ola is not available
{
"message": "BOOKING_FAILED",
"code": "INVALID_CITY"
}
Pickup and Drop lat-lng sent are the same
{
"status": "FAILURE",
"code": "SAME_PICKUP_DROP",
"message": "Pickup and drop locations cannot be the same."
}
User’s Ola account is in banned or deactivated state
{
"status": "FAILURE",
"code": "BANNED USER",
"message": "Your account has been suspended due to violation of Ola policies. Please contact our customer care."
}
User has outstanding payment due from a previous ride
{
"status": "FAILURE",
"code": "OUTSTANDING_DUE" or "PAYMENT_PENDING" or "OLA_CREDIT_DUE"
"message": "Please clear the amount due for previous ride(s). Update your app if you don't see your payment options."
}
Pickup and Drop lat-lng are in different cities
{
"status": "FAILURE",
"code": "INVALID_DROP_LOCATION",
"message": "Please enter a drop location within your city"
}
When the system is searching for cabs, user can choose to abort the process of driver allotment. In that case, the abort booking API can be called by sending the ‘booking_id’ provided in the create booking API response. If a driver has already been allotted, abort will not work and it will throw a failure.
POST
https://devapi.olacabs.com/v1/bookings/abort
{ "booking_id":"CRN123456789" }
Headers: { Authorization: Bearer 9b6121212f12ff12f12f1f12f1f12f2 x-app-token: fd6121212f12ff12f12f1f12f1f12fa }
{
"status": "SUCCESS",
"message": "Booking Cancelled Successfully",
"code": "SUCCESS"
}
{
"status": "FAILURE",
"message": "You can track your ride in a moment.",
"code": "BOOKING_ALLOTED"
}
Once success is received in Abort Booking API, calling Track Ride API sends booking_status as ‘BOOKING_CANCELLED’ in the response.
POST
/v1/bookings/drop_location
Update drop location after a booking has been created.
Name | Data Type | Description | Type |
---|---|---|---|
drop_lat | float | The latitude of the drop location. | Payload |
drop_lng | float | The longitude of the drop location. | Payload |
booking_id | string | Booking ID for the ride | Payload | Authorization | string | OAuth token(OAuth access token must be passed as Authorization header with Bearer token.) | Header |
X-APP-TOKEN | string | Key which identifies the partner | Header |
Content-Type | string | "application/json" to be passed | Header |
POST
https://devapi.olacabs.com/v1/bookings/drop_location
"body": {
"drop_lat": 12.972934,
"drop_lng": 77.722302,
"booking_id": "CRN123456789"
}
"headers": {
"Authorization": "Bearer b6121212f12ff12f12f1f12f1f12fbf",
"X-APP-TOKEN": "6a56121212f12ff12f12f1f12f1f12fc",
"Content-Type": "application/json"
}
{
"status": "SUCCESS",
"request_type": "Update User Booking Drop Location"
"header": "SUCCESS",
"text": "Drop Location Updated"
}
Failure response in case of updating the drop location to a different city.
{
"status": "FAILURE",
"request_type": "Update User Booking Drop Location",
"header": "Invalid Drop Location",
"text": "Please enter a drop location within your city"
}
Failure response in case of updating drop location of a completed ride.
{
"status": "FAILURE",
"request_type": "Update User Booking Drop Location",
"header": "Oops!",
"text": "Sorry, the ride is already completed or cancelled!"
}