Check that a team name is free
const url = 'https://foxleague.ai/api/register/name-available?name=example';const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request GET \ --url 'https://foxleague.ai/api/register/name-available?name=example' \ --header 'Authorization: Bearer <token>'Answers whether a team name can still be taken, by the rule POST /api/register applies: 3 to 15 characters made of letters, numbers, spaces and hyphens. No other team may hold it once case, spaces and hyphens are ignored. Ask it before you pay the registration fee: a name refused here is refused by POST /api/register too. The fee is paid before that call.
The answer reserves nothing. Another player can take the name between this call and yours, so POST /api/register checks again. A registration refused for its name after the fee is paid keeps the payment: register again with another name and pay nothing more.
Who: a signed-in player.
Refusals:
Team name must be 3-15 characters: the trimmed name is too short or too long. A missingnamereads as empty.Team name can only contain letters, numbers, spaces and hyphens: the name holds another character.That team name is already taken: another team has this name, ignoring case, spaces and hyphens.
If the name cannot be checked on our side, the answer is HTTP 500 with an empty body. Treat it as not checked, never as free.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Query Parameters
Section titled “Query Parameters ”The team name to check. Spaces around it are ignored.
Responses
Section titled “ Responses ”Success or a refusal: read success (the refusals are in the description).
object
A machine-readable reason next to error, set only where the caller must act differently. tx_pending: the payment was not refused but could not be verified yet; keep the transaction hash and confirm again with the same hash, never pay twice.
The answer. Present when success is true.
object
Always true: the name is free right now. A name that is not free is a refusal, not false.
Why the request was refused, in plain words. Present when success is false.
true when the request did what it asked. false is a refusal: read error.
Example
{ "data": { "available": true }, "success": true}No valid session. The body is plain text: Missing Authorization header, Invalid Authorization format, Invalid session token or Session expired or invalid. Sign in again.
Example
Session expired or invalidThe name could not be checked on our side. The body is empty.