Developers

Quickstart

Install the TypeScript SDK and make your first FluxDigest API request.

Preview access required

Developer credentials are not generally available yet. During private beta, eligible workspace Admins can create a test key from Settings > Developers.

This guide creates a subscriber in a test workspace. Keep your API key in a server-side environment variable and use test mode while developing.

1. Create a restricted key

In the FluxDigest dashboard, open Settings > Developers > API keys and create a test key with these scopes:

workspaces:read
subscribers:read
subscribers:write

FluxDigest shows the full key once. Store it in your secret manager as FLUXDIGEST_API_KEY.

2. Install the SDK

npm install @fluxdigest/sdk

3. Initialize the client

fluxdigest.ts
import { FluxDigest } from "@fluxdigest/sdk";

export const fluxdigest = new FluxDigest({
  apiKey: process.env.FLUXDIGEST_API_KEY,
});

The constructor fails when the key is missing. FluxDigest does not silently fall back to a development credential or another environment variable.

4. Create a subscriber

create-subscriber.ts
import { fluxdigest } from "./fluxdigest";

const subscriber = await fluxdigest.subscribers.create({
  workspaceId: "ws_01JEXAMPLE",
  email: "ada@example.com",
  name: "Ada Lovelace",
  tags: ["sdk-quickstart"],
});

console.log(subscriber.id, subscriber.status);

The corresponding HTTP request is:

curl --request POST \
  --url https://api.sandbox.fluxdigest.com/v1/workspaces/ws_01JEXAMPLE/subscribers \
  --header "Authorization: Bearer $FLUXDIGEST_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: quickstart-ada-001" \
  --data '{
    "email": "ada@example.com",
    "name": "Ada Lovelace",
    "tags": ["sdk-quickstart"]
  }'

5. Handle errors

import { FluxDigestError } from "@fluxdigest/sdk";

try {
  await createSubscriber();
} catch (error) {
  if (error instanceof FluxDigestError) {
    console.error(error.status, error.code, error.requestId);
  }
  throw error;
}

Keep the requestId when reporting an issue. It lets FluxDigest support trace a request without needing your API key or full request payload.

Next steps