# Gate.haus developer docs

> The complete public reference for adding "Sign in with Gate.haus" to an app and calling the Gate.haus API. Generated from https://gate.haus/developers/docs on 2026-11-14; the API lives at https://api.gate.haus and its OAuth discovery document at https://api.gate.haus/.well-known/oauth-authorization-server.

## Overview

Gate.haus is a standard OAuth 2.0 provider. People sign in on Gate.haus’s own screens with a password, a passkey or a connected account, including two-factor where they have it, and your app receives an access token. You never see or store their password.

|  |  |
| --- | --- |
| Base URL | `https://api.gate.haus` |
| Requests | JSON (`Content-Type: application/json`) or form-encoded. Query string on GET. |
| Authentication | Access token in the `X-Access-Token` header, or `Authorization: Bearer …` |
| Dates | UTC, formatted `YYYY-MM-DD HH:MM:SS` |
| URL spellings | `/v2/user/me.php`, `/v2/user/me` and `/v2/user/me/` are all the same endpoint |

Every JSON response uses the same envelope, except the token exchange:

```
{ "success": true, "data": { … }, "error": null }
```

On failure `success` is `false` and `error` is a message for people. Branch on the HTTP status and on `data.error_code` where present, never on the wording of `error`.

## Quick start

1.  [Create an app](https://gate.haus/developers) to get a client ID, and a client secret if it runs on a server. Add every redirect URI you will use, including `http://localhost` ones for development.
2.  Send the user to the authorise URL. Generate a fresh random `state`, keep it in their session, and compare it when they come back.
    
    ```
    https://api.gate.haus/v2/auth/authorise.php
      ?client_id=gh_xxxxxxxxxxxx
      &redirect_uri=https://yourapp.example/callback
      &response_type=code
      &scope=profile.read%20email.read
      &state=RANDOM_PER_REQUEST
    ```
    
3.  Gate.haus sends them back to `https://yourapp.example/callback?code=…&state=…`. Check `state`, then exchange the code from your server:
    
    ```
    curl -X POST https://api.gate.haus/v2/auth/token.php \
      -H 'Content-Type: application/json' \
      -d '{"client_id":"gh_xxxxxxxxxxxx","client_secret":"YOUR_SECRET","code":"CODE","redirect_uri":"https://yourapp.example/callback"}'
    ```
    
4.  Use the access token:
    
    ```
    curl https://api.gate.haus/v2/user/me.php -H 'X-Access-Token: ACCESS_TOKEN'
    ```
    

## Choosing a flow

| Your app | Flow | Client secret |
| --- | --- | --- |
| Server-side web app (PHP, Node, Rails, Django…) | Authorisation code | Yes, kept on the server |
| Single-page app (React, Vue, Svelte…) | Authorisation code + PKCE | No |
| Mobile or desktop app | Authorisation code + PKCE | No |

If your code runs on the user’s device or in their browser, it cannot keep a secret: create a **browser or mobile app** and use PKCE. Server-side apps should use PKCE as well; it costs a few lines and stops intercepted codes being used.

Redirect URIs are matched exactly

No wildcards, prefixes or extra query parameters. Use https, except `http://localhost` and `http://127.0.0.1` for development. Custom schemes such as `yourapp://callback` need to be enabled by Gate.haus first; contact support.

## PKCE

Create a new verifier for every sign-in and keep it until the token exchange.

**JavaScript**

```
function base64url(bytes) {
  return btoa(String.fromCharCode(...bytes)).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}

const verifier = base64url(crypto.getRandomValues(new Uint8Array(32)));
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier));
const challenge = base64url(new Uint8Array(digest));

sessionStorage.setItem('gatehaus_verifier', verifier);
location.href = 'https://api.gate.haus/v2/auth/authorise.php?' + new URLSearchParams({
  client_id: 'gh_xxxxxxxxxxxx',
  redirect_uri: location.origin + '/callback',
  response_type: 'code',
  scope: 'profile.read email.read',
  state: crypto.randomUUID(),
  code_challenge: challenge,
  code_challenge_method: 'S256'
});
```

Then exchange the code without a secret, sending the verifier instead:

```
{ "client_id": "gh_xxxxxxxxxxxx", "code": "CODE", "redirect_uri": "https://yourapp.example/callback", "code_verifier": "VERIFIER" }
```

On iOS and Android, open the authorise URL with `ASWebAuthenticationSession` or Custom Tabs, never an embedded web view. Embedded web views cannot use the person’s saved passkeys, and people are right not to trust a sign-in form inside an app.

## Using access tokens

```
GET /v2/user/me.php HTTP/1.1
Host: api.gate.haus
X-Access-Token: ACCESS_TOKEN
```

-   **Never put tokens in a query string.** They are refused, because URLs end up in logs and browser history.
-   Tokens are long-lived but can be revoked at any time: by the user disconnecting your app, by a password reset, or by Gate.haus. **Treat any 401 as “sign in again”.**
-   There are no refresh tokens. Sending a user who still has a Gate.haus session back through the authorise URL is usually instant; they only see the consent screen if you ask for new scopes.
-   Browser calls work from the origins of your registered redirect URIs. Calls from other origins are blocked by CORS.
-   Call [logout](https://gate.haus/developers/docs#logout) when someone signs out of your app.

## Scopes

Ask for the fewest you need. Your app can only request the scopes you ticked when you set it up. On the consent screen people see one line per area, for example *Notifications: read, send and delete notifications from Example*, with sensitive areas marked.

| Area | Scope | What it allows |
| --- | --- | --- |
| Profile | `profile.read` | See name, username, profile picture and country |
|  | `profile.write` | Change name and country (sensitive) |
|  | `username.write` | Change username (sensitive) |
|  | `picture.write` | Change profile picture |
| Email address | `email.read` | See the primary email address |
| Mobile number | `phone.read` | See the mobile number, once verified (sensitive) |
| Connected accounts | `identities.read` | See which sign-in accounts are linked, their display names, and the Discord and Steam IDs |
| Apps | `apps.read` | See which apps the user has connected |
| Notifications | `notification.read` | Read your app’s notifications and mark them as read |
|  | `notification.send` | Send notifications (sensitive) |
|  | `notification.delete` | Delete your app’s notifications |

Upgrading an app from the old scope names

Since 11 November 2026 `profile.read` no longer includes the email address and `profile.write` no longer covers the username or picture. Request `email.read`, `username.write` and `picture.write` explicitly. On your Developers page, **Migrate scopes** recommends the right ones for each app and builds the sign-in link. `notification.write` keeps working and means `notification.send` plus `notification.delete`.

Account settings (email addresses, passwords, two-factor, passkeys, connected accounts) can only be changed on gate.haus itself. No scope gives a third-party app access to them.

## Assurance and step-up

Not every action deserves the same proof. Reading a feed is not the same as changing a payout account. Gate.haus lets your app ask how strongly someone must have signed in, and always tells you how strongly they did. Apps that never ask see no difference.

### Levels

| acr | The user signed in with | Use it for |
| --- | --- | --- |
| `aal1` | One factor: a password, a connected account (Google, Discord…) or a passkey | Most of your app |
| `aal2` | Two factors (password or connected account plus an authenticator code or backup code), or a passkey unlocked with a PIN, fingerprint or face | Payments, payout details, changing an email or password, deleting data, admin areas |
| `aal3` | A certified hardware security key (for example a YubiKey 5 FIPS) unlocked with its PIN, that never leaves one device | Admin areas and the most sensitive actions. Few people own one, so expect unmet\_authentication\_requirements often |

The levels follow NIST SP 800-63B. `urn:gate.haus:aal:1`, `…:2` and `…:3` are accepted as aliases. Email and text-message codes never count towards a level.

### 1\. Ask for a level

Add any of these to the authorise URL:

| Parameter | Example | Meaning |
| --- | --- | --- |
| `acr_values` | `aal2` | The level you need. If you list several (`aal3 aal2`), the lowest one listed is the requirement. Values Gate.haus does not know are ignored. |
| `max_age` | `300` | The user must have proved themselves within this many seconds. Older proof does not count, so they confirm again. |
| `prompt` | `login` | Make them sign in again now, whatever their session. Same as `max_age=0`. |

**Asking for two-step verification within the last 5 minutes**

```
https://api.gate.haus/v2/auth/authorise.php
  ?client_id=gh_xxxxxxxxxxxx
  &redirect_uri=https://yourapp.example/callback
  &response_type=code
  &scope=profile.read
  &state=RANDOM_PER_REQUEST
  &code_challenge=…&code_challenge_method=S256
  &acr_values=aal2
  &max_age=300
```

If every sign-in to your app needs a level, set a **minimum sign-in level** on your app in the Developers page instead of adding `acr_values` everywhere. Requests can still ask for more than the minimum, never less.

### 2\. What the user sees

-   **Not signed in to Gate.haus:** they sign in as usual, and are then asked for whatever extra proof the level needs.
-   **Already signed in, but not strongly enough:** a *Confirm it is you* screen naming your app. It offers only what can work for their account: their passkey, their authenticator code, or their password first if the old one is too old. They are never asked to sign in from scratch.
-   **Already signed in strongly enough:** nothing extra. They go straight to the usual approval screen.

### 3\. Handle the result

| They come back with | Meaning | What to do |
| --- | --- | --- |
| `?code=…&state=…` | They proved enough | Exchange the code as usual, then check acr and auth\_time (step 4) |
| `?error=unmet_authentication_requirements` | Their account has no way to reach the level, for example no authenticator app or passkey | Explain that the action needs two-step verification, and link them to gate.haus/security to set it up |
| `?error=access_denied` | They cancelled, or declined your app | Leave them where they were |

### 4\. Check what you got

The token response tells you what the user actually proved:

| Field | Example | Meaning |
| --- | --- | --- |
| `acr` | `"aal2"` | The level reached |
| `amr` | `["pwd","otp","mfa"]` | How: `pwd` password, `otp` authenticator or backup code, `pop` passkey, `hwk` certified hardware key, `user` PIN or biometric, `fed` connected account, `device` remembered device, `mfa` more than one factor |
| `auth_time` | `1794416280` | Unix time of the oldest proof the level relies on |

Always check on your server

Treat `acr_values` as a request, not a guarantee: anyone can edit a URL. Before the sensitive action, check that `acr` is at least what you need and, if freshness matters, that `now - auth_time` is within your limit. Store both with the user’s session in your app.

**Checking the level (Node.js)**

```
const LEVEL = { aal1: 1, aal2: 2, aal3: 3 };

function strongEnough(token, needed = 'aal2', maxAgeSeconds = 300) {
  const reached = LEVEL[token.acr] ?? 0;
  const fresh = token.auth_time && Date.now() / 1000 - token.auth_time <= maxAgeSeconds;
  return reached >= LEVEL[needed] && fresh;
}
```

### Step-up: a worked example

1.  Someone signs in to your app with their password. The token says `acr: "aal1"`.
2.  They use your app normally.
3.  They open *Change payout account*. Your server sees the stored `acr` is `aal1`.
4.  You redirect them to the authorise URL with `acr_values=aal2&max_age=300` and a new `state` (remember where they were going).
5.  Gate.haus recognises their session and asks only for their authenticator code or passkey.
6.  They return with a new code. Exchange it, check `acr` is `aal2` and `auth_time` is recent, store the new token, and continue to the payout page.

### Your own API (RFC 9470)

If your API receives Gate.haus tokens from your app, look the level up with [token introspection](https://gate.haus/developers/docs#introspect) (server-side apps). When it is not enough, answer with the standard step-up challenge, so your client knows to send the user back through Gate.haus with those values:

```
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="insufficient_user_authentication",
  error_description="A stronger sign-in is needed", acr_values="aal2", max_age=300
```

### Good to know

-   Ask for `aal2` only where it matters. Asking on every sign-in turns away people who have not set up two-step verification.
-   A remembered device keeps the level it was signed in at, with its original `auth_time`, but never more than `aal2`. Use `max_age` when you need the proof to be recent.
-   `aal3` lasts at most 12 hours from `auth_time` and lapses after 15 minutes without activity (NIST SP 800-63B). Treat an older `aal3` as `aal2`, and ask again with `acr_values=aal3`; the user only touches their key.
-   Tokens issued before 11 November 2026 have no `acr`. Treat a missing `acr` as `aal1` at most.
-   From 1 December 2026, Gate.haus may ask for more proof when a sign-in looks unusual: two-step verification where the account has it, otherwise a code by email. You will see the resulting `acr`; nothing else changes for you.
-   Discover the endpoints and supported levels programmatically from `https://api.gate.haus/.well-known/oauth-authorization-server` (RFC 8414), which lists `acr_values_supported`.

## Endpoints

### OAuth

#### GET /v2/auth/authorise.php

**Auth:** None (browser). **Also available as** `/api/auth/authorise`

The hosted sign-in and consent screen. Send the user here in their browser; Gate.haus handles passwords, passkeys, social sign-in and two-factor, then redirects back with a code.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `client_id` | string | Yes | Your app’s client ID. |
| `redirect_uri` | string | Yes | Must exactly match one of your registered redirect URIs. |
| `response_type` | string | Yes | `code` |
| `scope` | string | Yes | Space-separated, e.g. `profile.read notification.write`. |
| `state` | string | Recommended | Random per request. Check it on return. |
| `code_challenge` | string | Public apps (recommended for all) | BASE64URL(SHA-256(code\_verifier)). If you send one, the token request must include the verifier. |
| `code_challenge_method` | string | Public apps | `S256` only. `plain` is refused. |
| `acr_values` | string | No | Assurance level you need, e.g. `aal2`. See [Assurance and step-up](https://gate.haus/developers/docs#assurance). |
| `max_age` | integer | No | The user must have signed in within this many seconds. |
| `prompt` | string | No | `login` forces a fresh sign-in. |

On approval the user returns to `redirect_uri?code=…&state=…&iss=…`; on refusal to `redirect_uri?error=access_denied&state=…`; if the user cannot reach the level you asked for, to `redirect_uri?error=unmet_authentication_requirements&state=…`. A bad request (another `response_type`, a scope your app is not approved for, or a public app without PKCE) returns `invalid_request`, `invalid_scope` or `unsupported_response_type` the same way, before anyone signs in. Every redirect includes `iss` (RFC 9207), which matches the issuer in the discovery document. Codes are single use and expire after 5 minutes. Returns HTML, not JSON.

#### POST /v2/auth/token.php

**Auth:** Client credentials or PKCE. **Also available as** `/api/auth/token`

The OAuth token endpoint: exchange an authorisation code for tokens, or a refresh token for new ones. Call it from your server for confidential apps.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `grant_type` | string | Yes | `authorization_code` or `refresh_token`. Omitted means authorization\_code. |
| `client_id` | string | Yes | Or send client\_id and client\_secret with HTTP Basic auth instead. |
| `client_secret` | string | Server-side apps | Never ship it to a browser or a phone. |
| `code` | string | authorization\_code | From the redirect. Use it once. |
| `redirect_uri` | string | authorization\_code | The same value you sent to authorise. |
| `code_verifier` | string | Public apps, and any app that sent a code\_challenge | The verifier behind your code\_challenge. |
| `refresh_token` | string | refresh\_token | The latest refresh token you were given. |
| `scope` | string | No | refresh\_token only: narrow the new access token to fewer scopes. It can never add scopes. |

**Example**

```
curl -X POST https://api.gate.haus/v2/auth/token.php \
  -u 'gh_…:gatehaus_sk_…' \
  -d grant_type=authorization_code -d code=… -d redirect_uri=https://yourapp.example/callback
```

**Response**

```
{
  "access_token": "a1b2c3…",
  "token_type": "Bearer",
  "expires_in": 3600,
  "refresh_token": "gatehaus_rt_…",
  "scope": ["profile.read"],
  "user_id": 123,
  "acr": "aal2",
  "amr": ["pwd", "otp", "mfa"],
  "auth_time": 1794416280
}
```

| Status | Meaning |
| --- | --- |
| `400 invalid_request` | A required field is missing, or a public app sent no code\_verifier. |
| `401 invalid_client` | Unknown or suspended app, a wrong client\_secret, or a secret that was reported as exposed and switched off (create a new one on the Developers page). |
| `400 invalid_grant` | The code or refresh token is unknown, expired, already used, for another app or redirect\_uri, or the PKCE verifier does not match. error\_description says which. |
| `400 invalid_scope` | A refresh asked for scopes that were never granted. |
| `400 unsupported_grant_type` | Only authorization\_code and refresh\_token are supported. |

Errors follow RFC 6749: `{"error": "invalid_grant", "error_description": "…"}`, with no response envelope. Apps created from 12 November 2026 get access tokens that last an hour (`expires_in`) and a refresh token; older apps get tokens that never expire and no refresh token. **Refresh tokens rotate:** each works once and the response carries the next one. Presenting a used one revokes every token from that sign-in, so store the new one before using the access token. A refresh token lapses after 30 days unused, and stops working when the person signs out, revokes your app or changes their password. A refreshed token keeps the original `acr`, `amr` and `auth_time`. Never retry a code: one replayed after a few seconds revokes the token it produced. Rate limited to 60 requests per IP per 5 minutes.

#### POST /v2/auth/introspect.php

**Auth:** Client credentials. **Also available as** `/api/auth/introspect`

Token introspection (RFC 7662) for your own API: is this token live, who is it for, and how strongly did the user sign in? Needs your app’s secret, so it is for your server: a server-side app’s client secret, or the optional server secret a browser or mobile app can create from Manage. Only tokens issued to your app are described.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `client_id` | string | Yes | Or use HTTP Basic auth. |
| `client_secret` | string | Yes | Public apps cannot introspect. |
| `token` | string | Yes | The access token your API was given. |

**Response**

```
{
  "active": true,
  "scope": "profile.read",
  "client_id": "gh_…",
  "sub": "123",
  "token_type": "Bearer",
  "acr": "aal1",
  "amr": ["pwd"],
  "auth_time": 1794416280
}
```

| Status | Meaning |
| --- | --- |
| `401 invalid_client` | Wrong client\_id or client\_secret, or a public app. |

Unknown, revoked or other apps’ tokens all return `{"active": false}`. No response envelope. Rate limited to 300 requests per IP per 5 minutes.

#### POST /v2/auth/revoke.php

**Auth:** Client credentials, or client\_id for public apps. **Also available as** `/api/auth/revoke`

Token revocation (RFC 7009): switch off an access token your app holds, for example when someone signs out. Works for any OAuth library that supports revocation.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `client_id` | string | Yes | Or use HTTP Basic auth. |
| `client_secret` | string | Server-side apps |  |
| `token` | string | Yes | An access token or refresh token. A refresh token also ends every access token from the same sign-in. |
| `token_type_hint` | string | No | Accepted and ignored. |

**Response**

```
HTTP 200 with an empty body.
```

| Status | Meaning |
| --- | --- |
| `400 invalid_request` | No token sent. |
| `401 invalid_client` | Unknown app, or a wrong client\_secret. |

Only tokens issued to your app are revoked, and the answer is 200 whether or not the token existed. No response envelope.

#### POST /v2/keys/burn.php

**Auth:** None. **Also available as** `/api/keys/burn`

Found a Gate.haus client secret, refresh token or access token somewhere it should not be, such as a public repository or a log? Send it here and it is switched off at once. Anyone can call this, and the owner is told.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `key` | string | Yes | The whole exposed secret or token. Client secrets start with gatehaus\_sk\_, refresh tokens with gatehaus\_rt\_. |

**Example**

```
curl -X POST https://api.gate.haus/v2/keys/burn.php -d 'key=gatehaus_sk_…'
```

**Response**

```
{ "success": true, "data": { "message": "If that was a live Gate.haus client secret, refresh token or access token, it has been switched off and its owner told. Thank you for reporting it." }, "error": null }
```

| Status | Meaning |
| --- | --- |
| `422 missing_key` | Nothing was sent. |

The answer is the same whether or not the key was live. A burned client secret stops your server exchanging codes until an owner creates a new one; people already signed in are unaffected. Rate limited to 20 requests per IP per 5 minutes.

#### GET or POST /v2/auth/logout.php

**Auth:** Access token

Revokes the access token you send. Call it when someone signs out of your app so the token does not outlive their session.

**Response**

```
{ "success": true, "data": { "logged_out": true }, "error": null }
```

Send the token in a header; GET and POST both work. A browser that opens this URL without a token is asked to confirm before its Gate.haus session ends, so another site cannot sign people out.

### Users

#### GET /v2/user/me.php

**Auth:** scope `profile.read, email.read or phone.read`. **Also available as** `/api/user/me`

The signed-in user. Each scope unlocks its own fields, and id is always included. Use id as the key in your database; email and username can change.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `profile.read` | scope |  | `first_name`, `surname`, `username`, `profile_picture`, `country_code`, `created_at` |
| `email.read` | scope |  | `email`: the primary address |
| `phone.read` | scope |  | `mobile_number` (only once verified, otherwise `null`) and `mobile_number_verified` |

**Example**

```
curl https://api.gate.haus/v2/user/me.php -H 'X-Access-Token: YOUR_TOKEN'
```

**Response**

```
{
  "success": true,
  "data": {
    "user": {
      "id": 123,
      "first_name": "Ada",
      "surname": "Lovelace",
      "email": "ada@example.com",
      "username": "ada",
      "profile_picture": "https://assets.gate.haus/profiles/123-ab12-500.png",
      "country_code": "GB",
      "created_at": "2026-01-15 10:22:31"
    }
  },
  "error": null
}
```

| Status | Meaning |
| --- | --- |
| `401` | Token missing, invalid or revoked. |
| `403` | Token has none of the three scopes. |
| `404` | The account no longer exists. |

Fields your token cannot see are left out, not set to `null`. `profile_picture` may be `null`; use the image endpoint below for a guaranteed picture.

#### GET /v2/user/image.php

**Auth:** None (public). **Also available as** `/api/user/image`

Redirects (302) to a user’s profile picture, or a generated identicon. Use it directly as an image source.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `id` | integer | Yes | Gate.haus user ID. |
| `size` | 100 | 500 | No | Defaults to 500. |

**Example**

```
<img src="https://api.gate.haus/v2/user/image.php?id=123&size=100" alt="">
```

Unknown IDs return an identicon rather than 404. Cached for 24 hours.

#### GET /v2/user/resolve.php

**Auth:** None (public)

Looks up a public profile by username, for example to show who someone is from an @mention.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `username` | string | Yes |  |

**Response**

```
{
  "success": true,
  "data": { "user": { "id": 123, "username": "ada", "first_name": "Ada", "surname": "Lovelace", "profile_picture": null } },
  "error": null
}
```

| Status | Meaning |
| --- | --- |
| `404` | No account has that username. |
| `422` | username missing or too long. |

#### GET /v2/user/stats.php

**Auth:** scope `profile.read`. **Also available as** `/api/user/stats`

A small summary of the account.

**Response**

```
{ "success": true, "data": { "authorised_apps": 4, "member_since": "2026-01-15 10:22:31" }, "error": null }
```

#### POST /v2/user/update-profile.php

**Auth:** scope `profile.write / username.write`

Updates the user’s name, country or username. Send only the fields you are changing. Name and country need profile.write; the username needs username.write.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `first_name` | string | No | Up to 100 characters. |
| `surname` | string | No | Up to 100 characters. |
| `username` | string | No | 3–30 characters: letters, numbers, \_ and . |
| `country_code` | string | No | ISO 3166-1 alpha-2, e.g. GB. |

**Response**

```
{ "success": true, "data": { "user": { "id": 123, "first_name": "Ada", "…": "…" } }, "error": null }
```

| Status | Meaning |
| --- | --- |
| `403` | You sent a field your token may not change. |
| `409` | Username taken. |
| `422` | Validation failed, or nothing to update. |

The returned user follows the same field rules as /v2/user/me.

#### POST /v2/user/upload-profile-picture.php

**Auth:** scope `picture.write`

Replaces the user’s profile picture. Send multipart/form-data with the image in a field called avatar.

**Example**

```
curl -X POST https://api.gate.haus/v2/user/upload-profile-picture.php \
  -H 'X-Access-Token: YOUR_TOKEN' \
  -F 'avatar=@photo.jpg'
```

**Response**

```
{
  "success": true,
  "data": {
    "avatar_100": "https://…-100.png",
    "avatar_500": "https://…-500.png",
    "profile_picture": "https://…-500.png"
  },
  "error": null
}
```

| Status | Meaning |
| --- | --- |
| `400` | No image, or the upload failed. |
| `413` | Over 4 MB. |
| `415` | Not a JPG, PNG or WebP. |
| `422` | Over 40 megapixels. |

Images are re-encoded, which strips EXIF data including location.

#### GET /v2/user/connected-accounts.php

**Auth:** scope `identities.read`. **Also available as** `/api/user/connected-accounts`

The sign-in accounts the user has connected to Gate.haus, with their display names. Steam accounts include the SteamID64 and Discord accounts the Discord user ID.

**Response**

```
{
  "success": true,
  "data": { "accounts": [
    { "provider": "steam", "display_name": "ada_plays", "linked_at": "2026-10-02 18:11:40", "steam_id": "76561198000000000", "discord_id": null },
    { "provider": "discord", "display_name": "Ada", "linked_at": "2026-11-11 09:40:12", "steam_id": null, "discord_id": "123456789012345678" },
    { "provider": "google", "display_name": "Ada Lovelace", "linked_at": "2026-09-30 09:12:03", "steam_id": null, "discord_id": null }
  ] },
  "error": null
}
```

Providers are google, apple, discord, facebook and steam. Email addresses and other providers’ internal IDs are never shared.

### Apps

#### GET /v2/user/authorised-apps.php

**Auth:** scope `apps.read`

The apps this user has signed in to with Gate.haus, with the permissions each one holds.

**Response**

```
{
  "success": true,
  "data": { "apps": [ {
    "id": 7, "client_id": "gh_…", "name": "Example", "description": "…",
    "logo": "https://…", "homepage_url": "https://…",
    "authorised_at": "2026-03-02 09:00:00", "last_used": "2026-11-10 18:21:04",
    "scopes": ["profile.read", "email.read"],
    "permissions": [
      { "area": "profile", "label": "Profile", "short": "Profile: see", "description": "See your name, username, picture and country.", "sensitive": false },
      { "area": "email", "label": "Email address", "short": "Email address: see", "description": "See your email address.", "sensitive": false }
    ]
  } ] },
  "error": null
}
```

#### GET /v2/apps/list.php

**Auth:** Any access token. **Also available as** `/api/apps`

The public app directory: apps whose owners have chosen to list them. No particular scope is needed.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `page` | integer | No | Defaults to 1. |
| `per_page` | integer | No | 1–50, defaults to 10. |
| `search` | string | No | Matches app names. |
| `approved` | 1 | No | Only apps that are live (not suspended). |

**Response**

```
{
  "success": true,
  "data": {
    "apps": [ { "id": 7, "client_id": "gh_…", "name": "Example", "description": "…", "logo": "https://…", "homepage_url": "https://…", "approved": 1 } ],
    "page": 1, "per_page": 10, "total": 1
  },
  "error": null
}
```

### Notifications

Notifications appear in the user’s Gate.haus dashboard and the Gate.haus iOS app, and can also be emailed. Your app’s name and logo are shown as the sender. Your app only ever sees, marks and deletes notifications **it** sent; notifications from Gate.haus and other apps stay private. Sending with a user’s token is limited to 120 per app per hour.

#### POST /v2/notifications/create.php

**Auth:** scope `notification.send`

Sends a notification to the signed-in user.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `title` | string | Yes | Up to 200 characters. |
| `body` | string | Yes | Up to 4,000 characters. Plain text. |
| `ctas` | array | No | Up to 4 buttons, each `{ "label": "…", "url": "https://…" }`. Only http(s) links are kept. |
| `send_email` | boolean | No | Also email it to the user’s primary address. |

**Example**

```
curl -X POST https://api.gate.haus/v2/notifications/create.php \
  -H 'X-Access-Token: YOUR_TOKEN' -H 'Content-Type: application/json' \
  -d '{"title":"Order shipped","body":"Your order #1042 is on its way.","ctas":[{"label":"Track it","url":"https://yourapp.example/orders/1042"}]}'
```

**Response**

```
{ "success": true, "data": { "notification_id": 981, "push": { "attempted": 1, "sent": 1, "status": "ok" } }, "error": null }
```

#### POST /v2/notifications/create-client.php

**Auth:** Client ID and secret

Server-to-server: notify a user without holding their token, for example from a background job.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `client_id` | string | Yes |  |
| `client_secret` | string | Yes |  |
| `user_id` | integer | Yes | The Gate.haus user ID. |
| `title, body, ctas, send_email` |  |  | As above. |

| Status | Meaning |
| --- | --- |
| `401` | Invalid client credentials. |
| `403` | Server-to-server notifications are not turned on for your app (contact us), or that user has not signed in to your app. |

Off by default. Ask Gate.haus support to turn it on for your app. You can only message people who currently have your app connected.

#### GET /v2/notifications/list.php

**Auth:** scope `notification.read`. **Also available as** `/api/notifications`

Notifications your app has sent this user, newest first.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `page` | integer | No | Defaults to 1. |
| `per_page` | integer | No | 1–50, defaults to 20. |

**Response**

```
{
  "success": true,
  "data": {
    "notifications": [ {
      "id": 981, "title": "Order shipped", "body": "…", "ctas": [ { "label": "Track it", "url": "https://…" } ],
      "severity": null, "sent_at": "2026-11-11 10:02:11", "viewed_at": null, "email_opened_at": null,
      "client_name": "Example", "client_logo": "https://…"
    } ],
    "page": 1, "per_page": 20, "total": 1
  },
  "error": null
}
```

#### POST /v2/notifications/mark-viewed.php

**Auth:** scope `notification.read`

Marks one of your app’s notifications as read.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `notification_id` | integer | Yes |  |

| Status | Meaning |
| --- | --- |
| `404` | No such notification from your app for this user. |

#### POST /v2/notifications/delete.php

**Auth:** scope `notification.delete`

Deletes one of your app’s notifications.

| Parameter | Type | Required | Notes |
| --- | --- | --- | --- |
| `notification_id` | integer | Yes |  |

| Status | Meaning |
| --- | --- |
| `404` | No such notification from your app for this user. |

#### POST /v2/notifications/delete-all.php

**Auth:** scope `notification.delete`

Deletes every notification your app has sent this user. Notifications from Gate.haus and other apps are untouched.

**Response**

```
{ "success": true, "data": { "deleted": 12 }, "error": null }
```

### System

#### GET /v3/health.php

**Auth:** None (public). **Also available as** `/health`

Service health, for your monitoring.

**Response**

```
{ "status": "ok", "database": true, "config": true }
```

Returns 503 when Gate.haus is degraded.

## Errors

| Status | Meaning | What to do |
| --- | --- | --- |
| 400 | Malformed request | Check your JSON and parameters |
| 401 | Token missing, invalid or revoked | Send the user through sign-in again |
| 403 | Not permitted | Your token is missing a scope, or the endpoint is not open to third-party apps |
| 404 | No such endpoint or resource | Check the URL |
| 405 | Wrong HTTP method | See the Allow header |
| 409 | Conflict, for example a username already taken | Show the message to the user |
| 413 / 415 | Upload too large, or the wrong type | Resize or convert the image |
| 422 | Validation failed | Read error for the details |
| 429 | Rate limited | Wait for the number of seconds in Retry-After |
| `unmet_authentication_requirements` | Returned to your redirect URI: the user cannot reach the level you asked for | [Assurance and step-up](https://gate.haus/developers/docs#assurance) |
| 5xx | Our problem | Retry with back-off; check the health endpoint |

## Rate limits

Going over a limit returns **429** with a `Retry-After` header in seconds. Normal integrations stay well inside them; if you see 429s you are probably running the sign-in flow where you should be reusing a stored token.

| Action | Limit |
| --- | --- |
| Token exchange | 60 per IP per 5 minutes |
| Notifications sent with a user’s token | 120 per app per hour |
| Server-to-server notifications | 60 per IP per hour |

## App directory and owners

**Directory.** Gate.haus users can browse listed apps on their Apps page. New apps start *unlisted*. Turn on *Show in the app directory* in your app’s settings when you are ready; sign-in works the same either way.

**Owners.** An app can have several owners, who all have the same powers: edit it, issue a new secret, manage owners and delete it. Add someone by their username or email address from *Manage*. They need a passkey or two-factor authentication on their account. Every app keeps at least one owner.

**App limits.** Standard accounts can own 10 apps and Extended accounts 20; Trusted accounts have no limit. Apps you co-own count towards your limit. [Contact support](https://gate.haus/support) if you need more.

**Review.** New apps go live straight away and Gate.haus reviews them shortly afterwards. Gate.haus can suspend an app that misuses the platform, which stops it signing anyone in.

## Gate.haus Start widgets

**Gate.haus Start** is Gate.haus’s new tab page for Chrome, Edge and other Chromium browsers. Your app can put live information on it: friends online, today’s numbers, upcoming bookings, a line of news or a rail of stories. People can add your widgets once they have signed in to your app with Gate.haus and while they still have access; removing your app from their Apps page removes its widgets too.

The browser never talks to your app. When someone opens a new tab, `api.gate.haus` asks your server for that person’s data, checks and trims the response, caches it and passes it to Start. You never see the person’s IP address, and nothing is shared that you do not already know from their sign-in.

### Registering a widget

1.  Open your app on the [Developers](https://gate.haus/developers) page, choose *Manage* and then *Add widget* under *Start widgets*. An app can have up to 10.
2.  Give it a **key** (2 to 40 lower-case letters, numbers and hyphens, unique in your app, sent to you as `widget_id`), a name and description, a [template](https://gate.haus/developers/docs#start-templates), the sizes it supports (`mini`, `wide` or both; stories have no size), your **data URL** and how often to refresh (30 to 3600 seconds, default 300, stories 60).
3.  Use *Test* to fetch it as yourself. It shows the HTTP status, how long it took, any warnings and exactly what Start would receive.
4.  Gate.haus reviews each widget before people can add it. Its status is *In review* until then, and *Live* after. A widget can also be *Rejected* (with a note on what to change) or *Disabled*; neither is ever fetched. Changing a live widget’s data URL or template sends it back for review; changing its name or description does not.

### The request Gate.haus sends

```
POST {data_url}
Authorization: Bearer gh_wt_3f1c…
Content-Type: application/json
Accept: application/json
User-Agent: Gate.haus-Start/1.0 (+https://gate.haus/developers/docs)
Gatehaus-Widget: friends-online
Gatehaus-Request-Id: req_9b2e…

{
  "event": "widget.fetch",
  "widget_id": "friends-online",
  "locale": "en-GB",
  "timezone": "Europe/London",
  "requested_at": "2026-11-13T09:12:00Z"
}
```

The body never says who the person is. The `gh_wt_` token does: it lasts 5 minutes, is issued to your app and covers one person and one widget. **Introspect it** with your app’s secret (a server-side app’s client secret, or a browser or mobile app’s optional server secret from *Manage*):

```
POST https://api.gate.haus/v2/auth/introspect.php
Authorization: Basic base64(client_id:client_secret)
Content-Type: application/x-www-form-urlencoded

token=gh_wt_3f1c…
```

**Response**

```
{
  "active": true,
  "token_type": "Bearer",
  "client_id": "yourapp",
  "sub": "987",
  "scope": "start.widget",
  "widget_id": "friends-online",
  "gatehaus_use": "start_widget",
  "iat": 1794560000,
  "exp": 1794560300
}
```

Before answering, check that:

-   `active` is `true`,
-   `client_id` is your own app,
-   `scope` is exactly `start.widget`,
-   `widget_id` matches the widget being asked for (and the `Gatehaus-Widget` header).

Then use `sub`, the person’s Gate.haus user ID, to look them up. Widget tokens only work for this: `/v2/user/me` and every other endpoint reject them, and introspection only describes them to the app they were issued to.

### Responding

| Rule | Detail |
| --- | --- |
| Data URL | `https://` on port 443 with a public hostname. Private, loopback, link-local and reserved addresses are refused. No cookies are sent and **redirects are not followed**. |
| Time and size | 5 second timeout, 64 KB maximum, `Content-Type: application/json`. |
| 200 with JSON | Rendered with your template. |
| `204` or `{"hidden": true}` | Nothing is shown for this person, for example when they have no account in your app. |
| 401 or 403 | Treated as hidden. |
| Anything else | Any other status, invalid JSON or a timeout shows the widget as unavailable. The last good data is kept for up to an hour. |
| Caching | Each person’s data is cached for your refresh time. Send `refresh_after` (seconds, at least 30) to ask for a sooner refresh. Each widget is fetched at most once every 30 seconds per person, and Start only refreshes while the tab is visible. |

All text is plain text (no HTML), trimmed and cut to the lengths below. URLs must be `https://` (links may also be `http://`); anything else is dropped. Unknown fields are ignored.

### Templates

Every template accepts these fields at the top level:

| Field | Type | Notes |
| --- | --- | --- |
| `template` | string | Optional. If present it must equal the registered template. |
| `title` | string, 40 | Replaces the widget name in the header. |
| `icon` | Icon | Header icon. See [Icons](https://gate.haus/developers/docs#start-icons). |
| `link` | `{url, label}` | A header or footer action such as “See more”. `label` up to 20. |
| `refresh_after` | integer | Seconds, at least 30. A hint. |
| `empty` | string, 80 | Shown when there are no rows. |
| `hidden` | boolean | `true` hides the widget for this person. |

**`list`** (mini, wide). A title, then rows with an icon, up to two lines of text and a link. `items` up to 20 (mini shows 4, wide 5); `title` 60, `subtitle` 120 (one line each), `trailing` 12 (short text on the right instead of a status dot).

```
{
  "title": "Friends Online",
  "icon": "people",
  "link": { "url": "https://yourapp.example/friends", "label": "See more" },
  "items": [
    { "id": "u1", "icon": "gamepad", "title": "James", "subtitle": "Playing Fortnite",
      "status": "online", "url": "https://yourapp.example/u/james" },
    { "id": "u2", "icon": "person", "title": "Ethan", "subtitle": "Online",
      "status": "online", "trailing": "2m" }
  ]
}
```

**`stat`** (mini, wide). `stats` up to 4 (mini shows 2, wide 3); `value` 16, `label` 40, `change` 12, `trend` `up`, `down` or `flat`, `series` up to 30 numbers for a sparkline.

```
{
  "title": "Today",
  "stats": [
    { "label": "Revenue", "value": "£1,240", "change": "+12%", "trend": "up",
      "series": [3, 5, 4, 8, 7, 9], "url": "https://yourapp.example/reports" }
  ]
}
```

**`progress`** (mini, wide). `items` up to 6 (mini shows 3, wide 4); `value` from 0 to 1.

```
{
  "title": "Goals",
  "items": [
    { "label": "Steps", "value": 0.64, "display": "6,400 of 10,000", "icon": "fire",
      "url": "https://yourapp.example/goals" }
  ]
}
```

**`agenda`** (mini, wide). `events` up to 20, with ISO 8601 times. Start shows them in the person’s time zone, grouped Today, Tomorrow and then by date, and drops events that have ended. Mini shows 4, wide 5.

```
{
  "title": "Bookings",
  "events": [
    { "title": "Haircut", "starts_at": "2026-11-13T15:00:00Z", "ends_at": "2026-11-13T15:30:00Z",
      "all_day": false, "location": "High Street", "icon": "calendar", "colour": "#0099cc",
      "url": "https://yourapp.example/bookings/42" }
  ]
}
```

**`message`** (mini, wide). One line of news with up to two buttons. `text` 120, `detail` 120, `actions` up to 2.

```
{
  "message": { "icon": "camera", "text": "Two unopened messages from Archer & Ben",
               "detail": "Latest 4 minutes ago", "url": "https://yourapp.example/" },
  "actions": [ { "label": "Open", "url": "https://yourapp.example/" } ]
}
```

**`stories`** (story rail only). See [Stories](https://gate.haus/developers/docs#start-stories).

### Icons and status

An icon is a string or an object:

-   a built-in symbol: `person`, `people`, `gamepad`, `music`, `video`, `camera`, `photo`, `chat`, `bell`, `calendar`, `clock`, `star`, `heart`, `trophy`, `fire`, `check`, `alert`, `info`, `mail`, `phone`, `cart`, `bag`, `money`, `chart`, `document`, `folder`, `link`, `location`, `home`, `car`, `globe`, `code`, `settings`, `lock`, `gift`, `sparkle`, `play`, `ticket`, `book`, `weather`, `headphones` or `mic`. Unknown symbols fall back to `sparkle`.
-   an `https://` image URL, shown as a rounded square, or `{"image": "https://…", "shape": "circle"}` for a circle,
-   one or two characters, such as an emoji or initials: `{"text": "JB", "colour": "#26b47f"}`.

`status` is `online` (green), `away` (amber), `busy` (red) or `offline` (grey). Leave it out for no dot.

### Stories

Story widgets fill the rail on the left. Start merges every story app the person has added into one rail: people with unseen stories first (newest first), then by when they were last active. Each avatar carries its app’s badge.

```
{
  "viewed_url": "https://api.yourapp.example/start/viewed",
  "people": [
    { "id": "42", "name": "Archer", "avatar_url": "https://cdn.yourapp.example/a.jpg",
      "last_active_at": "2026-11-13T09:10:00Z", "url": "https://yourapp.example/u/archer" }
  ],
  "stories": [
    { "id": "story_123", "author_id": "42", "media_url": "https://cdn.yourapp.example/s.jpg",
      "media_type": "image", "duration": 5, "created_at": "2026-11-13T08:00:00Z",
      "expires_at": "2026-11-14T08:00:00Z", "viewed": false, "caption": "Sunrise" }
  ]
}
```

-   `people` up to 50: `id` (your own ID for that person), `name` 40, `avatar_url`, optional `last_active_at` and `url`. The activity dot is green up to 2 minutes, amber under 2 hours, grey under 24 hours and absent after that. People with no stories still appear, so the rail also works as “last active”.
-   `stories` up to 100: `id` (up to 100 characters), `author_id` (must match a person), `media_url`, `media_type` `image` or `video`, `duration` in seconds (1 to 60; images default to 5, videos to their length up to 60), `expires_at` (expired stories are dropped), and optionally `created_at`, `viewed`, `caption` (200) and `url`.
-   Media must be `https://`. Start loads it straight from your host.
-   `viewed_url` is optional and must have the **same origin** as your data URL, or it is ignored.

When the person has watched a story (shown for its full duration, or skipped after at least a second), Gate.haus checks the story was in their data and sends a `story.viewed` event to your `viewed_url`, once per person and story:

```
POST {viewed_url}
Authorization: Bearer gh_wt_…
Content-Type: application/json
Gatehaus-Event: story.viewed
Gatehaus-Event-Id: evt_abc123

{
  "event_id": "evt_abc123",
  "event": "story.viewed",
  "widget_id": "friends-stories",
  "story_id": "story_123",
  "viewer_user_id": "987",
  "viewed_at": "2026-11-12T21:45:00Z"
}
```

Introspect the token as for a fetch, and also check that **`sub` equals `viewer_user_id`** before marking the story as seen. `event_id` is unique, so treat a repeat as already handled. Gate.haus tries once with a 5 second timeout; any 2xx counts as success.

## Sign-in buttons

Use the official button so people recognise it. The HTML and CSS version is recommended: it is a real link, scales with your page and works with the keyboard. Variants are `--dark`, `--light` and `--green`; add `--block` to fill the width or `--icon` for the square icon button.

[![Sign in with Gate.haus, signin dark](https://gate.haus/brand/buttons/gatehaus-signin-dark.svg)](https://gate.haus/brand/buttons/gatehaus-signin-dark.svg "gatehaus-signin-dark.svg")[![Sign in with Gate.haus, signin light](https://gate.haus/brand/buttons/gatehaus-signin-light.svg)](https://gate.haus/brand/buttons/gatehaus-signin-light.svg "gatehaus-signin-light.svg")[![Sign in with Gate.haus, signin green](https://gate.haus/brand/buttons/gatehaus-signin-green.svg)](https://gate.haus/brand/buttons/gatehaus-signin-green.svg "gatehaus-signin-green.svg")[![Sign in with Gate.haus, continue dark](https://gate.haus/brand/buttons/gatehaus-continue-dark.svg)](https://gate.haus/brand/buttons/gatehaus-continue-dark.svg "gatehaus-continue-dark.svg")[![Sign in with Gate.haus, icon green](https://gate.haus/brand/buttons/gatehaus-icon-green.svg)](https://gate.haus/brand/buttons/gatehaus-icon-green.svg "gatehaus-icon-green.svg")

**HTML**

```
<link rel="stylesheet" href="https://gate.haus/brand/buttons/gatehaus-button.css">
<a class="gatehaus-btn gatehaus-btn--dark" href="YOUR_AUTHORISE_URL">
  <svg class="gatehaus-btn__mark" viewBox="10 4 44 54" aria-hidden="true">
    <path fill-rule="evenodd" d="M32 4l22 8v18c0 13.2-9.4 24.6-22 28-12.6-3.4-22-14.8-22-28V12zM32 22a7 7 0 0 0-3.4 13.1L26.5 46h11l-2.1-10.9A7 7 0 0 0 32 22z"/>
  </svg>
  Sign in with Gate.haus
</a>
```

Images: `/brand/buttons/gatehaus-{signin,continue,signup,icon}-{dark,light,green}.svg`, with 2× PNGs in `/brand/buttons/png/`. Use *light* on dark or busy backgrounds and *dark* or *green* on light ones, keep the button at least 40 px tall, and do not change the wording. [Download the CSS](https://gate.haus/brand/buttons/gatehaus-button.css)

## Security checklist

-   Check state on every callback against the value you stored.
-   Use PKCE for browser and mobile apps, and preferably for server apps too.
-   Keep the client secret on your server: never in JavaScript, an app binary or a repository.
-   Store tokens where other code cannot read them: the Keychain or Keystore, or an httpOnly cookie.
-   Handle 401 by signing the user in again, not by retrying the same token.
-   Never retry a token exchange with a code that has already been used.
-   Call logout when the user signs out of your app.
-   Open sign-in in the system browser on mobile, never an embedded web view.
-   Ask for the fewest scopes your app needs.
-   If a secret leaks, issue a new one from Manage straight away; the old one stops working immediately.

Questions, or need a custom URL scheme or server-to-server notifications turned on? [Contact support](https://gate.haus/support).
