# Upsy API: use Upsy from your code with an API key

> Create an Upsy API key and call your Gmail, Calendar, Drive, Slack, memory and files from TypeScript, the AI SDK or any MCP client, with the access you choose.

Updated 2026-12-04 · https://upsy.ai/guides/upsy-api

## Short answer

Create an API key in Upsy under **Assistants › Add assistant › Your code**, or **Settings › API keys**. Choose what it can use, then install the SDK with `npm install @upstash/upsy` and call `new Upsy({ apiKey })`. Every app you allowed is a tool: `upsy.listTools()` lists them and `upsy.call(name, args)` runs one. Any MCP client works too: connect to `https://upsy.ai/connect` with the header `Authorization: Bearer <key>`.

## What an API key is

Assistants like Claude and ChatGPT sign in to Upsy with OAuth: a person clicks **Allow** in a browser. Your own code can't do that, so it uses an API key instead.

Each key is an assistant of its own. It shows up on the **Assistants** page next to Claude and ChatGPT, with:

- **Its own access.** Each app is Read-only or All, or you pick single actions. Memory, Files and the cloud browser are on or off.
- **Its own history.** Everything the key did is listed on its page.
- **A switch.** Turning it off stops the key at once, without losing its settings.

A key starts with everything you have turned on, and every app at **Read-only**: in your apps, a key that leaks can look things up, but can't send, change or delete anything. Memory, Files and the cloud browser are on or off, not Read-only: Files lets a key save files, and the browser gives it full control of the sites you're logged in to. Turn off what a key doesn't need when you create it, or later on its page.

## Create a key

1. In [Upsy](https://upsy.ai/agents/new), open **Assistants**, click **Add assistant**, then **Your code**. **Settings › API keys › Create API key** opens the same page.
2. Give the key a name, like the app or script it's for.
3. Choose when it expires: 30 days, 90 days (the default), 1 year or never.
4. Choose what it can use, and set each app to Read-only or All.
5. Click **Create API key**, and copy the key. It starts with `upsy_sk_` and is shown only once.

Keep the key in a secret store or an environment variable, such as `UPSY_API_KEY`. Never put it in code that runs in a browser.

## Use it with the TypeScript SDK

```bash
npm install @upstash/upsy
```

```ts
import { Upsy } from "@upstash/upsy";

const upsy = new Upsy({ apiKey: process.env.UPSY_API_KEY });

// What this key may use
const tools = await upsy.listTools();
console.log(tools.map((t) => t.name));

// Run one; JSON comes back parsed
const threads = await upsy.call("search_threads", { query: "invoice newer_than:7d" });
```

`new Upsy()` with no options reads `UPSY_API_KEY` from the environment. The tool names and their arguments are the same ones any assistant sees. Each tool's `inputSchema` describes its arguments.

When a tool says it failed, for example because the key is Read-only and the tool sends email, `call()` throws an `UpsyToolError` with Upsy's message. A wrong, expired or revoked key throws an `UpsyAuthError`. `callRaw()` returns the whole MCP result instead, with images and other content blocks.

## Use it with the Vercel AI SDK

The SDK turns Upsy's tools into AI SDK tools:

```ts
import { anthropic } from "@ai-sdk/anthropic";
import { generateText, isStepCount } from "ai";
import { Upsy } from "@upstash/upsy";
import { upsyTools } from "@upstash/upsy/ai";

const upsy = new Upsy();

const { text } = await generateText({
  model: anthropic("claude-sonnet-5-5"),
  system: await upsy.instructions(),
  tools: await upsyTools(upsy),
  stopWhen: isStepCount(10),
  prompt: "Summarize the invoices I got this week.",
});
```

`upsy.instructions()` is what Upsy tells every assistant about the apps and accounts this key can use. Pass `{ only: ["search_threads", "get_message"] }` to `upsyTools` to hand the model fewer tools.

## Use it from any MCP client

Upsy is an MCP server, so you don't need the SDK. Connect to `https://upsy.ai/connect` over Streamable HTTP and send the key as a bearer token.

With the AI SDK's own MCP client:

```ts
import { createMCPClient } from "@ai-sdk/mcp";

const mcp = await createMCPClient({
  transport: {
    type: "http",
    url: "https://upsy.ai/connect",
    headers: { Authorization: `Bearer ${process.env.UPSY_API_KEY}` },
  },
});
const tools = await mcp.tools();
```

With the official MCP TypeScript SDK:

```ts
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";

const client = new Client({ name: "my-app", version: "1.0.0" });
await client.connect(
  new StreamableHTTPClientTransport(new URL("https://upsy.ai/connect"), {
    authProvider: { token: async () => process.env.UPSY_API_KEY },
  }),
);
const { tools } = await client.listTools();
```

## Many agents, many sandboxes

One key can be used from many places at once, and they all share its access and history. When each agent should have its own access, or you want to stop one without stopping the rest, create one key per agent. You can have up to 50 keys.

## Change, regenerate or remove a key

Open the key on the **Assistants** page:

- **What it can use:** change any app's access. It takes effect on the next call.
- **Regenerate:** makes a new key with a new expiry. The old key stops working at once.
- **Turn it off:** the switch at the top. The key stays, but can use nothing until you turn it back on.
- **Remove:** at the bottom of the page. The key stops working for good.

## Troubleshooting

### UpsyAuthError: Upsy refused the API key

The key is wrong, expired or revoked, or its assistant was removed. Check it under **Settings › API keys**. An expired key shows "Expired" there: regenerate it on its page.

### Every call says the user turned Upsy off

The key's assistant is turned off. Turn it back on with the switch at the top of its page on the **Assistants** page. `upsy.instructions()` says so too.

### A tool isn't available, or says it isn't allowed

A key gets only the tools of the apps it may use, and only the read-only ones for an app that's Read-only. Memory, Files and the cloud browser are always listed, and refused when they're off for the key. Set the app to All, pick the action, or turn on Memory, Files or Browser on the key's page.

## Security

- Upsy stores only a hash of each key. The key is shown once, when you create or regenerate it.
- Keys expire after 90 days unless you choose otherwise.
- Every call is in the key's history. With alerts on, Upsy emails you when a new key is created.
- Your app logins never reach your code: Upsy calls Gmail, Slack and the rest for you, with the access you gave the key.

## FAQ

### Is there a Python SDK?

Not yet. Any MCP client works, in any language: connect to `https://upsy.ai/connect` with the `Authorization: Bearer` header.

### Can I use a key in a browser?

No. Anyone who opens the page could read it. Call Upsy from your server, and keep the key there.

### Does a key see everything in my Upsy?

Only what you allow on its page, and each app's accounts only at the level you set.

---

Upsy connects personal AI assistants (Muse, Grok, ChatGPT, Claude, Gemini, Cursor, Antigravity, Claude Code, Codex, OpenClaw, Devin) to your Gmail, Google Calendar, Google Drive, Slack, Notion and other apps through one MCP server, with a shared memory, files and a cloud browser signed in to your sites. You choose what each assistant may do in each app, see everything it did, and turn it off in one click. Upsy is free. To add Upsy to an assistant, add a remote MCP server (Streamable HTTP) named Upsy at https://upsy.ai/connect. It signs in with OAuth; there is no API key.
