Skip to main content

Overview

This tutorial walks through implementing Fingerprint to prevent AI token abuse, where people create many accounts, or delete and recreate them, to claim free credits again and again. It’s a common problem for AI products with free tiers, where every free credit pays for real inference. You’ll begin with a starter app that includes a mock AI assistant sign-up page that grants 1,000 free credits to every new account. From there, you’ll add the JavaScript agent to identify each visitor and use server-side logic with Fingerprint data to grant free credits only once per device. New accounts are still created, so people aren’t locked out, but a device that has already received free credits won’t get them again. Each account also stores the visitor ID, so your support or risk team can later link accounts created on the same device. The same device check can also run when a prompt is sent, so a daily free allowance can’t be reset by switching accounts. Fraudsters also get tokens through account takeover, logging in to existing accounts and spending their credits. To protect existing accounts, see the account takeover tutorial. By the end, you’ll have a sample app that limits free credits to one grant per device and can be adapted to fit your own free tier and business logic. This tutorial uses just plain JavaScript and a Node server with SQLite on the backend. For language- or framework-specific setups, see the quickstarts.
Estimated time: < 15 minutes

Prerequisites

Before you begin, make sure you have the following:
  • A copy of the starter repository (clone with Git or download as a ZIP)
  • Node.js (v22 or later) and npm installed
  • Your favorite code editor
  • Basic knowledge of JavaScript

1. Create a Fingerprint account and get your API keys

  1. Sign up for a free Fingerprint trial, or log in if you already have an account.
  2. After signing in, go to the API keys page in the dashboard.
  3. Save your public API key, which you’ll use to initialize the JavaScript agent.
  4. Create and securely store a server API key for your server. Never expose it on the client side. You’ll use this key on the backend to retrieve full visitor information through the Fingerprint Server API.

2. Set up your project

  1. Clone or download the starter repository and open it in your editor.
Terminal
  1. This tutorial will be using the ai-token-abuse folder. The project is organized as follows:
public
index.html - AI assistant sign-up page
index.js - Frontend logic to handle sign-up
server
server.js - Serves static files and sign-up endpoint
db.js - SQLite database connection
accounts.js - Sign-up and free credit logic
.env.example - Example environment variables
  1. Install dependencies:
Terminal
  1. Copy or rename .env.example to .env, then add your Fingerprint API keys:
Terminal
  1. Start the server:
Terminal
  1. Visit http://localhost:3000 to view the mock AI assistant sign-up page from the starter app. Create a test account by entering a username and password and clicking Sign up. You’ll see “Account created. 1,000 free credits added.” Create a few more accounts with different usernames, then open the page in an incognito window and try again. By default, the app grants free credits to every new account, no matter how many times someone signs up on the same device.

3. Add Fingerprint to the frontend

In this step, you’ll load the JavaScript agent when the page loads and trigger identification when the user clicks Sign up. The JavaScript agent returns both a visitor_id and an event_id. Instead of relying on the visitor_id from the browser, you’ll send the event_id to your server along with the signup payload. The server will then call the Fingerprint Events API to securely retrieve the full identification details, including the verified visitor ID and risk signals such as browser tampering or bot activity.
  1. At the top of public/index.js, load the JavaScript agent:
public/index.js
  1. Make sure to change region to match your workspace region (e.g., eu for Europe, ap for Asia, us for Global (default)).
  2. Near the bottom of public/index.js, the Sign up button already has an event handler for submitting the credentials. Inside this handler, request visitor identification from Fingerprint using the get() method and include the returned event_id when sending the signup to the server:
public/index.js
Linking your own identifiers: if you already have an identifier for the user at this point, like an account, order, or session ID, pass it as linkedId. It’s returned as linked_id on the event and indexed, so you can retrieve every event tied to that identifier through the Server API. Learn more about adding more context to your identification events in Linking and tagging information.
The get() method sends signals collected from the browser to Fingerprint servers, where they are analyzed to identify the visitor. The returned event_id acts as a reference to this specific identification event, which your server can later use to fetch the full visitor details. For lower latency in production, use Sealed Client Results to return full identification details as an encrypted payload from the get() method.

4. Receive and use the event ID to get visitor insights

Next, pass the event_id through to your signup logic, install and initialize the Fingerprint Node Server SDK, and fetch the full visitor identification event so you can access the trusted visitor ID and Smart Signals.
  1. In the backend, the server/server.js file defines the API routes for the app. Update the /api/signup route there to also extract event_id from the request body and pass it into the attemptSignup function:
server/server.js
  1. Install the Fingerprint Node Server SDK:
Terminal
  1. The server/accounts.js file contains the logic for handling signups and granting free credits. Start by importing and initializing the Fingerprint Node Server SDK there, and load your environment variables with dotenv.
server/accounts.js
  1. Make sure to change region to match your workspace region (e.g., EU for Europe, AP for Asia, Global for Global (default)).
  2. Update the attemptSignup function to accept event_id and use it to fetch the full identification event details from Fingerprint:
