---
title: "API authentication | Hostemi"
description: "A key you create yourself in the app, or OAuth 2.1 with PKCE for an app that acts for other hosts. No sales step, no waiting list."
canonical: https://hostemi.com/docs/api/authentication
source: https://hostemi.com/docs/api/authentication.md
---

# API authentication

A key you create yourself in the app, or OAuth 2.1 with PKCE for an app that acts for other hosts. No sales step, no waiting list.

#### On this page

1. [An API key, for your own code](#an-api-key-for-your-own-code)
2. [OAuth 2.1, for an app that acts for others](#oauth-2-1-for-an-app-that-acts-for-others)
3. [What a key never holds](#what-a-key-never-holds)
4. [When it fails](#when-it-fails)

## An API key, for your own code

Create the key in the app under Settings, AI & apps. It starts with `hst_` and is shown once. Send it as the whole `Authorization` header; the `Bearer` prefix is accepted too.

**curl**

```bash
curl -s https://api.hostemi.com/public/v1/is-connected -H "Authorization: hst_your_key"
```

**JavaScript**

```js
const res = await fetch('https://api.hostemi.com/public/v1/units', {
  headers: { Authorization: process.env.HOSTEMI_KEY },
});
const { units } = await res.json();
```

**Python**

```python
import os, requests

r = requests.get('https://api.hostemi.com/public/v1/units', headers={'Authorization': os.environ['HOSTEMI_KEY']})
units = r.json()['units']
```

`GET /is-connected` checks a key without needing a scope. A key's power follows its owner's current role: if they are moved down or leave the workspace, the key can at once do only what they can. A key that belongs to several workspaces picks one with the `showorg` header (the workspace id).

## OAuth 2.1, for an app that acts for others

An app that works in other hosts' workspaces asks each host to approve it, and never sees their keys:

| Step | Detail |
| --- | --- |
| Discover | Resource metadata at `https://api.hostemi.com/.well-known/oauth-protected-resource`; authorization server metadata at `https://api.hostemi.com/.well-known/oauth-authorization-server`. |
| Register | A Client ID Metadata Document, or dynamic registration at `https://api.hostemi.com/oauth/register`. |
| Authorize | Authorization code with PKCE (S256 only) at `https://hostemi.com/oauth/authorize`, with `resource=https://api.hostemi.com/public/v1` and the scopes you need. |
| Token | `https://api.hostemi.com/oauth/token` (public clients send no secret); refresh tokens are issued. |
| Call | `Authorization: Bearer pos_…`. A token is bound to its resource: one issued for the MCP server is refused here, and the reverse. |

## What a key never holds

No Hostemi credential contains, replaces or reveals a booking platform login or a card number. Connecting a platform, keys, team members and billing are done by a person in the app.

## When it fails

| Answer | Meaning |
| --- | --- |
| 401 {"msg":"No API Key found"} | No Authorization header. |
| 401 {"msg":"Invalid API key"} | Unknown, revoked or mistyped key. |
| 401 | An OAuth token issued for another resource (the MCP server), or expired. |
| 403 SCOPE\_REQUIRED | The key lacks the scope; the body names it. [Scopes](https://hostemi.com/docs/api/scopes). |

Documentation pages

Something missing from this page? Write to [hello@hostemi.com](mailto:hello@hostemi.com), or use the form on the [Help](https://hostemi.com/help) page.
