For the complete documentation index, see llms.txt. This page is also available as Markdown.

SmartURLs

Run a SmartURLs redirect domain with the official Go or PHP client, including redirect handling, JavaScript verification, reverse proxy setup, and security requirements.

SmartURLs lets you run short, trackable redirect URLs that can apply STOPBOT visitor analysis before sending a visitor to the final destination.

Use this guide when you want to host your own SmartURLs redirect domain, for example:

https://links.example.com/swWV8j

The public visitor URL uses your own domain and the SmartURLs keyname. Your server-side SmartURLs client then sends the visitor context to STOPBOT V2.

Use one of the official SmartURLs V2 clients:

Client
Recommended for
Repository

Go client

Production servers, VPS, reverse proxy deployments, high traffic redirect domains

PHP client

Shared hosting, Apache/PHP hosting, existing PHP environments

The Go client is recommended for most production deployments.

Endpoint Used By The Clients

Both clients call:

GET https://api.stopbot.net/services/shorterlink

You normally do not need to call this endpoint directly from frontend code. Keep the STOPBOT API key on your server.

How SmartURLs Works

  1. Create a SmartURLs keyname in the STOPBOT panel.

  2. Deploy the Go or PHP SmartURLs client on your redirect domain.

  3. A visitor opens https://your-domain.example/{keyname}.

  4. The client sends the visitor IP, user agent, URL, and keyname to STOPBOT V2.

  5. STOPBOT returns a redirect decision.

  6. The client redirects the visitor, shows a local error page, or runs JavaScript browser verification first.

Create A SmartURLs Keyname

  1. Sign in to panel.stopbot.net.

  2. Open the SmartURLs or Shortlink section.

  3. Create a new SmartURLs key, or open an existing one.

  4. Configure the destination URL and protection rules.

  5. Copy the SmartURLs keyname.

If the panel shows:

the keyname is:

Your public visitor URL becomes:

Allowed keyname characters:

The maximum length is 64 characters.

Go Client Setup

Clone the Go client:

Copy the environment example:

Configure .env:

SMARTURLS_SIGNING_KEY is a private local secret used to protect browser verification tokens. It is not your STOPBOT API key and does not need to be configured in the STOPBOT panel.

Recommended signing key characters:

Use at least 32 characters. Avoid spaces and quotes.

Build and run:

On Windows:

The Go binary embeds the local message template. Rebuild the binary after editing template/message.html.

Go Client With Nginx

Nginx is the recommended reverse proxy for the Go client.

Example Nginx server block:

Use:

only when the Go application is always behind a trusted reverse proxy and cannot be accessed directly from the internet.

PHP Client Setup

Clone or download the PHP client:

Upload the PHP client files to your SmartURLs domain.

Set the API key through an environment variable:

Or create config.local.php next to config.php:

Do not commit config.local.php.

Apache

The PHP client includes .htaccess rules. A request like:

is routed internally to:

Nginx

Nginx does not read .htaccess, so add a rewrite rule:

Adjust root and fastcgi_pass for your server.

Redirect Decision Handling

The SmartURLs clients handle common STOPBOT redirect decisions:

API value
Client behavior

valid redirectTo URL

Redirects the visitor

STOPBOTNET 403

Shows the local 403 message page

STOPBOTNET 404

Shows the local 404 message page

empty redirectTo

Shows the local 404 message page

SERVER NOT RESPOND

Shows the local 503 message page

invalid redirect value

Shows the local 502 message page

The local message page is included in the client template and can be customized.

The final redirect action must come from blockAccess and redirectTo, not from isBot. isBot is only a visitor classification signal. A SmartURLs visitor can be human/non-bot and still receive the blocked redirect when your keyname configuration blocks that request.

Example country restriction response:

JavaScript Verification Flow

When JavaScript verification is enabled for a SmartURLs keyname, STOPBOT V2 returns:

The current Go and PHP clients do not expose the API key to the browser. They create a local signed token and render a browser check page.

The browser calls the local client:

The server verifies the local token, then calls STOPBOT V2 with:

Example API verification request:

Successful verification response:

After verification succeeds, the client redirects the visitor to the destination URL.

Important Security Notes

  • Keep the STOPBOT API key on the server.

  • Do not place the API key in browser JavaScript.

  • Do not commit .env or config.local.php.

  • Use a long random signing key for browser verification tokens.

  • Enable proxy header trust only behind a trusted reverse proxy.

  • Make sure the API key belongs to the same STOPBOT account that owns the SmartURLs keyname.

Test Checklist

  • Open https://your-domain.example/{keyname}.

  • Confirm the visitor reaches the expected destination URL.

  • Confirm blocked traffic shows the local message page or follows the configured redirect behavior.

  • If JavaScript verification is enabled, confirm /rsc/rjs.json?token=... returns a successful verification response.

  • Check SmartURLs statistics in the STOPBOT panel.

  • Confirm the API key is not visible in browser page source or network calls.

V1 Difference

Legacy SmartURLs V1 used keyname-based JavaScript tracking.

Current SmartURLs V2 uses a uniqueCode verification flow:

Use the current Go or PHP V2 client for new integrations.

Last updated