# REST API reference ## API versioning Management endpoints use `/api/v1`. Account and session endpoints use /api. Capture URLs use `/b/:binId/*` and also accept requests at /b/:binId without a path suffix. Clients should tolerate additional fields in JSON responses. ## HTTP client examples The [JavaScript example](https://github.com/corridora/freebin/blob/main/src/site/examples/javascript.mjs) and [Python example](https://github.com/corridora/freebin/blob/main/src/site/examples/python.py) provide reusable functions for listing bins, creating bins, and listing requests. Both read `FREEBIN_API_KEY` and the optional `FREEBIN_URL` environment variable. ## Endpoint reference The reference below covers management, capture, account, and MCP endpoints. Use the OpenAPI specification for REST request and response schemas. Public share URLs are read-only web pages. ### Management API Replace path parameters with IDs returned by the API. Bin access means an owner account API key, an authorized browser session, or an anonymous inspector capability. Collaborator sessions require the permission for each operation. #### GET /api/v1/bins List bins owned by the API-key account, newest first. An anonymous inspector capability lists its bin. An unrecognized nonempty credential returns an empty list. Authentication: Bearer key. #### POST /api/v1/bins Create a private bin with a bearer key or browser session. Without credentials, creates a public bin that cannot capture. Send termsAccepted: true; names default to Untitled bin. Authentication: Optional bearer key or session. #### GET /api/v1/bins/:binId Read a bin’s name, response and forwarding configuration, creation time, and current public-share token. Authentication: Bin access. #### PATCH /api/v1/bins/:binId Update the fallback capture response and automatic forwarding configuration, including one allowed HTTPS destination and optional conditions. Authentication: Bin access. #### DELETE /api/v1/bins/:binId Permanently delete a bin and its retained data. Collaborator sessions cannot delete bins. Authentication: Bin access. #### GET / PUT /api/v1/bins/:binId/config Export or atomically replace the versioned portable bin configuration and ordered response rules. Captures and replay history are preserved. Authentication: Bin access. #### GET /api/v1/bins/:binId/audit List mutation audit events, newest first. limit accepts 1–500 and defaults to 100; up to 500 events are retained per bin. Authentication: Bin access. #### GET /api/v1/bins/:binId/collaborators List collaborators and their permissions. Collaborator sessions require collaborators.view. Authentication: Bin access. #### PUT / DELETE /api/v1/bins/:binId/collaborators Invite or update a registered-user collaborator with PUT; remove one with DELETE. Both operations require the bin owner’s browser session. Authentication: Owner session required. #### GET / POST / PUT /api/v1/bins/:binId/rules List, create, or reorder conditional response rules. Enabled rules use first-match-wins order. Authentication: Bin access. #### PATCH / DELETE /api/v1/bins/:binId/rules/:ruleId Update or delete one conditional response rule. Authentication: Bin access. #### POST /api/v1/bins/:binId/rules/test Test a synthetic request against enabled rules without capturing it. Authentication: Bin access. #### GET /api/v1/bins/:binId/interactions?limit=10&offset=0 List retained requests, newest first. limit accepts 1–100 or all and defaults to 10; responses include an interactions array plus meta.total, meta.limit, and meta.offset. Authentication: Bin access. #### GET /api/v1/bins/:binId/stream?lastId=:requestId Open a server-sent event stream. Checks the latest request every five seconds for about 125 seconds, emitting request IDs or keepalives. Reconnect to continue; Last-Event-ID takes precedence over lastId. Authentication: Bin access. #### GET /api/v1/bins/:binId/export Download bin configuration, rules, retained requests, replay attempts, and automatic-forwarding attempts as JSON. Authentication: Bin access. #### POST /api/v1/bins/:binId/share Enable or disable a read-only public bin URL with {"public":true|false}. Enabling again rotates the URL. Authentication: Bin access. #### DELETE /api/v1/bins/:binId/interactions/:requestId Permanently delete one retained request. Authentication: Bin access. #### GET /api/v1/bins/:binId/interactions/:requestId/export Download one retained request and its replay and automatic-forwarding attempts as JSON. Authentication: Bin access. #### POST /api/v1/bins/:binId/interactions/:requestId/share Enable or disable a read-only public request URL with {"public":true|false}. Authentication: Bin access. #### GET /api/v1/bins/:binId/interactions/:requestId/replay List the newest 50 retained replay attempts, including effective request snapshots and results. Authentication: Bin access. #### POST /api/v1/bins/:binId/interactions/:requestId/replay Replay a request with optional edits, or use operation: "forward" with the bin’s enabled forwarding destination. Manual forwarding bypasses forwarding conditions and can also apply edits. Outbound attempts are recorded; requests rejected before delivery do not create attempts. Authentication: Bin access. #### GET /api/v1/bins/:binId/interactions/:requestId/forwarding List retained automatic-forwarding attempts for one captured request. Authentication: Bin access. ### MCP and OAuth OAuth-capable MCP clients discover these endpoints automatically. Freebin requires authorization code flow with S256 PKCE and explicit account consent. #### POST /mcp Send MCP JSON-RPC messages over Streamable HTTP. Tool availability depends on the granted bins:read, requests:read, and replay:write scopes. Authentication: OAuth token or account key. #### GET /.well-known/oauth-protected-resource/mcp Describe the protected MCP resource, authorization server, and baseline scopes. Authentication: Public. #### GET /.well-known/oauth-authorization-server Publish authorization, token, registration, revocation, scope, and PKCE metadata. Authentication: Public. #### GET / POST /oauth/authorize Authenticate the account, display requested access, and approve or deny the OAuth grant. Authentication: Session required. #### POST /oauth/token Exchange an authorization code, refresh an access token, or revoke a token according to advertised metadata. Authentication: OAuth client. #### POST /oauth/register Register a compatible OAuth client dynamically. Client ID Metadata Documents are also supported. Authentication: Public. ### Request capture Capture URLs accept requests at /b/:binId and any path below it. Use an API key belonging to the bin owner, or the configured public capture key for the designated demo. #### GET /b/:binId/\* Capture a GET request and return the bin’s configured response. Authentication: Bearer key required. #### POST /b/:binId/\* Capture a POST request and return the bin’s configured response. Authentication: Bearer key required. #### PUT /b/:binId/\* Capture a PUT request and return the configured response. Authentication: Bearer key required. #### PATCH /b/:binId/\* Capture a PATCH request and return the configured response. Authentication: Bearer key required. #### DELETE /b/:binId/\* Capture a DELETE request and return the configured response. Authentication: Bearer key required. #### OPTIONS /b/:binId/\* Capture an OPTIONS request and return the configured response. Authentication: Bearer key required. #### HEAD /b/:binId/\* Capture a HEAD request. The stored body is null and the response has no body. Authentication: Bearer key required. ### Browser account and session API These endpoints support the first-party web application. Corridora manages login and user accounts; Freebin sets a secure HttpOnly session cookie after the browser-bound sign-in callback and revalidates the central session on authenticated requests. #### GET /api/config Return browser telemetry configuration, application name, deployment environment, and application version. The legacy signupsEnabled field is retained for compatibility; Corridora controls account registration. Authentication: Public. #### GET /api/auth/login Start Corridora sign-in with termsAccepted=true and an optional returnTo of /account or a pending /oauth/authorize?... URL. Returns a 303 redirect to app.corridora.ai/login and sets a browser-bound sign-in cookie. Authentication: Public; terms required. #### GET /api/auth/callback Complete the Corridora sign-in handoff using code and returnTo. Requires the initiating browser’s sign-in cookie; returns a 303 redirect to the account page or pending OAuth authorization. Authentication: Browser-bound handoff. #### POST /api/auth/register Returns 409. Local password registration is disabled; create or manage the account through Corridora. Authentication: Disabled. #### POST /api/auth/login Returns 409. Local password login is disabled; use the GET sign-in flow through Corridora. Authentication: Disabled. #### POST /api/auth/logout Revoke the scoped Freebin credential, delete the local session, and clear its cookie. The Corridora dashboard session remains signed in. Authentication: Session optional. #### GET /api/me Return the signed-in account, storage usage and limit, and owned or shared bins. Signed-out callers receive user: null and an empty bins array. Authentication: Session optional. #### DELETE /api/me Returns 409 with accountManagementUrl pointing to app.corridora.ai/settings. User account management is handled by Corridora. Authentication: Managed by Corridora. #### GET /api/account/token List API-key metadata. Full key values are never returned after creation. Authentication: Session required. #### POST /api/account/token Create a named user API key in `fb_` format. The full token is returned once; accounts may have five active keys. Authentication: Session required. #### DELETE /api/account/token Revoke the key whose ID is supplied as {"id":"…"}. Authentication: Session required. ## Error model REST API errors generally use `{"error":"Human-readable message"}`. Some endpoints include an additional code field. Clients should branch on HTTP status codes and treat the message as diagnostic text. Stream authorization and availability errors use plain text. Capture responses use the bin’s configured response format, and MCP uses its protocol-specific error format. Replay delivery errors are returned with attempt details; a destination HTTP error still returns API status 200, while a transport failure returns 502. Source: [Freebin API documentation](https://freebin.org/docs) and [Freebin quickstart](https://github.com/corridora/freebin/blob/main/QUICKSTART.md).