Skip to content
Browse documentation

API

API authentication

How to authenticate requests to the inFlow API.

Open Markdown

Authentication methods

Use public keys for visitor submissions, session tokens for the dashboard, and temporary integration credentials for coding agents.

Integration key (ik_…) — local coding-agent credential for /api/agent-integration. Explicitly grants one or several businesses, with per-business form scope, approved domains, and optional lead read permission. Discovery needs no business header; every other request requires X-Business-Id. See /docs/agent-integration. Legacy authoring key (fa_…) — draft-only, one business, /api/form-authoring; cannot read leads or register domains.

Public key (pk_…) — for browser-facing endpoints (form submissions, showcase rendering, AI chat). Sent as an Authorization: Bearer pk_… header. Enforces origin restrictions via environments and allowed domains. Cannot access administrative endpoints.

Session token (JWT) — user authentication for dashboard requests. Sent as an HTTP-only cookie or Authorization: Bearer <jwt> header. X-Business-Id selects a business; current membership and resource permissions authorize each operation. A session is not a scoped integration credential to hand to an external agent.

Public key endpoints

Public key auth is used for embedding inFlow widgets on third-party sites. It identifies a business but not an individual user. Endpoints that accept public key auth:

  1. 1POST /api/leads — form submissions
  2. 2GET /api/v1/ssr/showcase/:id — showcase SSR rendering
  3. 3GET /api/v1/ssr/showcase/:id/posts/:slug — single post
  4. 4GET /api/public-ai/config — published visitor agent configuration
  5. 5POST /api/public-ai/chat and POST /api/public-ai/chat/stream — visitor chat
  6. 6GET /api/forms/public/:id — published form definition
When Origin is supplied, public-key resolution checks the configured environment, legacy origin rules, or same-business hosted sites. Lead and visitor-chat writes additionally require a validated Origin. Public reads do not all require Origin. An agent can construct an Origin header, so origin admission is not proof of machine identity or administrative authority.

Making an authenticated request

ts
// Public key auth
const res = await fetch("https://api.inflow.build/api/leads", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer pk_67a1b2c3d4e5f6a7b8c9d0e1",
  },
  body: JSON.stringify({
    formId: "67d4...",
    responses: [],
  }),
});

const data = await res.json();

For session-authenticated endpoints (dashboard, admin), the server uses HTTP-only cookies managed by the login flow. Your frontend code calls the API normally — cookies are sent automatically.

Error responses

StatusMeaning
401Missing or invalid API key
403Origin, business scope, permissions, or feature access denied; inspect the endpoint's response
429Rate limit exceeded