SDKs

Primitive publishes official SDKs for Node.js, Python, and Go. Use SDKs in application code and Functions. Use the CLI for terminal workflows; install it with Homebrew from primitivedotdev/tap or with npm as @primitivedotdev/cli.

LanguagePackageRuntime
Node.js@primitivedotdev/sdkNode.js 22 or newer
PythonprimitivedotdevPython 3.10 or newer
Gogithub.com/primitivedotdev/sdks/sdk-goGo 1.25 or newer

Install

npm install @primitivedotdev/sdk
pnpm add @primitivedotdev/sdk
yarn add @primitivedotdev/sdk
bun add @primitivedotdev/sdk

Receive an Email

import primitive from '@primitivedotdev/sdk';


const client = primitive.client({
  apiKey: process.env.PRIMITIVE_API_KEY!,
});


export async function POST(req: Request) {
  const email = await primitive.receive(req, {
    secret: process.env.PRIMITIVE_WEBHOOK_SECRET!,
  });


  await client.reply(email, {
    text: 'Got it.',
  });


  return Response.json({ ok: true });
}

Reply helpers use reply-specific body keys: text and html in Node.js and Python, and BodyText and BodyHtml in Go. Send helpers use send-specific names such as bodyText in TypeScript.

Send an Email

const result = await client.send({
  from: 'support@yourdomain.com',
  to: 'alice@example.com',
  subject: 'Order confirmed',
  bodyText: 'Your order is on its way.',
  wait: true,
});


console.log(result.id, result.deliveryStatus);

High-Level Helpers

The SDKs provide high-level helpers for:

  • verifying and parsing inbound webhooks;
  • sending new outbound messages;
  • replying to an inbound email with threading derived from the parent;
  • forwarding inbound context to a new recipient;
  • verifying webhook signatures manually when you need lower-level control.

Functions Runtime Caveat

Hosted Primitive Functions execute JavaScript. Function handler examples are therefore TypeScript/JavaScript-only. Application code outside hosted Functions can use Node.js, Python, or Go SDKs.

Low-Level API Client

Inside hosted Functions, import the API-safe subpath:

import { createPrimitiveClient } from '@primitivedotdev/sdk/api';

The /api subpath avoids Node-only modules and is suitable for Workers-style runtimes.

See CLI for terminal workflows.