Hookdeck Outpost Quickstart: TypeScript

Hookdeck Outpost is Hookdeck’s managed Outpost service. Each tenant represents one of your platform’s customers; destinations are where events are delivered; topics route events to the right destinations.

This quickstart uses the official TypeScript SDK. Configure topics in the Hookdeck dashboard before publishing—use a topic name that exists there in the code below.

Prerequisites

  • A Hookdeck account with an Outpost project
  • An API key (Outpost API key) from your project: Settings → Secrets
  • Topics already configured in the dashboard
  • Node.js 18+ recommended
  • API base URL: https://api.outpost.hookdeck.com/2025-07-01

Install the SDK

npm install @hookdeck/outpost-sdk

Set up credentials

In the Hookdeck Dashboard, open your Outpost project, go to Settings → Secrets, and create or copy an API key. Export it (and optionally the base URL) in your shell:

export OUTPOST_API_KEY="your_api_key"
export OUTPOST_API_BASE_URL="https://api.outpost.hookdeck.com/2025-07-01"

The SDK defaults to the production API base URL, so OUTPOST_API_BASE_URL is only needed if you want to be explicit or point at another environment.

Set environment variables

Before you run the quickstart script, define these in the same terminal session (or load them from a .env file if your tooling supports it).

  1. OUTPOST_API_KEYRequired. Copy the Outpost API key from Settings → Secrets in your project. The script passes this to the SDK as the Bearer token. Without it, the script stops with an error.

  2. OUTPOST_API_BASE_URLOptional. Only set this if you need to override the API host. For Hookdeck Outpost you can omit it entirely: the SDK already uses https://api.outpost.hookdeck.com/2025-07-01.

  3. OUTPOST_TEST_WEBHOOK_URLRequired for this walkthrough. The script creates a webhook destination, which must point at an HTTPS URL. Easiest path: open Hookdeck Console, create a Source, copy its URL, and assign it to this variable so you can see the webhook payload without deploying your own server.

Create and run the quickstart script

Save the following as outpost-quickstart.ts.

The script (1) builds an authenticated SDK client, (2) ensures a tenant exists, (3) adds a webhook destination subscribed to your topic, (4) publishes one test event, and (5) prints the event id.

import { Outpost } from "@hookdeck/outpost-sdk";

//
// --- 1. Authenticated client (API key from Settings → Secrets) ---
//

const apiKey = process.env.OUTPOST_API_KEY;
if (!apiKey) {
  throw new Error("Set OUTPOST_API_KEY");
}

const outpost = new Outpost({
  apiKey,
  ...(process.env.OUTPOST_API_BASE_URL
    ? { serverURL: process.env.OUTPOST_API_BASE_URL }
    : {}),
});

//
// --- 2. Tenant id, topic name, and webhook URL (from env) ---
//
// tenantId = one of your customers in Outpost.
// topic    = must match a topic configured in the dashboard.
//

const tenantId = "customer_acme_001";
const topic = "user.created";

const webhookUrl = process.env.OUTPOST_TEST_WEBHOOK_URL;
if (!webhookUrl) {
  throw new Error(
    "Set OUTPOST_TEST_WEBHOOK_URL to an HTTPS endpoint (e.g. a Hookdeck Console Source URL)",
  );
}

//
// --- 3. Create or update the tenant ---
//

await outpost.tenants.upsert(tenantId);

//
// --- 4. Webhook destination: Outpost delivers events on `topic` to this URL ---
//

await outpost.destinations.create(tenantId, {
  type: "webhook",
  topics: [topic],
  config: { url: webhookUrl },
});

//
// --- 5. Publish one event (delivered to destinations subscribed to `topic`) ---
//

const published = await outpost.publish.event({
  tenantId,
  topic,
  eligibleForRetry: true,
  metadata: { source: "quickstart" },
  data: { user_id: "user_123" },
});

console.log("Published event id:", published.id);

Run:

npx tsx outpost-quickstart.ts

To subscribe the destination to all topics, pass topics: ["*"] instead of [topic].

Verify delivery

  • In Hookdeck Console, inspect the Source or connection you used for OUTPOST_TEST_WEBHOOK_URL and confirm the webhook request arrived as expected.
  • In the Hookdeck Dashboard, open your Outpost project and review logs to confirm the event was processed and delivered.

Next steps