Skip to content

TypeScript SDK

The TypeScript SDK is a small typed client for Node.js, browsers and Cloudflare Workers. Its run method runs a script and returns the result in one call, however long the script takes. Every other API operation is a method too. Each path, parameter and response takes its type from the same definitions the API uses to validate requests, so the SDK always matches the API reference.

Terminal window
npm install @reminix/sdk

Create an API key in the app under Settings → Developers, and keep its access at Run scripts.

  • createClient() reads your key from the REMINIX_API_KEY environment variable. If you haven’t set it, it reads REMINIX_TOKEN, the variable the CLI uses. With neither variable set, it throws an error.
  • Where there’s no process.env, such as in a browser or a Cloudflare Worker, pass the key yourself: createClient({ apiKey: env.REMINIX_API_KEY }).
  • With an API key, every call acts in the key’s workspace.
  • With a personal access token, pass it as token and name the workspace: createClient({ token, workspace: "acme" }).
import { createClient } from "@reminix/sdk";
const reminix = createClient(); // uses the REMINIX_API_KEY environment variable
const run = await reminix.run("monthly-report", { month: "2026-09" });
console.log(run.output);

run returns once the script has finished:

  • A long run keeps going after the API call returns. run checks on it until it ends.
  • A run that needs a person’s approval waits for them. Pass onApproval to show them where to approve it: reminix.run(slug, inputs, { onApproval: (url) => notify(url) }).
  • A run that fails or ends as cancelled throws a RunError. A run ends as cancelled when a person stops it, an approver denies it, or its approval expires. The error’s run has the run’s status, and the run’s error says why.
  • To get the run back straight away, pass { wait: false }. Later, reminix.waitForRun(run) follows it until it ends. It also takes the run’s id.
  • pollInterval sets how often run checks on a run that hasn’t ended, in milliseconds. It’s 2000 by default.
  • timeout limits each request run makes, in milliseconds, as on every other method. If a request times out, run tries it again.
  • headers go with every request run makes.
  • To stop waiting, pass a signal. It stops every request run makes, starting the run included. AbortSignal.timeout(ms) limits the whole wait. The run carries on when the wait stops.
  • To make calling again safe, such as from a job that reruns, pass { idempotencyKey }. A second call with the same key and inputs returns the first run instead of starting another.

Give a file input as a Blob, a File, or { name, mediaType, data }. The SDK uploads the file first and passes its id. In this example, the monthly report takes an optional CSV file of manual adjustments and saves the report as a CSV file:

import { readFile } from "node:fs/promises";
import { createClient } from "@reminix/sdk";
const reminix = createClient(); // uses the REMINIX_API_KEY environment variable
const run = await reminix.run("monthly-report", {
month: "2026-09",
adjustments: {
name: "adjustments.csv",
mediaType: "text/csv",
data: await readFile("adjustments.csv"),
},
});
for (const file of run.files ?? []) {
if (file.origin === "saved") console.log(file.name, file.downloadUrl);
}

The files a run saves come back in run.files, each with a download link. Files has the details.

import { createClient } from "@reminix/sdk";
const reminix = createClient(); // uses the REMINIX_API_KEY environment variable
const runs = await reminix.runs.list({ script: "monthly-report", limit: 10 });
console.log(runs.items);

Every API operation is a method, named after its CLI command. For example, reminix runs list becomes reminix.runs.list().

  • Ids in the path are arguments, and everything else goes in one object:

    reminix.scripts.update("monthly-report", { name: "Monthly report" });
  • A method returns the response’s data.

  • Creating a schedule or trigger needs a personal access token, not a workspace API key. Schedules and triggers explains why.

  • Because the types come from the API itself, your editor completes every method, field and response.

A list method returns its first page when you await it. The page has the response’s items and nextCursor:

import { createClient } from "@reminix/sdk";
const reminix = createClient(); // uses the REMINIX_API_KEY environment variable
const page = await reminix.runs.list({ script: "monthly-report", limit: 50 });
console.log(page.items);
if (page.hasNextPage()) {
const next = await page.getNextPage();
console.log(next.items);
}

To go through every item, use for await. The SDK fetches each next page when it needs it:

import { createClient } from "@reminix/sdk";
const reminix = createClient(); // uses the REMINIX_API_KEY environment variable
for await (const run of reminix.runs.list({ script: "monthly-report" })) {
console.log(run.id, run.status);
}

Each next page is the same call with cursor set, so your other fields and options hold for every page. Read more about pagination.

When the API refuses a call, the method throws an APIError. It has the error’s code, message, status and requestId. It also has:

  • details: what is wrong with each field, as { path, message }, when the API refused the input.
  • docs: a link to the error on the Errors page.
  • headers: the response’s headers, such as Retry-After and the rate-limit headers.

Each status has its own class, so you can catch one kind of failure:

Status Class
400 BadRequestError
401 AuthenticationError
402 PlanLimitError
403 PermissionDeniedError
404 NotFoundError
409 ConflictError
422 UnprocessableEntityError
429 RateLimitError
500+ InternalServerError

Any other status is an APIError itself.

When the SDK can’t reach the API, the method throws an APIConnectionError, with the network’s error as its cause. When every attempt timed out, it throws an APITimeoutError, which is an APIConnectionError too.

A run that fails throws a RunError. Every error a call throws, a RunError included, is a ReminixError, unless your own signal stopped it:

