OpsTour Partner API

REST + JSON for B2B agents and integrators. Each tour company on OpsTour issues its own API keys, so you always call the company’s address.

Tài liệu API cho đại lý và đối tác. Mỗi công ty tour tự cấp khóa API trong app (Cài đặt › Tích hợp), dữ liệu chỉ thuộc công ty đó.

ItemValue
Base URLhttps://api.opstour.com/api/partner/v1 with ?t=<company-code>, or https://<company-code>.opstour.com/api/partner/v1
FormatJSON, UTF-8. Dates YYYY-MM-DD, amounts in the company’s currency (integer VND unless stated).
Rate limitRequests above the limit get 429; retry after a short pause.
Status pagestatus.opstour.com

Authentication

Send the key in the X-Api-Key header. Keys have scopes: read (view departures) and book (create bookings). Never put a key in a browser or mobile app – call the API from your server.

curl -H "X-Api-Key: ak_live_xxx" "https://api.opstour.com/api/partner/v1/departures?t=saigontravel"

Write requests accept an Idempotency-Key header (8–100 characters). Retrying with the same key returns the first result instead of creating a duplicate – use it for every booking.

List departures

GET/api/partner/v1/departures  scope read

Published departures with dates, price, seats left and route.

[{ "id": "8f0c…", "tour_code": "DN4", "title": "Da Nang – Hue – Hoi An 4D3N",
   "start_date": "2027-03-05", "end_date": "2027-03-08", "price": 5000000,
   "seats_left": 12, "route_text": "Da Nang – Hue – My Son – Hoi An" }]

Create a booking

POST/api/partner/v1/bookings  scope book

FieldRequiredNotes
departure_idyesFrom the departures list
paxyes1–50
name, phoneyesLead passenger; Vietnamese phone numbers are normalised
email, note, promo_codeno
curl -X POST -H "X-Api-Key: ak_live_xxx" -H "Idempotency-Key: agent-42-booking-0001" \
  -H "content-type: application/json" \
  -d '{"departure_id":"8f0c…","pax":2,"name":"Nguyen Van A","phone":"0909000111"}' \
  "https://api.opstour.com/api/partner/v1/bookings?t=saigontravel"

Seats are held with a time limit; the agent discount and commission set on the key are applied automatically. Errors: 409 not_enough_seats, 422 invalid_input, 401/403 for a missing or wrong-scope key.

Webhooks

The company registers your URL and chooses events: order.created, order.status_changed, payment.received, booking.confirmed, booking.rejected, departure.updated, review.created, lead.created.

POST https://your-server/hook
X-OpsTour-Timestamp: 1767225600
X-OpsTour-Signature: sha256=<hex HMAC-SHA256(secret, timestamp + "." + body)>

{ "event": "payment.received", "data": { … }, "at": "2027-01-01T00:00:00Z" }

Verify the signature with the shared secret, reject timestamps older than 5 minutes, and answer 2xx quickly. The older X-TourApp-* headers carry the same values.

// Node.js
const crypto = require('crypto');
const ok = (secret, ts, raw, sig) => {
  const mine = 'sha256=' + crypto.createHmac('sha256', secret).update(ts + '.' + raw).digest('hex');
  return Math.abs(Date.now() / 1000 - Number(ts)) < 300 &&
    crypto.timingSafeEqual(Buffer.from(mine), Buffer.from(String(sig)));
};

Support

Questions about a company’s data or keys go to that company. Platform questions: the contact details on opstour.com.