server/accounts.js
Using the event_id, the getEvent method will retrieve the full data for the visitor identification event. The returned object will contain the visitor ID, IP address, device, and browser details, and Smart Signals like bot detection, browser tampering detection, proxy detection, and more. You can see a full example of the event structure and test it with your own device in the demo playground. For additional checks to ensure the validity of the data coming from your frontend, view how to protect from client-side tampering and replay attacks.

5. Block bots and withhold credits from suspicious devices

This optional step uses the Bot Detection Smart Signal, which is available during the free trial and on paid plans. If you skip this step, add let withholdCredits = false; to attemptSignup after fetching the event, because step 6 uses this flag.
AI token abuse is often automated, with scripts creating accounts in bulk to farm free credits. A simple but powerful way to stop this is to block bot signups entirely. The event object includes the Bot Detection Smart Signal that flags automated activity, making it easy to reject bot traffic. This signal returns good for known bots like search engines and verified AI agents, bad for automation tools, headless browsers, or other signs of automation, and not_detected when no bot activity is found.
  1. Continuing in the attemptSignup function in server/accounts.js, check the bot signal returned in the event object:
server/accounts.js
Scripts can also call your backend endpoints directly without ever loading the JavaScript agent. To detect that kind of automated traffic, the Automation Intelligence API, currently in public preview, classifies requests from HTTP request metadata without the JavaScript agent. You can also use Fingerprint’s Suspect Score to flag high-risk signups. The Suspect Score is a weighted representation of all Smart Signals present in the identification payload, helping to identify suspicious activity, such as someone using a proxy, a tampered browser, or a virtual machine to look like a new device. Rather than blocking the signup outright, a high Suspect Score is a good reason to hold back the free credits. The person can still create an account, while your app asks for additional verification, such as adding a card, before granting the credits.
  1. Below the bot detection check, add a condition that reads the Suspect Score from the event object and sets a flag to withhold the credits if it exceeds a chosen threshold (for example, 20):
server/accounts.js
You’ll use the withholdCredits flag in the next step when deciding whether to grant the free credits.

6. Limit free credits to one grant per device

Next, use the trusted visitor ID from the event object to grant free credits only once per device. Every signup that passes the bot check still creates an account, but if an account with the same visitor ID has already been granted free credits, the new account is created without them. In production, you might allow a set number of grants per device over time, or offer a paid plan instead. (This example simplifies account creation and credit logic for demonstration purposes.) This makes free tier limits enforceable at the device level, not just the account level. Even if someone signs up with a new username or email address, clears cookies, or switches to incognito mode, the free credit grant is still linked to the visitor ID for that browser. Note: The starter app includes a SQLite database with a table already created for you. The freeCredits column records how many free credits each account was granted:
SQLite database tables
  1. Add a helper function to the bottom of the server/accounts.js file to check if any account on this device has already been granted free credits:
server/accounts.js
  1. Update attemptSignup to retrieve the visitorId and use it to decide whether the new account should receive free credits. The credits are granted only if the Suspect Score is under the threshold and the device hasn’t already received them:
server/accounts.js
  1. The starter app’s SQL statement grants free credits to every new account. Update it to store the visitorId and only grant the credits when creditsApplied is true. Then return the result, including a warning message when the credits are withheld:
server/accounts.js
The account is always stored with its visitorId, even when the credits are withheld. This lets your support or risk team look up every account created on the same device, which is useful for reviewing suspected multi-accounting or investigating resold accounts after the fact. This gives you a basic system to detect and prevent AI token abuse. You can extend it by allowing a limited number of grants per device, adding verification steps before releasing withheld credits, setting time-based limits, or flagging linked accounts for review.
This is a minimal example to show how to implement Fingerprint. In a real application, make sure to use proper security practices, input validation, password handling, and account management logic that align with your production standards.

7. Test your implementation

Now that everything is wired up, you can test the full protected signup and free credit flow.
  1. Start your server if it isn’t already running and open http://localhost:3000:
Terminal
  1. Reset the database by clicking on Reset demo DB at the bottom of the page.
  2. Create a new account in your browser. You’ll see “Account created. 1,000 free credits added.”
  3. Create another account with a different username in the same browser. The account is created, but you’ll see “Account created. Free credits have already been used on this device. Upgrade to keep going.”
  4. Open an incognito/private window and create another account. The account is still created, but the free credits are denied because your visitor ID stays the same for that browser.
  5. Bonus: Test the flow using a headless browser or automation tool to see bot detection in action. A sample script is available in test-bot.js that attempts to create 10 new accounts. While your app is running, run the script with node test-bot.js in your terminal and observe that every automated signup is blocked with “Signup failed.”
  6. Click Reset demo DB again to clear all accounts, then sign up once more. The first signup receives 1,000 free credits again.

Next steps

You now have a working signup flow that limits free AI credits to one grant per device with Fingerprint. From here, you can expand the logic with more Smart Signals, fine-tune rules based on your business policies, or layer in additional checks for suspicious devices. To dive deeper, explore the other use case tutorials for more step-by-step examples. Check out these related resources: