# Create an app for Sign in with hematite

How to register an app for Sign in with hematite: its two types, PKCE, exact return addresses, scopes, its secret, what people see, and the limits.

An app that people sign in to with their hematite account needs a **client id**: what it sends with every [sign-in request](https://hematite.gg/docs/developers/oauth), so hematite knows which app is asking and where it may send people back. Anyone with an account can register one, in [Settings → Developers](https://hematite.gg/settings/developers).

## Register it

1. **Confirm your email address**, if you haven't: hematite needs one from everyone who makes an app.
2. **Open [Settings → Developers](https://hematite.gg/settings/developers)** and press **Create app**.
3. **Name it**, as people will see it when it asks for their account.
4. **Say where it runs:** in a browser or on a phone, or on a server ([the two types](#two-types-of-app)).
5. **Add its return addresses**, where people come back after they allow it ([the rules](#return-addresses)).
6. **Copy what it shows you:** the client id, and for an app on a server its secret, which is shown only then.

Creating it, you agree that it follows hematite's [terms](https://hematite.gg/tos#terms-for-apps), says truly what it is and asks only for what it uses; that what it gets from people is yours to look after, and you answer for it, not hematite; and that hematite can switch off an app that breaks these.

## Two types of app

| Where it runs                                                                              | Its type       | How it proves itself                                                                                                                                                                          |
| ------------------------------------------------------------------------------------------ | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| In a browser or on a phone: a single-page app, a phone or desktop app, a browser extension | `public`       | PKCE alone. It has no secret: anything shipped to people's devices can be read out of them                                                                                                    |
| On a server: a website's backend, a bot                                                    | `confidential` | PKCE and its secret, sent with every request to [`POST /oauth/token`](https://hematite.gg/docs/developers/reference/oauth#post-oauth-token) and [`POST /oauth/revoke`](https://hematite.gg/docs/developers/reference/oauth#post-oauth-revoke) |

An app's type stays as it was made. For the other, create another app: an app with a browser front and a server behind it is often two.

## PKCE, always

Every app, public or confidential, sends a PKCE challenge with its sign-in request and the verifier with the code, `S256` only. A secret doesn't replace it: it proves the code is traded by the same app that asked for it. [The flow](https://hematite.gg/docs/developers/oauth#the-flow) has it step by step.

## Return addresses

The address in `redirect_uri` has to be one the app registered, **character for character**: another path, port, query or a trailing slash is another address, and hematite sends nobody there.

- **`https://` only.** `http://` works for `localhost` and `127.0.0.1` alone, for development, with the port you use: `http://localhost:5173/callback` and `http://localhost:3000/callback` are two addresses.
- **No `#fragment`:** the code comes back in the query. **No user name or password** in it.
- **One to ten addresses** an app, each up to 512 characters: one for each place it runs, local development included.
- **A phone app** comes back on an `https://` address it opens itself (iOS's universal links, Android's app links); a custom scheme (`pixelvault:/callback`) isn't taken. A desktop app can listen on `127.0.0.1`.
- **Taking one out** takes effect at once: a request that asks for it is refused, and nobody is sent there.

```text label="Return addresses for one app"
https://pixelvault.example/callback
http://localhost:5173/callback
```

## Scopes

An app doesn't register its scopes: it asks for them in each sign-in request, and the person sees each in words before they allow it. Ask for what the app uses and nothing more. [The scopes](https://hematite.gg/docs/developers/oauth#scopes) lists them all; each endpoint in the [API reference](https://hematite.gg/docs/developers/reference/images) says the one it needs.

## Its secret

An app on a server gets a secret when it's made (`hma_live_…`), shown that once: hematite keeps only a keyed fingerprint of it, so it can't show it again. Keep it on your server and nowhere else, never in a browser or a phone app. Send it with HTTP Basic (the client id and the secret) or as `client_secret` in the body:

```bash
curl -X POST https://api.hematite.gg/v1/oauth/token \
  -u "$CLIENT_ID:$CLIENT_SECRET" \
  --data-urlencode "grant_type=authorization_code" \
  --data-urlencode "code=$CODE" \
  --data-urlencode "redirect_uri=https://pixelvault.example/callback" \
  --data-urlencode "code_verifier=$CODE_VERIFIER"
```

**Lost it, or it got out?** Its row's **⋯ → Make a new secret** replaces it, once you've held the button to the end. Secrets made before 2026-11-18 were wiped with every other token when hematite's tokens changed: an app from before has none until you make one the same way. The old one stops working at once; nobody is signed out. Put the new one where the old one was before the app next asks for tokens: its next refresh needs it.

## What people see

When your app asks for their account, the consent page says its name, that **you** made it ("By nova, not made by hematite"), the account it would act as, what it may do in words, and where it sends them back, by the address's host. They choose Deny or Allow.

Once allowed, it's one of their **connected apps** in Settings → Security, with who made it ("By nova, not made by hematite"), what it may do and when it was last used. They can disconnect it whenever they like: its tokens stop at once. A new name shows on both at once. In Settings → Developers, each app's row says how many people have it connected.

## Limits

- **Five apps** an account.
- **A name of 2 to 40 characters,** never "hematite" or anything that reads as it: case, spacing, accents and look-alike letters don't count (`Hema-tite`, `H3MAT1TE` and a Cyrillic `е` are all "hematite"). Nor a name kept for hematite as a whole: Support, Admin, Official, Staff and a few more.
- **Registering takes 10 a minute,** and so does making a new secret.
- **An app's own token can't register or change apps,** whatever its scopes: only you, signed in to hematite.

## Deleting an app

Its row's **⋯ → Delete**, asked first, and typing its name when people have it connected. Everyone who connected it is disconnected at once: every token it holds stops working, and its client id is known no more. That can't be undone.

## With the API

The same, with your own sign-in rather than an app's token: [`GET /users/:userId/apps`](https://hematite.gg/docs/developers/reference/users#get-users-userid-apps) lists your apps, and the [Apps API](https://hematite.gg/docs/developers/reference/apps) registers one, renames it or changes its addresses, makes a new secret and deletes it. In the SDK, `hematite.apps` and `user.apps`.
