Booking API
Booking API
The Booking API lets your own website (WordPress, plain PHP, or any server-side stack) push a visitor's enquiry or booking into BharatBilty. Each request creates a new Party / Customer in your account — exactly as if you had filled the “Add Party” form in the app — and your phone gets a push notification instantly.
1. Get your API key
- Log in to the BharatBilty app and open API Integration.
- Under API Keys, create a key for your business. You get one key per website, and each key is tied to one business.
- Copy the key and store it in your server config (environment variable /
wp-config.php).
Because the key is tied to a business, bookings from that website always land under that
business — any business_id you send in the body is ignored. The website name
shown in the notification and party record comes from the website set in your Business Details.
You can regenerate or delete a key at any time; the old key stops working immediately.
2. Endpoint
https://packers.bharatbilty.com/api/integrations/booking
| Header | Value |
|---|---|
X-API-Key | Your API key (required) |
Content-Type | application/json or application/x-www-form-urlencoded |
If you cannot set headers, you may send the key as an api_key field in the request body instead.
The header is preferred because it stays out of request logs.
3. Request fields
f_* fields describe the pickup / origin party and t_*
fields the destination / consignee. Only name is required.
Unknown fields are ignored.
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Required | Customer / party name. |
phone | string | Optional | Customer phone number. |
email | string | Optional | Valid email address (stored in lower case). |
gender | string | Optional | Customer gender. |
m_date | string | Optional | Preferred moving / shifting date, YYYY-MM-DD. |
f_gst | string | Optional | GSTIN of the pickup party. |
f_address, f_city, f_state, f_country, f_pin | string | Optional | Pickup address. f_pin is the PIN code. |
f_floor, f_is_lift | string | Optional | Pickup floor, and whether a lift is available (1 = yes, 0 = no). |
t_name, t_phone, t_gst | string | Optional | Destination / consignee name, phone and GSTIN. |
t_address, t_city, t_state, t_country, t_pin | string | Optional | Delivery address. |
t_floor, t_is_lift | string | Optional | Delivery floor, and lift availability (1 / 0). |
4. Code examples
curl -X POST https://packers.bharatbilty.com/api/integrations/booking \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Ravi Kumar",
"phone": "9876543210",
"email": "ravi@example.com",
"f_city": "Patna",
"f_state": "Bihar",
"f_address": "12 Boring Road",
"t_city": "Delhi",
"t_state": "Delhi",
"m_date": "2026-11-20"
}'<?php
$apiKey = getenv('BHARATBILTY_API_KEY'); // keep it out of your code
$payload = [
'name' => $_POST['name'],
'phone' => $_POST['phone'],
'email' => $_POST['email'],
'f_city' => $_POST['from_city'],
't_city' => $_POST['to_city'],
'm_date' => $_POST['move_date'],
];
$ch = curl_init('https://packers.bharatbilty.com/api/integrations/booking');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($body, true);
if ($code === 200 && !empty($result['status'])) {
// saved - $result['c_id'] is the new party id
} else {
error_log('BharatBilty booking failed: ' . $body);
}Add to your theme's functions.php (or a small plugin). Example: Contact Form 7 hook.
<?php
// wp-config.php: define('BHARATBILTY_API_KEY', 'YOUR_API_KEY');
add_action('wpcf7_mail_sent', function ($form) {
$data = WPCF7_Submission::get_instance()->get_posted_data();
$response = wp_remote_post('https://packers.bharatbilty.com/api/integrations/booking', [
'timeout' => 15,
'headers' => [
'X-API-Key' => BHARATBILTY_API_KEY,
'Content-Type' => 'application/json',
],
'body' => wp_json_encode([
'name' => sanitize_text_field($data['your-name'] ?? ''),
'phone' => sanitize_text_field($data['your-phone'] ?? ''),
'email' => sanitize_email($data['your-email'] ?? ''),
'f_city' => sanitize_text_field($data['from-city'] ?? ''),
't_city' => sanitize_text_field($data['to-city'] ?? ''),
'm_date' => sanitize_text_field($data['move-date'] ?? ''),
]),
]);
if (is_wp_error($response)) {
error_log('BharatBilty booking failed: ' . $response->get_error_message());
}
});// Node 18+ (server-side only)
const res = await fetch('https://packers.bharatbilty.com/api/integrations/booking', {
method: 'POST',
headers: {
'X-API-Key': process.env.BHARATBILTY_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Ravi Kumar',
phone: '9876543210',
f_city: 'Patna',
t_city: 'Delhi',
m_date: '2026-11-20',
}),
});
const data = await res.json();
if (!res.ok) throw new Error(data.message);
console.log('Party id:', data.c_id);5. Response
Success — 200 OK
{
"status": true,
"message": "Party added successfully.",
"c_id": 123
}
c_id is the id of the newly created party. Each booking creates a new party; the API does not de-duplicate by phone.
6. Errors
| HTTP | Message | Cause & fix |
|---|---|---|
400 | name is required. | Send a non-empty name. |
400 | Email is not valid. | Send a valid email or omit the field. |
401 | Missing API key. | Add the X-API-Key header. |
401 | Invalid API key. | The key is wrong, regenerated, or deleted. Copy the current one from the app. |
401 | This account has been disabled. | Contact BharatBilty support. |
429 | Too many requests | Rate limit reached — retry after the time shown in the Retry-After header. |
Error bodies look like { "message": "Invalid API key." }.
What happens after a booking is saved
- The enquiry appears in the Customers / Parties list of the business the key belongs to, tagged with the website it came from.
- You (and your staff) receive a notification in the app — “New booking from <your website>” — with name, phone, route and moving date.
- From there you can create a quotation, bilty or invoice for that party as usual.
Security & limits
- Always use HTTPS; keep the key in server config, never in front-end code or a public repository.
- Validate and sanitise visitor input on your server before forwarding it. Add a CAPTCHA to your form to stop spam bookings.
- Requests are rate limited per IP. A normal website form is far below the limit, but don't call the API in a loop.
- If a key leaks, regenerate it from the API Integration page — the old key stops working at once.
Troubleshooting
X-API-Key.