FLOWLOGIC
module /api-auth-patterns

unit U22 of 4

API keys done right

scoping, rotation, vaulting

An API key is a bearer secret: whoever holds the string is the client, no questions asked. That bluntness is why scope and storage matter more than the key itself. A key minted with full account access, pasted into a step parameter, and shared across three flows is a single point of catastrophic failure — leak it once and an attacker can read every record, run up spend, and you cannot even tell which flow was breached. Treat every key as a liability sized to exactly what one integration needs, and nothing broader.

Scope down at the source: most providers let you mint a key restricted to specific endpoints, read-only where possible, and rate-limited per key. In the engine, store it as a Connection — never a literal in an HTTP Request field, where it lands in the exported flow JSON and the run history. Reference it through the Connection so the value is encrypted at rest and masked in exports. Give each flow, or each environment, its own key so you can revoke one without breaking the others.

Where it breaks: rotation you never planned for. A key with no expiry and no owner outlives the person who created it, gets copied into a Postman collection and a Slack thread, and becomes impossible to retire safely because nobody knows what would break. Rotate on a schedule, keep the old and new key valid during an overlap window, and cut over cleanly before you revoke.

worked example

A scoped, rotation-ready key manifest for a client’s read-only inventory sync against their commerce API.

{
  "name": "inventory-sync-prod",
  "key": "sk-•••live•••",
  "scopes": ["inventory:read", "products:read"],
  "rate_limit_rpm": 120,
  "environment": "production",
  "created": "2026-06-01",
  "rotates_at": "2026-09-01",
  "overlap_days": 7,
  "owner": "[email protected]",
  "stored_in": "vault://youragency/engine/inventory-sync"
}

field checklist

common failure — A leaked key nobody could revoke

A single admin-scoped key powered eight flows and lived in the HTTP Request steps as plaintext. When it surfaced in an exported flow shared over email, revoking it would have broken all eight at once, so it stayed live for weeks. Scope keys to one integration, store them as encrypted Connections, and give each flow its own — so revoking one is a contained, boring event.

check your understanding

One admin-scoped API key powers eight flows and is written directly into their HTTP Request steps. It then appears in a flow export shared over email. What made this unrecoverable rather than routine?

next unit opens once this is passed

sandbox validation

The check above confirms you followed the unit. Marking the module COMPLETED takes more: build the automation in your own engine and submit the exported flow and its run evidence, signed, to your unique validation URL. See the module page for that spec.