SDK reference
createGate
The Gate client — createGate(), require(), and resume().
import { createGate } from "@seal-dev/sdk";createGate(options)
Creates a Gate bound to your API key and base URL.
const gate = createGate({
apiKey: process.env.SEAL_API_KEY!,
baseUrl: "https://api.your-org.com",
});| Option | Type | Required | Notes |
|---|---|---|---|
apiKey | string | yes | Sent as Authorization: Bearer <apiKey>. |
baseUrl | string | yes | API origin. A trailing slash is stripped. |
fetch | FetchLike | no | Custom fetch. Defaults to globalThis.fetch; required if none. |
Returns a Gate with require() and resume().
gate.require(input, options?)
Creates an approval request and, unless told not to, long-polls until it settles. Resolves
with the ApprovalRequestView when the request is
approved, and throws on any non-approved terminal state.
const approval = await gate.require({
action: "wire.transfer",
policyKey: "payments.high_value",
payload: { to: "acct_999", amount: 5000 },
context: { reason: "Vendor invoice #4471" },
idempotencyKey: "invoice-4471",
});Input
| Field | Type | Required | Notes |
|---|---|---|---|
action | string | yes | 1–200 chars. What the agent wants to do. |
policyKey | string | yes | 1–200 chars. Which policy decides. |
payload | object | yes | JSON object the policy evaluates and the reviewer sees. |
context | object | no | Agent reasoning shown to the reviewer; never evaluated. |
agent | string | no | 1–200 chars. Used for policy match on agent. |
idempotencyKey | string | no | Reuse to make creation idempotent; returns the same record. |
Options
| Option | Type | Default | Notes |
|---|---|---|---|
waitSeconds | number | 30 | Per-poll long-poll budget, clamped to 1–30. |
timeoutMs | number | — | Overall client deadline; throws ApprovalPendingError if hit. |
poll | boolean | true | false returns the initial pending record without waiting. |
signal | AbortSignal | — | Abort waiting; throws ApprovalPendingError with the last state. |
Resolution
| Final status | Result |
|---|---|
approved | resolves with the ApprovalRequestView |
rejected | throws ApprovalRejectedError |
expired | throws ApprovalExpiredError |
| still pending after budget | throws ApprovalPendingError |
An allow verdict is auto-approved server-side, so require() returns without ever notifying a
human. require_approval is what blocks on a reviewer.
gate.resume(approvalId)
Fetches the current state of an existing approval — one shot, no polling. Useful after a process restart or when reacting to a webhook.
const approval = await gate.resume("6f1c…-uuid");
if (approval.status === "approved") {
/* … */
}Returns the ApprovalRequestView; throws
GateApiError on a non-2xx response.