---
title: "Quickstart: connect a mailbox in minutes · Workwae"
description: "Get an API key, install the TypeScript or Python SDK, connect a mailbox, receive signed webhooks, and read and send mail with Workwae."
url: https://workwae.com/quickstart
---

Quickstart

# 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.

Step 1 of 6

## Get an API key.

Workspaces come with [early access](https://workwae.com/early-access/); once yours is open, create a key in the console at [app.workwae.com](https://app.workwae.com/) and keep it in your secret manager, since it is shown once.

.env

```text
# Your app's environment, not committed
WORKWAE_API_KEY=wk_...
```

Step 2 of 6

## 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.

terminal

```text
npm install @workwae/sdk
```

terminal

```text
pip install workwae
```

Step 3 of 6

## 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.

workwae.tsworkwae.py

```ts
import { createClient } from "@workwae/sdk";

export const workwae = createClient({
  apiKey: process.env.WORKWAE_API_KEY,
});
```

```python
import os

from workwae import Workwae

workwae = Workwae(api_key=os.environ["WORKWAE_API_KEY"])
```

Step 4 of 6

## 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.

connect.tsconnect.py

```ts
// 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-...
```

```python
# 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-...
```

Step 5 of 6

## Receive events.

Create a webhook endpoint, store its secret, and verify each delivery with `parseWebhook``parse_webhook` before you trust it.

webhooks.tswebhooks.py

```ts
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);
}
```

```python
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)
```

Step 6 of 6

## Read and send.

List the account’s messages, then reply from the same mailbox; sends are queued and retried, and results arrive as events.

mail.tsmail.py

```ts
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.",
});
```

```python
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.",
)
```

Next

## Go deeper in the docs.

### [Quickstart guide](https://docs.workwae.com/guides/quickstart)

The full walkthrough, with curl, errors and the change feed.

### [Connect flows](https://docs.workwae.com/guides/connect)

Headless connect, your own OAuth apps and reauthorization.

### [Webhooks](https://docs.workwae.com/guides/webhooks)

Filters, retries, replay and secret rotation.

### [API reference](https://docs.workwae.com/reference)

Every operation, with its fields and error reasons.

### [OpenAPI document](https://api.workwae.com/v1/openapi.json)

The machine-readable spec for code generators and tools.

Early access

## Get a workspace and an API key.

We are onboarding a small number of teams. Tell us what you are building.

[Request early access](https://workwae.com/early-access/) [Read the docs](https://docs.workwae.com/)
