Skip to main content
See /concepts/lifecycle for the end-to-end flow (policy → trigger → bond → wait/sell decision).
The agent’s job is one HTTP call. Everything else — gas, on-chain encoding, event scraping for the policyId — happens server-side.

Sequence

Full TypeScript example

curl equivalent

Field deep-dive

  • productName — canonical name (FLASHBTC1H-001, FLASHETH24-001, …). Preferred input — the API resolves both the productId hash AND the per-shield asset literal from it. See Products and assets for the registered set.
  • productId — bytes32 hash. Optional alternative to productName. Compute as keccak256(toUtf8Bytes('FLASHBTC24-001')). Pre-computed values are listed in Shields.
  • coverageAmount — string of USDC base units. **Minimum: "100000000" (= 100,enforcedonchain).100, enforced on-chain).** 100 = "100000000", $1,000 = "1000000000". Always pass as a string to preserve precision.
  • asset — bytes32 of the asset symbol. Optional — the API auto-resolves the per-shield literal when omitted. This must equal the product’s coveredAsset (exposed on GET /products) — not the USDC payment token. Each shield expects a specific value (BTC for FlashBTC, ETH for FlashETH); sending the wrong one reverts with InvalidAsset(bytes32) (selector 0x8196d462). See Covered asset vs payment asset for the distinction.
  • buyer — the wallet that pays the USDC premium (NOT the relayer). Must hold ≥ premium and have approved the relayer-side spender.

Idempotency

Pass Idempotency-Key: <uuidv4> on every retryable purchase. Replays return the original response without double-spending. The key is scoped per agent; it’s safe (and good practice) to derive a fresh UUID per logical attempt.

Errors