Seal
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",
});
OptionTypeRequiredNotes
apiKeystringyesSent as Authorization: Bearer <apiKey>.
baseUrlstringyesAPI origin. A trailing slash is stripped.
fetchFetchLikenoCustom 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

FieldTypeRequiredNotes
actionstringyes1–200 chars. What the agent wants to do.
policyKeystringyes1–200 chars. Which policy decides.
payloadobjectyesJSON object the policy evaluates and the reviewer sees.
contextobjectnoAgent reasoning shown to the reviewer; never evaluated.
agentstringno1–200 chars. Used for policy match on agent.
idempotencyKeystringnoReuse to make creation idempotent; returns the same record.

Options

OptionTypeDefaultNotes
waitSecondsnumber30Per-poll long-poll budget, clamped to 130.
timeoutMsnumberOverall client deadline; throws ApprovalPendingError if hit.
pollbooleantruefalse returns the initial pending record without waiting.
signalAbortSignalAbort waiting; throws ApprovalPendingError with the last state.

Resolution

Final statusResult
approvedresolves with the ApprovalRequestView
rejectedthrows ApprovalRejectedError
expiredthrows ApprovalExpiredError
still pending after budgetthrows 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.

On this page