From API key to first sent message.
Six steps with the TypeScript or Python SDK: connect a mailbox, receive its events, then read and send mail.
Get an API key.
Workspaces come with early access; once yours is open, create a key in the console at app.workwae.com and keep it in your secret manager, since it is shown once.
# Your app's environment, not committed
WORKWAE_API_KEY=wk_... Install the SDK.
Two typed clients, both currently alphas: @workwae/sdk for TypeScript on npm and workwae for Python 3.10 or later on PyPI. The language you pick in any code window on this site is used in all of them.
npm install @workwae/sdk pip install workwae Create the client.
Pass the key from your own app’s environment. Most methods take one object with its path, query and body fields, and a few deletes with options take { params, query }.Methods are named after the operation in snake_case and take their path, query and body fields as keyword arguments; AsyncWorkwae has the same methods as coroutines.
import { createClient } from "@workwae/sdk";
export const workwae = createClient({
apiKey: process.env.WORKWAE_API_KEY,
});import os
from workwae import Workwae
workwae = Workwae(api_key=os.environ["WORKWAE_API_KEY"])Connect a mailbox.
First allowlist your redirect URI, once, with an admin-scoped key or under Settings in the console; a session to any other URI is refused. Then create a hosted connect session and redirect the user to its URL; the browser returns with status and account_id in the query string.
// Once, with an admin-scoped key: the redirect URIs you allow
await workwae.settings.update({
redirectUris: ["https://app.example.com/mail/connected"],
});
const session = await workwae.connectSessions.create({
redirectUri: "https://app.example.com/mail/connected",
providers: ["google", "microsoft", "imap"],
externalRef: "user_42",
});
// Redirect the browser to session.url
// Back on your redirect URI:
// ?status=success&account_id=6f1c2a4e-...# Once, with an admin-scoped key: the redirect URIs you allow
workwae.settings.update(redirect_uris=["https://app.example.com/mail/connected"])
session = workwae.connect_sessions.create(
redirect_uri="https://app.example.com/mail/connected",
providers=["google", "microsoft", "imap"],
external_ref="user_42",
)
# Redirect the browser to session.url
# Back on your redirect URI:
# ?status=success&account_id=6f1c2a4e-...Receive events.
Create a webhook endpoint, store its secret, and verify each delivery with parseWebhookparse_webhook before you trust it.
import { parseWebhook } from "@workwae/sdk";
const { endpoint, secret } = await workwae.webhooks.create({
url: "https://app.example.com/hooks/workwae",
filters: { eventTypes: ["message.created"] },
});
// In your handler: checks the signature and the timestamp
const body = await request.text();
const event = await parseWebhook(secret, request.headers, body);
if (event.known && event.type === "message.created") {
console.log(event.data.message.subject);
}from workwae import UnknownEvent, parse_webhook
webhook = workwae.webhooks.create(
url="https://app.example.com/hooks/workwae",
filters={"event_types": ["message.created"]},
)
# In your handler, with the raw request body: checks the signature and the timestamp
event = parse_webhook(webhook.secret, request.headers, body)
if not isinstance(event, UnknownEvent) and event.type == "message.created":
print(event.data.message.subject)Read and send.
List the account’s messages, then reply from the same mailbox; sends are queued and retried, and results arrive as events.
const { items } = await workwae.messages.list({ accountId, unread: true });
const message = await workwae.messages.get({
accountId,
messageId: items[0].id,
});
await workwae.outbox.create({
accountId,
inReplyToMessageId: message.id,
to: [{ address: "priya@example.com" }],
subject: "Re: Q3 roadmap",
text: "Thanks, I will review it today.",
});page = workwae.messages.list(account_id=account_id, unread=True)
message = workwae.messages.get(account_id=account_id, message_id=page.items[0].id)
workwae.outbox.create(
account_id=account_id,
in_reply_to_message_id=message.id,
to=[{"address": "priya@example.com"}],
subject="Re: Q3 roadmap",
text="Thanks, I will review it today.",
)Go deeper in the docs.
Quickstart guide
The full walkthrough, with curl, errors and the change feed.
Connect flows
Headless connect, your own OAuth apps and reauthorization.
Webhooks
Filters, retries, replay and secret rotation.
API reference
Every operation, with its fields and error reasons.
OpenAPI document
The machine-readable spec for code generators and tools.
Get a workspace and an API key.
We are onboarding a small number of teams. Tell us what you are building.