# Support Site API Reference

This document summarizes the browser-facing API routes exposed by `support.opencartgreece.gr`.

## GET `/api/health`

Returns a simple health payload plus discovery links for the API catalog, OpenAPI description, and human-readable API documentation.

- Returns `200` when the support-site API surface is available.
- Use this endpoint as the `status` target in the RFC 9727 catalog.
- Includes `openidConfiguration`, `oauthAuthorizationServer`, and `oauthProtectedResource` links so agents can discover the production Clerk OAuth/OIDC issuer and protected-resource metadata used by authenticated site experiences.

## GET `/api/availability`

Returns the localized public team availability status used by the site notification.

- Accepts optional `lang=el` or `lang=en`; otherwise uses `Accept-Language` and falls back to Greek.
- Returns `status.message`, `status.variant`, `status.reason`, `status.dismissKey`, and next-open metadata when relevant.
- Sends CORS headers only for HTTPS origins on `opencartgreece.gr`, `*.opencartgreece.gr`, `open-cart.gr`, and `*.open-cart.gr`.

## GET `/api/postcode/{postcode}`

Returns the places and streets that ELTA assigns to a five-digit Greek postcode.

- Example: `curl https://support.opencartgreece.gr/api/postcode/10431`
- A space after the third digit is accepted (`104 31`).
- Returns `200` with `query`, `count` and `results[]` (`postcode`, `place`, `streets[]`), `400` (`invalid_postcode`) when the value is not five digits, `404` (`postcode_not_found`), and `500` (`postcode_data_unavailable`).

## GET `/api/place/{place}`

Returns up to 25 places whose Greek name equals or starts with the query, each with its postcodes and streets.

- Example: `curl https://support.opencartgreece.gr/api/place/%CE%91%CE%98%CE%97%CE%9D%CE%91` (`ΑΘΗΝΑ`, URL-encoded).
- Accents and case are ignored; the query must use Greek characters.
- Returns `200` with `query`, `count` and `results[]`, `400` (`invalid_place`) for an empty query, `404` (`place_not_found`), and `500` (`postcode_data_unavailable`).

## POST `/api/check-url`

Checks a submitted URL and returns the downstream HTTP status, final URL after redirects, and response headers.

- Accepts JSON with a `url` field or a raw URL string.
- Returns `200` on success, `400` for invalid input, and `502` when the downstream fetch fails.

## POST `/api/report-abuse`

Submits an abuse report to the site operators after validating the request body and verifying the Cloudflare Turnstile token.

- Accepts JSON fields for reporter details, the abusive URL, a description, and `cf-turnstile-response`.
- Returns `200` on success, `400` for validation or CAPTCHA failures, and `500` or `504` for server-side delivery issues.

## GET `/api/plugins/version`

Returns the latest known version for a supported plugin identifier.

- Requires the `plugin` query parameter.
- Returns `200` on success, `400` when the parameter is missing, `404` for unknown plugins, and `503` when the upstream version lookup fails.

## POST `/api/stripe/create-checkout-session`

Redirects the request to the configured checkout-session worker endpoint.

- Returns `307` when the worker endpoint is available.
- Returns `500` when the worker endpoint is not configured.

## Authenticated customer API

Customer account and dashboard data is served from `https://api.opencartgreece.gr`.

- Use `https://support.opencartgreece.gr/.well-known/oauth-protected-resource` when starting discovery from the support-site origin. It publishes the resource identifier for the site, the supported Clerk authorization server, and the advertised scopes for authenticated access.
- The worker origin also publishes `https://api.opencartgreece.gr/.well-known/oauth-protected-resource` for direct API discovery.
- Unauthorized responses from the protected API also return `WWW-Authenticate: Bearer resource_metadata="..."` so OAuth-capable clients can recover discovery metadata directly from a `401`.

## Machine-readable description

Use `/site-api.openapi.json` for the OpenAPI document, `/.well-known/api-catalog` for the RFC 9727 API catalog, `/.well-known/ai-catalog.json` (also served as `/.well-known/ard.json`) for the AI catalog, `/.well-known/agent-card.json` for the public A2A agent discovery card, `/.well-known/openid-configuration`, `/.well-known/oauth-authorization-server`, or `/.well-known/oauth-protected-resource` for authentication discovery, `/pricing.md` for published prices, and `/api/health` for a lightweight status check. Human-readable developer documentation is at `/developers/`.

## MCP server

AI agents can call the same public data through the Model Context Protocol server at `https://support.opencartgreece.gr/mcp`.

- Transport: Streamable HTTP (JSON responses).
- Authentication: none for the public tools. The plugin tools need a signed-in OpenCart Greece account: send a Clerk OAuth access token as `Authorization: Bearer <token>`. Without a valid token they return HTTP 401 with a `WWW-Authenticate` header that points to `/.well-known/oauth-protected-resource`.
- Protocol versions: `2025-11-25`, `2025-06-18`, `2025-03-26`; an unsupported requested version is answered with the latest supported one.
- Public read-only tools: `lookup_greek_postcode`, `search_greek_places`, `get_opencart_greece_pricing`, `get_support_availability`.
- Read-only tools for signed-in users: `list_opencart_plugins` (every plugin with its latest version) and `get_opencart_plugin_version` (one plugin).
- Each tool declares an `inputSchema` and an `outputSchema` and returns `structuredContent`.
- Server card: `/mcp/server-card` and `/.well-known/mcp/server-card.json`.
