Profanity filtering users can't bypass.
One POST from whatever you already have.
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
usernameProblemusernameProblemusernameProblemBuild with a test key, 100 checks a month; switch to a live key when you ship.
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.
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.
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.';
}admin, 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"}'const res = await fetch('https://api.unprofane.com/v1/check', {
method: 'POST',
headers: { Authorization: 'Bearer up_live_YOUR_KEY', 'Content-Type': 'application/json' },
body: JSON.stringify({ text: 'sh1tH3ad_69', context: 'username', policy: 'teen' }),
});
const result = await res.json();
if (!result.allowed) console.log(result.action, result.evasion, result.censored);import httpx
r = httpx.post(
"https://api.unprofane.com/v1/check",
headers={"Authorization": "Bearer up_live_YOUR_KEY"},
json={"text": "sh1tH3ad_69", "context": "username", "policy": "teen"},
timeout=5.0,
)
result = r.json()
if not result["allowed"]:
print(result["action"], result["evasion"], result["censored"])req, _ := http.NewRequest("POST", "https://api.unprofane.com/v1/check",
strings.NewReader(`{"text":"sh1tH3ad_69","context":"username","policy":"teen"}`))
req.Header.Set("Authorization", "Bearer up_live_YOUR_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)$res = file_get_contents('https://api.unprofane.com/v1/check', false, stream_context_create(['http' => [
'method' => 'POST',
'header' => "Authorization: Bearer up_live_YOUR_KEY\r\nContent-Type: application/json\r\n",
'content' => json_encode(['text' => 'sh1tH3ad_69', 'context' => 'username', 'policy' => 'teen']),
]]));
$result = json_decode($res, true);require 'net/http'; require 'json'
uri = URI('https://api.unprofane.com/v1/check')
res = Net::HTTP.post(uri, { text: 'sh1tH3ad_69', context: 'username', policy: 'teen' }.to_json,
'Authorization' => 'Bearer up_live_YOUR_KEY', 'Content-Type' => 'application/json')
result = JSON.parse(res.body)using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "up_live_YOUR_KEY");
var res = await http.PostAsJsonAsync("https://api.unprofane.com/v1/check",
new { text = "sh1tH3ad_69", context = "username", policy = "teen" });
var result = await res.Content.ReadFromJsonAsync<JsonElement>();
bool allowed = result.GetProperty("allowed").GetBoolean();var http := HTTPRequest.new()
add_child(http)
http.request_completed.connect(func(_r, _code, _h, body):
var result = JSON.parse_string(body.get_string_from_utf8())
print(result["allowed"], result["action"]))
http.request("https://api.unprofane.com/v1/check", PackedStringArray([
"Authorization: Bearer up_live_YOUR_KEY", "Content-Type: application/json"]),
HTTPClient.METHOD_POST, JSON.stringify({"text": "sh1tH3ad_69", "context": "username", "policy": "teen"}))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
Six usernames a word list gets wrong, and what this check answered.
sh1tH3ad_69
Digits for letters
Misses it
ilovesh1t
Words run together
Misses it
tihs_xX
Written backwards
Misses it
admin
Not rude: a claim to be staff
Passes it
Dickinson
A poet’s surname
Blocks it
therapist_jo
A job
Blocks it
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
When it runs, what it does with each answer, and what usually goes wrong.
Before the write, in the same request: you call it, and you decide whether to save.
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.
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.
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 browserThe 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 validSend JSON with text of at least one character. The answer’s detail names the field.
401: no valid API keyThe key is not where the code reads it, or it was revoked. Set it again and deploy again.
402: a plan is requiredA live or publishable key needs a plan. Build with a test key (up_test_…), which needs none.
429: too many requestsA 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.
Each recipe is a complete file, run the same way.
Paste the file, set the key, and send it sh1tH3ad_69, admin and river_otter.