Unprofane

Raw HTTP username check in one POST

One POST from whatever you already have.

Your sign-up formExample

Profile

How other people see you

Username

sh1tH3ad_69

Pick a different username.

Profile

How other people see you

Username

admin

That name is reserved.

Profile

How other people see you

Username

river_otter

Saved

Unprofane
blockleetspeak
usernameProblem
"Pick a different username."
Unprofane
blockreserved
usernameProblem
"That name is reserved."
Unprofane
allow
usernameProblem
null
Try a name

Live in four steps

Build with a test key, 100 checks a month; switch to a live key when you ship.

  1. Before you start

    • A server, a function or a backend route that can make an HTTPS request.

      The code is in every language the tabs show.

    • An Unprofane key from the keys page of the dashboard: a test key (up_test_…) to build with, a live key (up_live_…) in production.

  2. Store the key

    • Keep the key in the server’s environment as UNPROFANE_API_KEY and send it as Authorization: Bearer ….

      Never put a secret key in a page or an app: the API refuses one sent from a browser.

  3. Where the file goes

    • Wherever your server saves a username: the route, the controller or the service that writes it.

      Put usernameProblem beside it, in a file such as username-check.ts, call it first and save only when it allows the name.

    import { Unprofane } from '@unprofane/sdk';
    
    let unprofane: Unprofane | undefined;
    
    /** Returns the reason a username cannot be shown, or null when it can. Throws when Unprofane cannot answer. */
    export async function usernameProblem(username: string): Promise<string | null> {
      unprofane ??= new Unprofane(process.env.UNPROFANE_API_KEY!, { timeoutMs: 3_000, retries: 1 });
      const r = await unprofane.check({ text: username, context: 'username', policy: 'teen' });
      if (r.allowed) return null;
      return r.matches[0]?.category === 'reserved'
        ? 'That name is reserved.'
        : 'Pick a different username.';
    }
    1. Line 6One function: the reason a name cannot be shown, or null when it can.
    2. Line 7A form waits on this, so it gives up after three seconds and one retry.
    3. Line 8Read as a handle: glued words are split, leetspeak and look-alike letters are read, and the name is tried backwards too. The teen policy lets mild words through and turns the rest away; pick the one for your audience.
    4. Line 11admin, support and your own brand come back reserved, so the person reads taken, not rude.

    Complete as printed: it reads the key from the environment. Every name goes with context: "username" and the teen policy.

    The same request in 8 more languages:

    curl https://api.unprofane.com/v1/check \
      -H "Authorization: Bearer up_live_YOUR_KEY" \
      -H "Content-Type: application/json" \
      -d '{"text":"sh1tH3ad_69","context":"username","policy":"teen"}'
  4. Check that it works

    • With a test key, run the cURL tab as printed: sh1tH3ad_69 comes back with "allowed": false and "action": "block".

    • Change the text to admin: refused, with matches[0].category set to reserved.

      Change it to river_otter: allowed.

    What the run sends, and what comes back@unprofane/sdk 0.1.2Node 24

    1. sh1tH3ad_69"Pick a different username."
    2. admin"That name is reserved."
    3. river_otternull
    4. Unprofane unreachablethrows

It reads the name, not a list

Six usernames a word list gets wrong, and what this check answered.

  1. sh1tH3ad_69

    Digits for letters

    Misses it

    blockreads shitheadleetspeak
  2. ilovesh1t

    Words run together

    Misses it

    blockreads shitleetspeakconcatenation
  3. tihs_xX

    Written backwards

    Misses it

    blockreads shitreversed
  4. admin

    Not rude: a claim to be staff

    Passes it

    blockreserved
  5. Dickinson

    A poet’s surname

    Blocks it

    allow
  6. therapist_jo

    A job

    Blocks it

    allow
Out of 6

4 let through2 innocent blocked

4 turned away2 innocent let through

76.5%

Unprofane

Balanced mode, as the recipes run it

32.5%

Perspective API

Set to flag as much clean text as Unprofane

Toxic usernames caught. Held-back judged test set, run of .How it was measured

How it behaves in production

When it runs, what it does with each answer, and what usually goes wrong.

When the check runs
  1. Typed
  2. Unprofane checks
  3. Saved
  4. Shown to others

Before the write, in the same request: you call it, and you decide whether to save.

Allow, review and block
allow
Goes through
review
Turned away, like a block
block
Turned away

allowed is true only when action is allow. The recipes turn away review as well as block: a username has no moderator queue, and asking for another name costs the person a few seconds. To accept a name held for review and look at it later, test action !== "block" instead and keep the user id where a person will read it. A name that claims to be the platform or its staff, such as admin, comes back with matches[0].category set to reserved, and the code says so in its own words.

Every field of the answer is in the API reference.

When Unprofane does not answer

The TypeScript code gives up after the timeoutMs and the one retry set in it, and usernameProblem throws. Catch it where you save: refuse the save and ask the person to try again, or save and check later. The other languages raise their own errors on a network failure; check the status before you read the body.

How this recipe is run on every change

The TypeScript usernameProblem is typechecked and run with the three names below, and once with Unprofane unreachable. cURL, JavaScript, Python and Ruby run against the API on every change, Go and PHP where the CI machine has them. C# and GDScript are checked for their shape only.

403: secret keys cannot be used from a browser

The call came from a page. Make it from your server, or use a publishable key for a live hint in the page.

400: the request body is not valid

Send JSON with text of at least one character. The answer’s detail names the field.

401: no valid API key

The key is not where the code reads it, or it was revoked. Set it again and deploy again.

402: a plan is required

A live or publishable key needs a plan. Build with a test key (up_test_…), which needs none.

429: too many requests

A test key’s free checks are capped across the account, a month’s with no plan and a day’s on one, and every plan has a per-minute limit. The answer’s type says which.

Every error, and what to send instead, is on the errors page.

The same check, elsewhere

Each recipe is a complete file, run the same way.

Run this recipe with your API key

Paste the file, set the key, and send it sh1tH3ad_69, admin and river_otter.

Get your API key