{
  "openapi": "3.1.0",
  "info": {
    "title": "Travelioo Partner API",
    "version": "1.0.0",
    "summary": "Flight search, order creation and signed order events for agencies, banks and fintechs.",
    "description": "Reference specification of the Travelioo partner API. Request and response values are illustrative and non-contractual; credentials, quotas and the production base URL are provided at the end of partner onboarding (KYB).",
    "contact": { "name": "Travelioo Tech", "email": "hello@travelioo.tech", "url": "https://travelioo.tech" },
    "license": { "name": "Proprietary", "identifier": "LicenseRef-Travelioo-Partner" }
  },
  "servers": [{ "url": "https://api.travelioo.tech", "description": "Production (partner credentials required)" }],
  "security": [{ "bearerAuth": [] }],
  "tags": [
    { "name": "Flights", "description": "Search offers." },
    { "name": "Orders", "description": "Create and follow orders." }
  ],
  "paths": {
    "/v1/flights/search": {
      "post": {
        "tags": ["Flights"],
        "operationId": "searchFlights",
        "summary": "Search flight offers",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SearchRequest" }, "example": { "origin": "COO", "destination": "CDG", "departure_date": "2027-02-10", "passengers": 1, "currency": "XOF", "channel": "api" } } }
        },
        "responses": {
          "200": {
            "description": "Offers matching the search.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SearchResponse" }, "example": { "status": "ok", "offers_count": 18, "currency": "XOF", "offers": [{ "id": "off_01HXAMPLE", "total_amount": 412500, "currency": "XOF", "expires_at": "2027-01-05T10:15:00Z" }], "payment_methods": ["mobile_money", "card"] } } }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/v1/orders": {
      "post": {
        "tags": ["Orders"],
        "operationId": "createOrder",
        "summary": "Create an order from an offer",
        "description": "Idempotent: replaying the same `Idempotency-Key` returns the original order instead of creating a second one.",
        "parameters": [
          { "name": "Idempotency-Key", "in": "header", "required": true, "schema": { "type": "string", "minLength": 16, "maxLength": 128 } }
        ],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderRequest" }, "example": { "offer_id": "off_01HXAMPLE", "passengers": [{ "first_name": "Awa", "last_name": "Diallo", "date_of_birth": "1992-04-12" }], "contact": { "email": "traveler@example.com", "phone": "+22900000000" }, "payment_method": "mobile_money" } } }
        },
        "responses": {
          "201": {
            "description": "Order created.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Order" }, "example": { "id": "ord_01HXAMPLE", "status": "pending_payment", "total_amount": 412500, "currency": "XOF", "created_at": "2027-01-05T10:02:11Z" } } }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "409": { "description": "The offer is no longer available or its price changed.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/v1/orders/{id}": {
      "get": {
        "tags": ["Orders"],
        "operationId": "getOrder",
        "summary": "Retrieve an order",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" }, "example": "ord_01HXAMPLE" }],
        "responses": {
          "200": {
            "description": "The order and its current status.",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Order" }, "example": { "id": "ord_01HXAMPLE", "status": "ticketed", "booking_reference": "ABC123", "total_amount": 412500, "currency": "XOF", "created_at": "2027-01-05T10:02:11Z" } } }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "description": "Unknown order.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "webhooks": {
    "order.ticketed": {
      "post": {
        "tags": ["Orders"],
        "operationId": "onOrderTicketed",
        "summary": "Order ticketed (signed webhook)",
        "description": "Sent to your HTTPS endpoint once the tickets are issued. Verify the signature before trusting the payload: HMAC-SHA256 of `{timestamp}.{raw_body}` with your webhook secret, compared in constant time with the `v1` value of the `Travelioo-Signature` header. Reject timestamps older than 5 minutes. Respond with any 2xx status; failed deliveries are retried.",
        "parameters": [
          { "name": "Travelioo-Signature", "in": "header", "required": true, "description": "`t=<unix timestamp>,v1=<hex hmac-sha256>`", "schema": { "type": "string" }, "example": "t=1767607331,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd" }
        ],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/OrderTicketedEvent" }, "example": { "id": "evt_01HXAMPLE", "type": "order.ticketed", "created_at": "2027-01-05T10:04:51Z", "data": { "order_id": "ord_01HXAMPLE", "status": "ticketed", "booking_reference": "ABC123", "tickets_url": "https://api.travelioo.tech/v1/orders/ord_01HXAMPLE/tickets" } } } }
        },
        "responses": { "200": { "description": "Event acknowledged." } },
        "security": []
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer", "description": "Partner API key issued after onboarding." }
    },
    "responses": {
      "BadRequest": { "description": "Invalid request.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "Unauthorized": { "description": "Missing or invalid credentials.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
      "RateLimited": { "description": "Too many requests.", "headers": { "Retry-After": { "schema": { "type": "integer" } } }, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": ["error"],
        "properties": { "error": { "type": "object", "required": ["code", "message"], "properties": { "code": { "type": "string" }, "message": { "type": "string" } } } }
      },
      "SearchRequest": {
        "type": "object",
        "required": ["origin", "destination", "passengers"],
        "properties": {
          "origin": { "type": "string", "pattern": "^[A-Z]{3}$", "description": "IATA code." },
          "destination": { "type": "string", "pattern": "^[A-Z]{3}$", "description": "IATA code." },
          "departure_date": { "type": "string", "format": "date" },
          "return_date": { "type": "string", "format": "date" },
          "passengers": { "type": "integer", "minimum": 1, "maximum": 9 },
          "currency": { "type": "string", "enum": ["XOF", "EUR", "USD"], "default": "XOF" },
          "channel": { "type": "string", "enum": ["api", "portal"], "default": "api" }
        }
      },
      "Offer": {
        "type": "object",
        "required": ["id", "total_amount", "currency"],
        "properties": {
          "id": { "type": "string" },
          "total_amount": { "type": "integer", "description": "Total price in the minor-unit-free currency amount (XOF has no decimals)." },
          "currency": { "type": "string" },
          "expires_at": { "type": "string", "format": "date-time" }
        }
      },
      "SearchResponse": {
        "type": "object",
        "required": ["status", "offers_count", "currency"],
        "properties": {
          "status": { "type": "string", "enum": ["ok"] },
          "offers_count": { "type": "integer", "minimum": 0 },
          "currency": { "type": "string" },
          "offers": { "type": "array", "items": { "$ref": "#/components/schemas/Offer" } },
          "payment_methods": { "type": "array", "items": { "type": "string", "enum": ["mobile_money", "card"] } }
        }
      },
      "Passenger": {
        "type": "object",
        "required": ["first_name", "last_name", "date_of_birth"],
        "properties": {
          "first_name": { "type": "string" },
          "last_name": { "type": "string" },
          "date_of_birth": { "type": "string", "format": "date" }
        }
      },
      "OrderRequest": {
        "type": "object",
        "required": ["offer_id", "passengers", "contact"],
        "properties": {
          "offer_id": { "type": "string" },
          "passengers": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/Passenger" } },
          "contact": { "type": "object", "required": ["email"], "properties": { "email": { "type": "string", "format": "email" }, "phone": { "type": "string" } } },
          "payment_method": { "type": "string", "enum": ["mobile_money", "card"] }
        }
      },
      "Order": {
        "type": "object",
        "required": ["id", "status"],
        "properties": {
          "id": { "type": "string" },
          "status": { "type": "string", "enum": ["pending_payment", "paid", "ticketed", "cancelled", "failed"] },
          "booking_reference": { "type": "string" },
          "total_amount": { "type": "integer" },
          "currency": { "type": "string" },
          "created_at": { "type": "string", "format": "date-time" }
        }
      },
      "OrderTicketedEvent": {
        "type": "object",
        "required": ["id", "type", "created_at", "data"],
        "properties": {
          "id": { "type": "string" },
          "type": { "type": "string", "const": "order.ticketed" },
          "created_at": { "type": "string", "format": "date-time" },
          "data": {
            "type": "object",
            "required": ["order_id", "status"],
            "properties": {
              "order_id": { "type": "string" },
              "status": { "type": "string", "const": "ticketed" },
              "booking_reference": { "type": "string" },
              "tickets_url": { "type": "string", "format": "uri" }
            }
          }
        }
      }
    }
  }
}
