{{-- B2C Package Booking API — full reference. Rendered in the partner portal and the admin panel; base URLs and limits come from App\Support\B2cApiDocs so they match the running app. Code samples sit in verbatim blocks and read BASE_URL from the environment. --}} @php $sandbox = $docs['base']['sandbox']; $live = $docs['base']['live']; $holdMin = intdiv($docs['holdTtl'], 60); $extendMin = intdiv($docs['holdExtend'], 60); $tokenMin = intdiv($docs['tokenTtl'], 60); @endphp
Sell our tour packages directly from your own website or app. You show our live catalogue and prices, collect payment from your customer, and confirm the booking with us. You get back a confirmed voucher you can hand straight to your traveller. Our operations team handles fulfilment.
| Sandbox (demo) | Live | |
|---|---|---|
| Base URL | {{ $sandbox }} | {{ $live }} |
| Credentials | Prefixed gfc_test_ / gfs_test_ / gfk_test_ | Prefixed gfc_live_ / gfs_live_ / gfk_live_ |
| Availability | As soon as your partner account exists | After our team approves live access |
| Catalogue & prices | Real (same as live) | Real |
| Reservations | Simulated. Seats are not held. | Hold real seats |
| Confirm | Simulated. No customer, no booking with our ops team, wallet not charged. Voucher numbers start with TEST-. | Real booking. Your wallet is charged. |
| Error simulation | Yes, see Sandbox testing | No |
Credentials only work on their own environment's base URL. A sandbox key sent to the live URL (or the other way round)
is rejected with 401 UNAUTHENTICATED, so a test key can never create a real booking.
Sandbox and live also keep separate idempotency keys, webhooks and IP allow-lists.
export BASE_URL="{{ $sandbox }}"
@verbatim
# 1) access token (valid for the number of seconds in expires_in)
curl -s -X POST "$BASE_URL/oauth/token" \
-H "Content-Type: application/json" \
-d '{"grant_type":"client_credentials","client_id":"gfc_test_xxx","client_secret":"gfs_test_xxx"}'
# 2) search packages
curl -s "$BASE_URL/packages/search?destination=sylhet&pageSize=5" \
-H "Authorization: Bearer " \
-H "Accept: application/json"
@endverbatim
BASE_URL to {{ $live }}.Use either method on every call except the token endpoint.
POST/oauth/token
Send JSON or application/x-www-form-urlencoded:
| Field | Required | Description |
|---|---|---|
grant_type | yes | Always client_credentials |
client_id | yes | Your client ID for this environment |
client_secret | yes | Your client secret |
scope | no | Space-separated subset of packages.read reservations.write. Default: both. |
{
"success": true,
"data": {
"access_token": "Zq9...64 chars...",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "packages.read reservations.write"
}
}
@endverbatim
Send it as Authorization: Bearer <access_token>. Tokens last {{ $tokenMin }} minutes. Cache the token and fetch a new one
shortly before it expires, or when you get 401. Regenerating your credentials in the portal revokes every token you hold.
Send X-API-Key: gfk_test_… (or gfk_live_…) on each request. This is simpler, but the key never expires, so guard it like a password.
If you add IPs or CIDR ranges for an environment in the portal, calls from any other address get 403 FORBIDDEN.
"23000.00". Currency is {{ $docs['currency'] }}. Never parse money as a float.YYYY-MM-DD. Timestamps are ISO-8601 UTC, for example 2026-10-01T08:30:00Z.packageId is "42", slots are SLOT_<n>, reservations are RSV_…, bookings are BKG_…. Store them as strings.// success
{ "success": true, "data": { ... } }
// failure
{ "success": false, "error": { "code": "SOLD_OUT", "message": "Requested seats no longer available.", "details": { "seatsLeft": 1, "requested": 2 } } }
@endverbatim
Always branch on error.code, not on the message text. The codes are listed under Errors.
Every POST except /oauth/token requires an Idempotency-Key header. Use a UUID, and keep the same key
for every retry of the same operation:
409 IN_PROGRESS. Wait and retry.400 VALIDATION_ERROR.So if a confirm call times out, retry it with the same key. Never send a new key for the same payment.
/oauth/token: 10 requests per minute per client ID and IP. Cache your token.429 RATE_LIMITED with a Retry-After header.Your website Let's Go Tours and Travels API
──────────── ──────────────────
search / browse ── GET /packages/search ──▶ cards with fromPrice
package page ── GET /packages/{id} ────▶ itinerary, tiers, availableDates[slotId]
price for pax mix ── GET /packages/{id}/availability?slotId=… ─▶ binding quote
checkout clicked ── POST /reservations ────▶ HELD, priceBreakdown, priceLockToken,
holdExpiresAt (+{{ $holdMin }} min)
take customer payment (your gateway)
payment succeeded ── POST /reservations/{id}/confirm ─▶ CONFIRMED booking + voucherNo + voucherUrl
payment failed ── POST /reservations/{id}/cancel ──▶ hold released
later ── GET /bookings/{id} · POST /bookings/{id}/cancel
Always reserve before you take payment. The reserve response is the binding price: charge your customer
priceBreakdown.grandTotal, then confirm while the hold is still live (before holdExpiresAt).
packages.read)Query: country (ISO-2, e.g. BD), activeOnly (default true).
{ "success": true, "data": {
"destinations": [
{ "destinationId": "DST_3", "slug": "sylhet", "name": "Sylhet", "country": "BD", "region": "domestic",
"packageCount": 4, "isActive": true, "isPopular": true, "requiresPassport": false,
"thumbnail": { "type": "image", "url": "https://…", "alt": "Sylhet" } }
],
"updatedAt": "2026-09-28T10:00:00Z" } }
@endverbatim
Returns the categories, types and durationBuckets you can filter search by. Each has a slug and a label. Cache it for a day.
| Param | Description |
|---|---|
q | Free text over title and destination |
destination | Destination slug from /destinations |
category, type | Slugs from /taxonomies |
durationMin, durationMax | Days |
priceMin, priceMax | Base price per person |
travelers | Only packages whose group can take this many |
travelDateFrom, travelDateTo | Only packages with a departure in this window (YYYY-MM-DD) |
sort | price_asc · price_desc · popularity · date_asc (default: featured first, then title) |
page, pageSize | Default 1 / 20; pageSize max 100 |
{ "success": true, "data": {
"page": 1, "pageSize": 20, "totalItems": 1, "totalPages": 1,
"packages": [ {
"packageId": "42", "title": "Sylhet Tea Trails 3D2N", "slug": "sylhet-tea-trails-3d2n",
"destination": "sylhet", "categories": ["relax"], "durationDays": 3, "durationNights": 2,
"fromPrice": { "amount": "8500.00", "currency": "BDT", "basis": "per_person" },
"summary": "…", "thumbnail": { "url": "https://…" },
"nextAvailableDate": "2026-10-30", "isSellable": true } ] } }
@endverbatim
If your account is limited to selected packages, search only returns those, and any other packageId gives 404.
Returns the full package for your product page. That includes description, itinerary[], inclusions[], exclusions[],
pricing (tiers ADULT/CHILD/INFANT, occupancyOptions TWIN/SINGLE, serviceChargePercent),
groupSize, cancellationPolicy, media.gallery[], terms, requiresPassport and
availableDates[]. Each available date has a slotId, travelDate, seatsLeft and a
status of AVAILABLE, LIMITED or SOLD_OUT.
Query: slotId (required), adult, child, infant, occupancy (TWIN|SINGLE). Returns live seats and the exact price for that traveller mix.
{ "success": true, "data": {
"slotId": "SLOT_12", "travelDate": "2026-10-30", "seatsLeft": 8, "status": "AVAILABLE",
"priceBreakdown": {
"currency": "BDT",
"lineItems": [
{ "code": "ADULT", "label": "Adult x2", "unitPrice": "8500.00", "qty": 2, "amount": "17000.00" },
{ "code": "CHILD", "label": "Child x1", "unitPrice": "6000.00", "qty": 1, "amount": "6000.00" },
{ "code": "SINGLE_SUPPLEMENT", "label": "Occupancy", "unitPrice": "3000.00", "qty": 0, "amount": "0.00" } ],
"subTotal": "23000.00", "discount": "0.00", "serviceCharge": "0.00", "tax": "0.00",
"grandTotal": "23000.00",
"amountPayableToProvider": "20700.00" } } }
@endverbatim
grandTotal is the price you sell at. amountPayableToProvider is what your wallet is charged when you confirm
(grandTotal minus your commission). The difference is your earning. Infants are free unless the package has an infant price,
and infants do not take a seat.
reservations.write; every POST needs Idempotency-Key)Holds seats and locks the price for {{ $holdMin }} minutes. Returns 201.
| Field | Required | Description |
|---|---|---|
packageId | yes | From search or detail |
slotId | yes | From availableDates[] |
pax | yes | {"ADULT":2,"CHILD":1,"INFANT":0}. At least one traveller. |
occupancy | no | TWIN (default) or SINGLE. SINGLE adds the single supplement for each adult. |
travelDate | no | If you send it, it must match the slot's date |
leadCustomer | no | {"name","phone","email"} |
partnerOrderRef | recommended | Your order ID |
notes | no | Special requests, passed to our operations team |
POST /reservations
Idempotency-Key: 5b0d7c7e-7a4c-4c9f-9a5b-2f7f3c1d8e11
{ "packageId": "42", "slotId": "SLOT_12", "occupancy": "TWIN",
"pax": { "ADULT": 2, "CHILD": 1, "INFANT": 0 },
"leadCustomer": { "name": "Rahim Uddin", "phone": "+8801711000000", "email": "rahim@example.com" },
"partnerOrderRef": "WEB-100245" }
201 Created
{ "success": true, "data": {
"reservationId": "RSV_k2j…", "status": "HELD", "packageId": "42", "slotId": "SLOT_12",
"travelDate": "2026-10-30", "occupancy": "TWIN", "pax": { "ADULT": 2, "CHILD": 1, "INFANT": 0 },
"priceBreakdown": { "grandTotal": "23000.00", "amountPayableToProvider": "20700.00", … },
"priceLockToken": "PLT_9x…",
"holdCreatedAt": "2026-09-30T10:00:00Z", "holdExpiresAt": "2026-09-30T10:25:00Z", "holdTtlSeconds": 1500,
"cancellationPolicy": { "summary": "…", "tiers": [ … ] },
"partnerOrderRef": "WEB-100245", "environment": "sandbox" } }
@endverbatim
Possible errors: SOLD_OUT, NO_AVAILABILITY, NOT_FOUND, VALIDATION_ERROR.
Call this after your customer has paid. It turns the hold into a confirmed booking and, on live, charges amountPayableToProvider to your wallet.
| Field | Required | Description |
|---|---|---|
priceLockToken | recommended | From the reserve response. It must match. |
expectedAmount | recommended | The grandTotal you charged. If it differs, you get 409 PRICE_CHANGED and nothing is booked. |
travelers[] | recommended | One per traveller: tier (ADULT/CHILD/INFANT), fullName, isLead, phone, email, nationality, dateOfBirth, passport {"number","expiry"}. Send passport details for every traveller on packages with requiresPassport: true; our team needs them to process the trip. |
partnerOrderRef | no | Overrides the one you sent on reserve |
partnerPaymentRef | no | Your payment or transaction ID, for reconciliation |
paidAt | no | ISO-8601 time your customer paid |
{ "success": true, "data": {
"bookingId": "BKG_p0…", "reservationId": "RSV_k2j…", "status": "CONFIRMED",
"voucherNo": "GF-2026-004211",
"voucherUrl": "https://…/b2c/voucher/BKG_p0…?signature=…",
"packageId": "42", "travelDate": "2026-10-30", "pax": { "ADULT": 2, "CHILD": 1, "INFANT": 0 },
"amountConfirmed": "23000.00", "amountPayableToProvider": "20700.00", "currency": "BDT",
"confirmedAt": "2026-09-30T10:07:12Z",
"providerContact": { "phone": "…", "email": "…" },
"partnerOrderRef": "WEB-100245", "environment": "live", "channel": "api" } }
@endverbatim
voucherUrl is a signed, permanent link to a printable voucher. You can email it to your traveller or embed it on your
order page. Confirming a reservation that is already confirmed returns the same booking, so it is safe to retry.
Possible errors: RESERVATION_EXPIRED (reserve again), PRICE_CHANGED, INSUFFICIENT_BALANCE (402, top up your wallet),
ALREADY_CONFIRMED, IN_PROGRESS.
RESERVATION_EXPIRED or PRICE_CHANGED, reserve again and confirm if the price is the same. Otherwise, refund your customer.
Releases a hold, free of charge. Use it when payment fails or the customer abandons checkout. Body: {"reason":"payment_failed"} (optional).
Returns {"reservationId","status":"RELEASED","releasedAt"}. Releasing a hold that is already released or expired succeeds. Releasing a confirmed reservation gives 409 ALREADY_CONFIRMED; cancel the booking instead.
Adds {{ $extendMin }} minutes to a live hold, once. A second call gives 409 ALREADY_EXTENDED. Returns the updated reservation.
Current state of a hold: HELD, CONFIRMED, RELEASED or EXPIRED. Same shape as the reserve response.
Current state of a booking: CONFIRMED, CANCELLED, COMPLETED or NO_SHOW. Same shape as the confirm response, plus refund and cancelledAt once cancelled.
Look up bookings by your own order reference, or with ?voucherNo=GF-2026-004211. Use it to reconcile when a confirm response was lost. Returns {"bookings":[…]}.
Cancels a confirmed booking under the cancellation policy that was captured when it was booked. Body (optional): {"reason":"customer_request"}.
{ "success": true, "data": {
"bookingId": "BKG_p0…", "status": "CANCELLED", "cancelledAt": "2026-10-05T09:00:00Z",
"refund": { "currency": "BDT", "grossPaid": "23000.00", "penaltyPercent": "0.00", "penaltyAmount": "0.00",
"refundableAmount": "23000.00", "policyTierApplied": "7+ days before travel" } } }
@endverbatim
refundableAmount is what you should refund your customer. On live, your wallet is credited with the same share of what it was charged:
for example, a 50% penalty means half of amountPayableToProvider comes back. You cannot cancel after the travel date (422 POLICY_VIOLATION).
Cancelling twice returns the original refund.
Default policy when a package has none of its own: {{ $docs['defaultPolicy']['summary'] }} (@foreach($docs['defaultPolicy']['tiers'] as $tier){{ $tier['daysBeforeTravelMin'] }}+ days: {{ $tier['penaltyPercent'] }}%{{ $loop->last ? '' : ' · ' }}@endforeach).
| HTTP | error.code | Meaning / what to do |
|---|---|---|
| 400 | VALIDATION_ERROR | Bad or missing field, missing Idempotency-Key, or a reused key with a different body. See details.fields. Fix the request; do not retry it unchanged. |
| 401 | UNAUTHENTICATED | Missing, invalid or expired token or key, or a credential used on the wrong environment. Get a new token. |
| 402 | INSUFFICIENT_BALANCE | Your wallet plus credit limit does not cover amountPayableToProvider. details.required and details.available tell you how much. Top up, then retry. |
| 403 | FORBIDDEN | Access disabled, IP not on your allow-list, or a missing scope. |
| 404 | NOT_FOUND | Unknown package, slot, reservation or booking, or a package you are not allowed to sell. |
| 409 | SOLD_OUT | Not enough seats. details.seatsLeft tells you how many remain. Offer another date. |
| 409 | NO_AVAILABILITY | The package or slot is not open for sale. |
| 409 | RESERVATION_EXPIRED | The hold expired or was released. Reserve again. |
| 409 | PRICE_CHANGED | expectedAmount did not match. details.newPriceBreakdown has the current price. |
| 409 | ALREADY_CONFIRMED | The reservation is not in a state that can be confirmed or released. |
| 409 | ALREADY_EXTENDED | The hold was already extended once. |
| 409 | IN_PROGRESS | The same Idempotency-Key is still processing. Retry after a short wait. |
| 422 | POLICY_VIOLATION | The cancellation is not allowed, for example after the travel date. |
| 429 | RATE_LIMITED | Too many requests. Wait for Retry-After seconds. |
| 500 | INTERNAL_ERROR | Our side. Safe to retry with the same Idempotency-Key. |
Set a webhook URL for each environment in the portal (live URLs must use https://). We POST JSON to it when something changes on our side:
| eventType | When | Key fields |
|---|---|---|
BOOKING_STATUS_CHANGED | A booking is cancelled, whether by you or by our team. | bookingId, partnerOrderRef, newStatus, reason, data.refund |
RESERVATION_EXPIRED | An unconfirmed hold passes its expiry. We send this when the hold is next accessed, so also track holdExpiresAt yourself. | reservationId, partnerOrderRef, newStatus |
POST https://yoursite.com/webhooks/lets-go
Content-Type: application/json
X-GF-Signature: hmac-sha256=3f5a…
{ "eventId": "EVT_9b1c…", "eventType": "BOOKING_STATUS_CHANGED", "occurredAt": "2026-10-05T09:00:00Z",
"environment": "live", "bookingId": "BKG_p0…", "partnerOrderRef": "WEB-100245",
"newStatus": "CANCELLED", "reason": "customer_request",
"data": { "refund": { "refundableAmount": "23000.00", … } } }
@endverbatim
Verify the signature before you trust the payload. Compute the HMAC-SHA256 of the raw request body with your webhook signing secret, then compare it with a constant-time comparison:
@verbatim// PHP
$raw = file_get_contents('php://input');
$expected = 'hmac-sha256=' . hash_hmac('sha256', $raw, getenv('GF_WEBHOOK_SECRET'));
if (! hash_equals($expected, $_SERVER['HTTP_X_GF_SIGNATURE'] ?? '')) { http_response_code(401); exit; }
// Node.js (Express: app.post(path, express.raw({ type: 'application/json' }), handler))
const crypto = require('crypto');
const expected = 'hmac-sha256=' + crypto.createHmac('sha256', process.env.GF_WEBHOOK_SECRET).update(req.body).digest('hex');
const given = req.get('X-GF-Signature') || '';
const ok = given.length === expected.length && crypto.timingSafeEqual(Buffer.from(given), Buffer.from(expected));
@endverbatim
Reply 2xx within 5 seconds and do your processing afterwards. We may deliver the same event more than once, so
de-duplicate on eventId. Delivery is best-effort: treat webhooks as a prompt and use GET /bookings/{id} as the source of truth.
The sandbox uses the real catalogue, prices and cancellation policies. Nothing you do there affects real inventory, customers or your wallet.
To test your error handling, add the X-Sandbox-Simulate header to a sandbox request. The live API ignores it.
| X-Sandbox-Simulate | Effect |
|---|---|
{{ $code }} | {{ $effect }} |
Idempotency still applies. Use a new Idempotency-Key for each simulated call, or the first response is replayed.
Suggested test plan: happy path; idempotent retry of reserve and confirm; SOLD_OUT; PRICE_CHANGED; RESERVATION_EXPIRED; INSUFFICIENT_BALANCE;
releasing a hold after a failed payment; cancel booking and refund; token expiry and refresh; webhook signature verification.
grandTotal and keep your commission. Each live confirm charges amountPayableToProvider to your prepaid wallet.402 INSUFFICIENT_BALANCE and nothing is booked.use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
function gf(): \Illuminate\Http\Client\PendingRequest
{
$token = Cache::remember('gf_token', 3300, fn () => Http::asJson()
->post(env('GF_BASE_URL') . '/oauth/token', [
'grant_type' => 'client_credentials',
'client_id' => env('GF_CLIENT_ID'),
'client_secret' => env('GF_CLIENT_SECRET'),
])->throw()->json('data.access_token'));
return Http::baseUrl(env('GF_BASE_URL'))->withToken($token)->acceptJson()->timeout(20);
}
// Reserve
$hold = gf()->withHeaders(['Idempotency-Key' => (string) Str::uuid()])
->post('/reservations', [
'packageId' => '42', 'slotId' => 'SLOT_12',
'pax' => ['ADULT' => 2, 'CHILD' => 0, 'INFANT' => 0],
'partnerOrderRef' => $order->id,
])->json('data');
// … charge $hold['priceBreakdown']['grandTotal'] with your payment gateway …
// Confirm (store the key on the order so a retry reuses it)
$booking = gf()->withHeaders(['Idempotency-Key' => $order->confirm_key])
->post("/reservations/{$hold['reservationId']}/confirm", [
'priceLockToken' => $hold['priceLockToken'],
'expectedAmount' => $hold['priceBreakdown']['grandTotal'],
'partnerPaymentRef' => $payment->id,
'travelers' => [['tier' => 'ADULT', 'fullName' => 'Rahim Uddin', 'isLead' => true, 'phone' => '+8801711000000']],
])->json();
if (! $booking['success']) {
// branch on $booking['error']['code']
}
@endverbatim
const BASE = process.env.GF_BASE_URL;
let token, tokenExp = 0;
async function gf(path, { method = 'GET', body, idem } = {}) {
if (Date.now() > tokenExp) {
const r = await fetch(`${BASE}/oauth/token`, { method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ grant_type: 'client_credentials', client_id: process.env.GF_CLIENT_ID, client_secret: process.env.GF_CLIENT_SECRET }) });
const j = await r.json();
token = j.data.access_token; tokenExp = Date.now() + (j.data.expires_in - 120) * 1000;
}
const headers = { Authorization: `Bearer ${token}`, Accept: 'application/json', 'Content-Type': 'application/json' };
if (idem) headers['Idempotency-Key'] = idem;
const res = await fetch(BASE + path, { method, headers, body: body && JSON.stringify(body) });
return res.json(); // { success, data } | { success:false, error:{ code, message, details } }
}
const hold = await gf('/reservations', { method: 'POST', idem: crypto.randomUUID(),
body: { packageId: '42', slotId: 'SLOT_12', pax: { ADULT: 2 }, partnerOrderRef: 'WEB-100245' } });
@endverbatim
curl -s -X POST "$BASE_URL/reservations/RSV_k2j.../confirm" \
-H "X-API-Key: $GF_API_KEY" \
-H "Idempotency-Key: 0f6c1c4e-2d0b-4d6a-9d3e-8c1b1e2f3a4b" \
-H "Content-Type: application/json" \
-d '{"priceLockToken":"PLT_...","expectedAmount":"23000.00","partnerOrderRef":"WEB-100245",
"travelers":[{"tier":"ADULT","fullName":"Rahim Uddin","isLead":true,"phone":"+8801711000000"}]}'
@endverbatim
Idempotency-Key for its confirm, reused on every retry.X-GF-Signature and de-duplicates on eventId.cancellationPolicy.BASE_URL.Your API logs (kept for {{ $docs['logRetention'] }} days) are under API & Developers → API Logs. Include the X-Request-Id when you contact support.