FerriteDocs

OpenAPI and structured errors

Generate an OpenAPI 3.1 API catalogue and RFC 9457 application/problem+json errors directly from your Surface declaration so HTTP clients and agents call your endpoints reliably.

An OpenAPI 3.1 document tells HTTP clients, SDK generators, API hubs, and AI assistants exactly which paths exist, what JSON payloads they accept, and what responses to expect. When your application uses agent-ready, Ferrite generates both /.well-known/api-catalog (aliased at /openapi.json) and RFC 9457 application/problem+json error replies from the same Surface declaration that powers your /mcp endpoint.

Declare operations in Surface

Add each callable HTTP operation to Surface.routes[].operations. Every declared operation becomes a typed OpenAPI path item whose operationId matches Operation.name:

use crate::agent_ready::surface::Operation;
use ferrite_app::serde_json::json;

let create_booking = Operation {
    name: "create_booking".into(),
    method: "POST".into(),
    path: "/api/bookings".into(),
    description: "Create a class reservation. Requires a signed-in bearer token; returns 409 when full.".into(),
    input_schema: Some(json!({
        "type": "object",
        "properties": {
            "class_id": { "type": "string", "minLength": 1 },
            "seats": { "type": "integer", "minimum": 1, "maximum": 4 }
        },
        "required": ["class_id"],
        "additionalProperties": false
    })),
    output_schema: Some(json!({
        "type": "object",
        "properties": {
            "booking_id": { "type": "string" },
            "status": { "type": "string" }
        },
        "required": ["booking_id", "status"]
    })),
    read_only: false,
    idempotent: true,
    price_micros: 0,
};

What agent-ready generates

EndpointPurpose
GET /.well-known/api-catalogOpenAPI 3.1 JSON catalogue generated from all declared Surface operations
GET /openapi.jsonDirect alias serving the same OpenAPI 3.1 document
GET /poppy/openapi.jsonExposure-filtered OpenAPI 3.1 view served when Personal Agent Protocol is enabled, excluding InternalOnly operations

Each generated operation entry carries:

  • operationId set to Operation.name.
  • requestBody or query parameters derived from input_schema, plus response schema from output_schema when provided.
  • An idempotency-key header parameter on POST operations, annotated as retry-safe only when idempotent is true.
  • read_only and idempotent traits matching the tool annotations published on /mcp.
  • An RFC 9457 application/problem+json error response schema.
  • x-price-usd-micros metadata and a 402 Payment Required response whenever price_micros > 0 (see x402 agent payments).

Ferrite’s App Hub and Code Mode can also index operations from an application’s OpenAPI catalogue when an application exposes HTTP operations without a primary /mcp endpoint.

Return RFC 9457 structured errors

Assistants recover cleanly from conflicts, invalid inputs, and authorization refusals when failures arrive as predictable JSON instead of plain text or HTML error pages. Use agent_ready::problem to return application/problem+json with a stable type URI, HTTP status, short title, and actionable detail:

{
  "type": "https://yoga.ferrite.cloud/problems/class-full",
  "title": "Class is full",
  "status": 409,
  "detail": "Saturday 08:30 has 0 seats left. Call list_classes to check the 10:00 session."
}

Never place stack traces, internal hostnames, SQL or store keys, or secret names inside detail. State what failed and which declared operation or input change resolves it.

Explicit boundaries and limits

  • No auto-generated securitySchemes or rate-limit schemas. agent-ready does not infer authentication headers or rate-limit headers from your handler code. Document required authentication, scopes, and throttling behavior in each operation’s description, or enable Personal Agent Protocol for scope-annotated Poppy discovery.
  • Machine-readable JSON only. Ferrite does not bundle Swagger UI or Scalar UI. Serve /openapi.json directly to clients, generators, and agent hubs, and document workflows for humans and models in your pages and llms.txt.
  • Declaration vs runtime truth. agent-ready emits what your Surface declares; it does not enforce read_only, idempotent, or output_schema at runtime. Only set idempotent: true on a POST operation when your handler deduplicates repeated idempotency-key requests atomically.

Verify locally

ferrite dev
curl -s http://127.0.0.1:8787/.well-known/api-catalog | jq '.openapi, (.paths | keys)'
curl -s http://127.0.0.1:8787/openapi.json | jq '.info'

Confirm that .openapi starts with 3.1, every declared operation appears under .paths, and refused requests return Content-Type: application/problem+json.

Next steps

Ferrite counts page views on this site. Privacy · Terms · Support