import {
createClient,
NotFoundError,
ReminixError,
RunError,
} from "@reminix/sdk";
const reminix = createClient(); // uses the REMINIX_API_KEY environment variable
try {
await reminix.run("monthly-report", { month: "2026-09" });
} catch (error) {
if (error instanceof NotFoundError) {
console.log("No such script");
} else if (error instanceof RunError) {
console.log(error.run.error);
} else if (error instanceof ReminixError) {
console.log(error.message);
} else {
throw error;
}
}
  • Every write sends an idempotency key. When the SDK retries a failed attempt, such as after a network error or a 503, the write still happens only once.

  • The SDK retries a failed attempt twice. To change that, pass maxRetries to createClient. 0 turns retries off.

  • When the API says how long to wait with Retry-After, the SDK waits that long, up to 60 seconds. If it must wait longer, it throws the error, such as a RateLimitError, instead.

  • To make your own retries safe too, pass your key as the last argument:

    reminix.runs.create("monthly-report", { inputs }, { idempotencyKey: id });
  • Each attempt waits up to 60 seconds for a response. The SDK retries a timed-out attempt with the same key. To change the limit, pass timeout in milliseconds to createClient, or to one call:

    reminix.scripts.get("monthly-report", { timeout: 5000 });
  • To limit a whole call, retries included, pass a signal. With AbortSignal.timeout(), the call stops at once when time is up, even while it waits to retry. It then throws the signal’s TimeoutError, not an SDK error:

    reminix.scripts.get("monthly-report", { signal: AbortSignal.timeout(2000) });
Option What it does
apiKey Your API key. By default, REMINIX_API_KEY, then REMINIX_TOKEN.
token A personal access token, instead of a key.
workspace The workspace a personal access token acts in.
environment The environment to act in, sent as X-Environment. By default, the workspace’s default.
baseURL The API’s address, without /v1. By default, REMINIX_BASE_URL, else our API.
defaultHeaders Headers to send with every request. A call’s own headers win.
maxRetries How many times to retry a failed attempt. By default, 2.
timeout How long each attempt may take, in milliseconds. By default, 60 000.
fetch Your own fetch, such as a Cloudflare service binding.

Outside a browser, every request names the SDK and its version in its User-Agent header, such as reminix-node/1.0.0.

Each API method takes these options for one call, as its last argument: idempotencyKey, headers, timeout and signal. run and uploadFile take all four. waitForRun takes headers, timeout and signal, beside pollInterval.

Here is every method. Each one links to its fields and a full example under Endpoints:

Scripts

scripts.archive()
Archive a script
scripts.create()
Create a script
scripts.get()
Get a script
scripts.list()
List scripts
scripts.restore()
Restore an archived script
scripts.update()
Change a script

Runs

runs.cancel()
Cancel a run
runs.create()
Run a script
runs.get()
Get a run
runs.list()
List runs
runs.log()
Get a run's log

Versions

scriptVersions.get()
Get a version
scriptVersions.list()
List a script's versions
scriptVersions.publish()
Publish a version
scriptVersions.testRun()
Test-run a version
scriptVersions.upload()
Upload a version

Schedules

schedules.create()
Schedule a script
schedules.delete()
Delete a schedule
schedules.get()
Get a schedule
schedules.list()
List a script's schedules
schedules.update()
Change a schedule

Triggers

triggers.create()
Run a script when something happens
triggers.delete()
Delete a trigger
triggers.get()
Get a trigger
triggers.list()
List a script's triggers
triggers.rotateSecret()
Rotate a webhook trigger's secret
triggers.update()
Change a trigger

Files

files.content()
Get a file's content
files.get()
Get a file
files.list()
List files
files.upload()
Upload a file

Environments

environments.create()
Add an environment
environments.delete()
Delete an environment
environments.get()
Get an environment
environments.list()
List environments
environments.update()
Change an environment

Secrets

secrets.delete()
Delete a secret
secrets.get()
Get a secret
secrets.list()
List secrets
secrets.update()
Update a secret
secretValues.delete()
Remove a secret's value from an environment
secretValues.set()
Save a secret's value

Script settings

scriptSettings.get()
Get the workspace's script settings
scriptSettings.update()
Change the workspace's script settings

Trigger calls

triggerCalls.list()
List a webhook trigger's calls

Workspace

workspace.get()
Get the current workspace
workspace.invitations.list()
List pending invitations
workspace.members.list()
List workspace members
workspace.planUsage.get()
Get your plan's usage this period
workspace.teams.list()
List teams

Webhooks

workspace.eventTypes.list()
List event types
workspace.webhookDeliveries.list()
List an endpoint's deliveries
workspace.webhookDeliveries.redeliver()
Redeliver an event
workspace.webhookEndpoints.create()
Add a webhook endpoint
workspace.webhookEndpoints.delete()
Remove a webhook endpoint
workspace.webhookEndpoints.enable()
Re-enable a webhook endpoint
workspace.webhookEndpoints.get()
Get a webhook endpoint
workspace.webhookEndpoints.list()
List webhook endpoints
workspace.webhookEndpoints.test()
Send a test event
workspace.webhookEndpoints.update()
Update a webhook endpoint

Approvals

workspace.approvalActions.list()
List the actions you can ask approval for
workspace.approvalRequests.create()
Ask a person to approve an action
workspace.approvalRequests.get()
Check an approval request
workspace.approvalRequests.redeem()
Redeem an approved request

Audit events

workspace.auditEvents.list()
List workspace audit events

Personal access tokens

user.me()
Get the current user
user.revokeToken()
Revoke the token making this request

reminix.GET, reminix.POST and the other HTTP methods call any path, with the same types. They return { data, error, response } instead of throwing, and unwrap turns that into the data or an APIError:

import { createClient, unwrap } from "@reminix/sdk";
const reminix = createClient(); // uses the REMINIX_API_KEY environment variable
const scripts = unwrap(await reminix.GET("/scripts"));
console.log(scripts.items);