# auth.md — Authentication for AI Agents

Onwardic uses a dual-mode authentication model:

- **Public / Guest Mode (No Auth Required):** Read-only service discovery, pricing, quoting, order lookup (gated by `orderId` + `email`), help-center/blog tools, AND rate-limited guest calls to MCP/A2A `place_order` (returning an unpaid Stripe Checkout `checkoutUrl`) work **without an API key**.
- **Partner API Key Mode (`place_order` higher quota & `POST /api/v1/pay-links`):** Partners integrating at scale or calling REST `POST /api/v1/pay-links` authenticate with a **Partner API Key (`owk_...`)** issued via https://onwardic.com/b2b/apply (or partner onboarding via `support@onwardic.com`).

## Public tools & endpoints (no auth required)

| Surface | Tools / Endpoints | Auth |
| --- | --- | --- |
| MCP (`POST /api/mcp`) & A2A (`POST /api/a2a`) | `list_services`, `quote_order`, `search_blogs`, `get_blog_post` | None (public) |
| MCP / A2A checkout session | `place_order` | Dual-mode: public guest limits (unpaid Stripe `checkoutUrl`) or Partner API Key (`owk_...`) for higher quota |
| Order tracking | `lookup_order` (MCP/A2A), `GET /api/orders/lookup`, `GET /api/track` | None (order number + email match required) |
| REST catalog & quotes | `GET /api/services`, `GET /api/pricing`, `POST /api/quote`, `POST /api/pricing/quote`, `GET /api/blog`, `GET /api/blog/:slug` | None (public) |

## Partner API Key authentication (`place_order` partner tier & `POST /api/v1/pay-links`)

Dedicated REST pay-link creation (`POST /api/v1/pay-links`) requires `PartnerApiKeysService` (`owk_...` keys), and MCP/A2A `place_order` accepts the same key for higher partner quota.

- **Header (recommended):** `X-API-Key: owk_...`
- **Bearer header (also accepted):** `Authorization: Bearer owk_...`
- **How to obtain a key:** Apply at https://onwardic.com/b2b/apply or email `support@onwardic.com` for partner onboarding.
- **What it covers:** Higher-quota MCP/A2A `place_order` calls and REST `POST /api/v1/pay-links`.
- **Behavior without a key:** Guest `place_order` calls via MCP/A2A remain subject to per-IP/guest rate limits (returning an unpaid Stripe `checkoutUrl`), while `POST /api/v1/pay-links` returns `401 Unauthorized`.

```bash
curl -X POST https://onwardic.com/api/v1/pay-links \
  -H "Content-Type: application/json" \
  -H "X-API-Key: owk_your_partner_key" \
  -d '{"serviceKey":"flight-itinerary","email":"traveler@example.com","flightRoute":"oneway","travelers":1}'
```

## Optional OAuth 2.0 (`client_credentials`, when `AGENT_OAUTH_ENABLED=true`)

When `AGENT_OAUTH_ENABLED=true` on the API service, RFC 7591 dynamic registration and RFC 6749 `client_credentials` token endpoints are exposed at:

| | |
| --- | --- |
| Registration endpoint | POST https://onwardic.com/api/oauth/register |
| Token endpoint (claim) | POST https://onwardic.com/api/oauth/token |
| Revocation endpoint | POST https://onwardic.com/api/oauth/revoke |
| Discovery | https://onwardic.com/.well-known/oauth-authorization-server |
| Protected resource metadata | https://onwardic.com/.well-known/oauth-protected-resource |
| Keys | https://onwardic.com/.well-known/jwks.json |

**Important:** Self-registered OAuth clients provide a stable identity and separate rate-limit bucket on public read/quote/lookup operations (`agent:read`, `agent:orders`). **Self-registered OAuth does NOT authorize `place_order` or `POST /api/v1/pay-links`** — pay-link minting always requires a Partner API Key (`owk_...`) issued through partner onboarding.

## Enterprise B2B Reseller API (`/api/b2b/*`)

High-volume agencies using prepaid wallets and async desk fulfillment use scoped `b2b_live_...` / `b2b_test_...` keys (`Authorization: Bearer b2b_live_...`). See https://onwardic.com/docs/b2b.

## What is NOT public

`/api/admin/*` is staff-only, behind a first-party session JWT issued to human operators. Do not attempt to authenticate against it.

## Payment

`place_order` and `POST /api/v1/pay-links` create an **unpaid** pending order and return a Stripe-hosted `checkoutUrl`. **Paying needs a human** — present `checkoutUrl` to your user so they can authorize payment in their own browser. Prices are always re-derived server-side; nothing is fulfilled until Stripe webhook confirmation.

We do not accept machine-initiated on-chain payments. https://onwardic.com/.well-known/x402 documents that position and declares `live_402_responses: false`. No endpoint here returns an HTTP 402 challenge.

## Rate limits

60 requests/minute per IP by default on API endpoints; `/.well-known/` is exempt.

## Entry points

- OpenAPI 3.1 — https://onwardic.com/openapi.json
- API catalog (RFC 9727) — https://onwardic.com/.well-known/api-catalog
- MCP server card — https://onwardic.com/.well-known/mcp/server-card.json
- MCP (Streamable HTTP, preferred) — https://onwardic.com/api/mcp
- MCP (SSE, legacy fallback) — https://onwardic.com/api/mcp/sse
- A2A agent card — https://onwardic.com/.well-known/agent-card.json
- A2A (JSON-RPC) — https://onwardic.com/api/a2a
- Partner onboarding — https://onwardic.com/b2b/apply
- Human-readable docs — https://onwardic.com/agents
- B2B & Pay-Link docs — https://onwardic.com/docs/b2b
- Contact — support@onwardic.com
