البدء السريع
من مفتاح تجريبي إلى حجز محجوز مؤقتًا واستقبال Webhook في خمس خطوات.
في هذه الصفحة
١. أنشئ مفتاحًا تجريبيًا
في اللوحة افتح «المطوّرون»، وانتقل إلى وضع «تجريبي»، وأنشئ مفتاحًا بصلاحية القراءة فقط. انسخ المفتاح حين يظهر فهو يُعرض مرة واحدة، واحفظه في متغير البيئة API_KEY.
٢. تحقّق من المفتاح
يجيب GET /me بحسابك ووضع المفتاح ونطاقاته. إن نجح هذا فسينجح كل ما بعده.
curl "https://api.opentourbase.com/api/supplier/v1/me" \
-H "Authorization: Bearer $API_KEY"{
"data": {
"key": {
"id": "ush_test_Ab12Cd34Ef56Gh78Ij90Kl12",
"label": "Website back-end",
"mode": "test",
"scopes": [
"products:read",
"events:read"
]
},
"supplier": {
"id": "0b0f6a0e-5a57-4a10-9f6c-2f7f7a5d3c11",
"name": "Aurora Tours",
"currency": "GEL",
"currencyPrecision": 2,
"timeZone": "Asia/Tbilisi"
}
}
}٣. اعرض منتجاتك
المفاتيح التجريبية تقرأ كتالوجك وتوافرك وأسعارك الحقيقية، فترى بالضبط ما ستبيعه.
curl "https://api.opentourbase.com/api/supplier/v1/products?limit=25" \
-H "Authorization: Bearer $API_KEY"٤. احجز مؤقتًا ثم أكّد حجزًا تجريبيًا
اختر موعد انطلاق، واحجز عليه أماكن، ثم أكّد. يحتاج المفتاح إلى النطاق bookings:write لذلك، فامنحه وصولًا كاملًا أو أضف النطاق. الحجوزات التجريبية لا تأخذ مالًا ولا تصل إلى أي ضيف.
curl "https://api.opentourbase.com/api/supplier/v1/options/{optionUuid}/availability?local_date=2026-12-05" \
-H "Authorization: Bearer $API_KEY"curl -X POST "https://api.opentourbase.com/api/supplier/v1/bookings" \
-H "Authorization: Bearer $API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"optionId":"{optionId}","availabilityId":"{availabilityId}","units":[{"unitId":"{unitId}","quantity":2}],"reference":"ORDER-1042"}'curl -X POST "https://api.opentourbase.com/api/supplier/v1/bookings/{uuid}/confirm" \
-H "Authorization: Bearer $API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"contact":{"fullName":"Ana Beridze","email":"ana@example.com"},"payment":{"mode":"offline"}}'٥. استقبل Webhook
أضف عنوانًا من «المطوّرون › Webhooks» واضغط «إرسال حدث تجريبي». يصل إلى خادمك طلب موقَّع خلال ثانية. تحقّق من التوقيع قبل أن تثق به.
import crypto from "node:crypto";
export function verify(rawBody, headers, secret, toleranceSec = 300) {
const id = headers["webhook-id"], ts = headers["webhook-timestamp"], sig = headers["webhook-signature"];
if (!id || !ts || !sig || Math.abs(Date.now() / 1000 - Number(ts)) > toleranceSec) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = crypto.createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest("base64");
return sig.split(" ").some((p) => {
const [v, s] = p.split(",");
return v === "v1" && s && s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected));
});
}