Skip to main content

← Developer Docs

Integration Recipes

Four end-to-end flows showing how an agent or backend should orchestrate the Onwardic MCP tools. Every JSON-RPC body shown below is exactly what your MCP client should POST to the Streamable HTTP endpoint (/api/mcp, or over a legacy SSE message channel).

Contents

  1. Quote a flight from an agent conversation
  2. Place a paid order via Stripe Checkout
  3. Look up an order's status
  4. Ground an LLM with the help center

1. Quote a flight from an agent conversation

User says: “Get me a return onward ticket from Dubai to Bangkok for two travelers, fastest delivery.” The agent needs the price before asking for payment.

Pseudocode:

// 1. Discover services + base prices
const services = await mcp.callTool('list_services', {});
//    → { services: [{ key: 'flight-itinerary', basePrice: 7, ... }, ...] }

// 2. Compute the live quote (server re-derives price; agent prices ignored)
const quote = await mcp.callTool('quote_order', {
  serviceKey: 'flight-itinerary',
  flightRoute: 'return',
  urgency: 'instant',
  travelers: 2,
  currency: 'USD',
});
//    → { total: 32, currency: 'USD', deliveryEstimate: 'up to 2-20 minutes after payment' }

// 3. Tell the user the price; await consent before place_order
agent.say(`Total is $${quote.total} ${quote.currency}, delivered ${quote.deliveryEstimate}.`);

Step-2 JSON-RPC body:

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "quote_order",
    "arguments": {
      "serviceKey": "flight-itinerary",
      "flightRoute": "return",
      "urgency": "instant",
      "travelers": 2,
      "currency": "USD"
    }
  }
}

Why this works for agents: the price is computed server-side, so the agent can quote with confidence — no hallucinated totals reach the user.

2. Place a paid order via Stripe Checkout

After the user agrees to the quote, the agent calls place_order (dual-mode: public AI / ChatGPT users can create an unpaid checkout link under guest limits, or partners can include X-API-Key / Authorization: Bearer issued via /b2b/apply for higher quota). The response includes a Stripe Checkout URL — show it to the user; they click, pay, and the booking PDF is emailed when the Stripe webhook fulfils the order.

Request (optional X-API-Key: owk_... header for partners):

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "place_order",
    "arguments": {
      "serviceKey": "flight-itinerary",
      "email": "traveler@example.com",
      "flightRoute": "return",
      "travelers": 2,
      "fromIata": "DXB",
      "toIata": "BKK",
      "departureDate": "2027-01-15",
      "returnDate": "2027-01-29",
      "urgency": "instant",
      "name": "Jane Traveler",
      "currency": "USD"
    }
  }
}

Response:

{
  "jsonrpc": "2.0",
  "id": 3,
  "result": {
    "structuredContent": {
      "pendingOrderId": "cart_id_string",
      "checkoutUrl": "https://checkout.stripe.com/c/pay/cs_live_...",
      "total": 32,
      "currency": "USD",
      "expiresAt": "2027-01-15T12:30:00.000Z",
      "instruction": "Show the checkout URL to the user. Payment + delivery happen out-of-band; use lookup_order with the orderId that arrives by email."
    }
  }
}

What the user sees: the agent surfaces checkoutUrl; the user opens it in their browser; Stripe Checkout collects payment; on success, Onwardic's webhook fulfils the order and emails a PDF + order number. The agent can then poll lookup_order if the user shares the order number.

Why this works for agents:agents never handle payment credentials. The Stripe URL is a hard handoff to the user's browser — PCI-compliant by construction.

3. Look up an order's status

User pastes their order number and asks for status. Agent calls lookup_orderwith both the order number and the booking email (both required — email acts as a soft auth check so one user can't look up another user's order).

Request:

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "tools/call",
  "params": {
    "name": "lookup_order",
    "arguments": {
      "orderId": "OW-26-001655",
      "email": "traveler@example.com"
    }
  }
}

Response — delivered:

{
  "structuredContent": {
    "orderNumber": "OW-26-001655",
    "status": "delivered",
    "service": "Onward Ticket",
    "amount": 32,
    "currency": "USD",
    "createdAt": "2026-04-26T09:30:00.000Z",
    "updatedAt": "2026-04-26T10:00:00.000Z",
    "trackingUrl": "https://onwardic.com/track?orderId=OW-26-001655&email=traveler%40example.com"
  }
}

Response — pending (still being processed):

{
  "structuredContent": {
    "orderNumber": "OW-26-001655",
    "status": "pending",
    "service": "Onward Ticket",
    "amount": 32,
    "currency": "USD",
    "createdAt": "2026-04-26T09:30:00.000Z",
    "updatedAt": "2026-04-26T09:30:00.000Z",
    "trackingUrl": "https://onwardic.com/track?orderId=OW-26-001655&email=traveler%40example.com"
  }
}

Response — cancelled:

{
  "structuredContent": {
    "orderNumber": "OW-26-001655",
    "status": "cancelled",
    "service": "Onward Ticket",
    "amount": 32,
    "currency": "USD",
    "createdAt": "2026-04-26T09:30:00.000Z",
    "updatedAt": "2026-04-26T10:05:00.000Z",
    "trackingUrl": "https://onwardic.com/track?orderId=OW-26-001655&email=traveler%40example.com"
  }
}

Why this works for agents: the email gate keeps the tool unauthenticated yet abuse-resistant — public surface, but cross-user lookups are blocked.

4. Ground an LLM with the help center

User asks “Do I need an onward ticket for Thailand?” Rather than answer from memory, the agent searches the Onwardic help center and uses the canonical post body as context.

Step 1 — search:

{
  "jsonrpc": "2.0",
  "id": 5,
  "method": "tools/call",
  "params": {
    "name": "search_blogs",
    "arguments": {
      "query": "onward ticket thailand",
      "limit": 5
    }
  }
}

Response:

{
  "structuredContent": {
    "query": "onward ticket thailand",
    "count": 1,
    "results": [
      {
        "slug": "onward-ticket-thailand",
        "title": "Onward Ticket for Thailand Visa: 2026 Guide",
        "excerpt": "Thailand requires proof of onward travel for tourists arriving without..."
      }
    ]
  }
}

Step 2 — fetch the body for grounding:

{
  "jsonrpc": "2.0",
  "id": 6,
  "method": "tools/call",
  "params": {
    "name": "get_blog_post",
    "arguments": { "slug": "onward-ticket-thailand" }
  }
}

Response:

{
  "structuredContent": {
    "slug": "onward-ticket-thailand",
    "title": "Onward Ticket for Thailand Visa: 2026 Guide",
    "body": "# Onward Ticket for Thailand Visa\n\nThailand requires..."
  }
}

The agent feeds bodyinto its context as a system message: “Answer using the following authoritative content from Onwardic…” — and now answers cite the canonical source instead of hallucinating.

Why this works for agents: retrieval-augmented generation without crawling — the agent gets clean markdown, no HTML noise, and the post slug is a stable citation URL the agent can show the user.

Want to run any of these calls live? Open the playground. Looking for prepaid agency wallets and async webhooks? Read the B2B Reseller API & Portal docs.