Booking API

DEVELOPER DOCS

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.

Call this API from your server-side code only. Never put your API key in HTML or browser JavaScript — anyone who sees it can add parties to your account.

1. Get your API key

  1. Log in to the BharatBilty app and open API Integration.
  2. Under API Keys, create a key for your business. You get one key per website, and each key is tied to one business.
  3. 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

POST https://packers.bharatbilty.com/api/integrations/booking
HeaderValue
X-API-KeyYour API key (required)
Content-Typeapplication/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.

FieldTypeRequiredDescription
namestringRequiredCustomer / party name.
phonestringOptionalCustomer phone number.
emailstringOptionalValid email address (stored in lower case).
genderstringOptionalCustomer gender.
m_datestringOptionalPreferred moving / shifting date, YYYY-MM-DD.
f_gststringOptionalGSTIN of the pickup party.
f_address, f_city, f_state, f_country, f_pinstringOptionalPickup address. f_pin is the PIN code.
f_floor, f_is_liftstringOptionalPickup floor, and whether a lift is available (1 = yes, 0 = no).
t_name, t_phone, t_gststringOptionalDestination / consignee name, phone and GSTIN.
t_address, t_city, t_state, t_country, t_pinstringOptionalDelivery address.
t_floor, t_is_liftstringOptionalDelivery 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

HTTPMessageCause & fix
400name is required.Send a non-empty name.
400Email is not valid.Send a valid email or omit the field.
401Missing API key.Add the X-API-Key header.
401Invalid API key.The key is wrong, regenerated, or deleted. Copy the current one from the app.
401This account has been disabled.Contact BharatBilty support.
429Too many requestsRate 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

Check for a trailing space or line break when you pasted the key, and that you didn't regenerate it in the app since. Header name must be exactly X-API-Key.

Notifications are sent after the reply, so a successful response means the party is saved. Make sure the app is logged in on your phone with notifications allowed.

Each key belongs to one business. Create a separate key for each website/business and use the matching key on each site.

You are calling the API from browser JavaScript. Call it from your server (PHP / Node / WordPress hook) instead — that also keeps your key private.
Need help integrating?
Write to us at info@bharatbilty.com and we'll help you get connected.
WhatsApp support