Overview
In this quickstart, you’ll add Fingerprint to a PHP server to prevent fraudulent account creation. The example use case we’ll use for this quickstart is stopping new account fraud, where attackers create multiple fake accounts to abuse promotions, exploit systems, or evade bans. However, the steps you’ll follow apply to most use cases. You can flag and block suspicious users by identifying the device behind each sign-up attempt, login, or transaction. In this quickstart, you’ll learn how to:- Set up a PHP server with a Fingerprint integration
- Retrieve visitor identification data using the Server API
- Block bots and suspicious devices
- Prevent multiple signups from the same device
Estimated time: < 10 minutes
Prerequisites
Before you begin, make sure you have the following:- PHP 8.0 or later
- Composer (PHP package manager) installed
- SQLite3 installed
- A completed front-end or mobile Fingerprint implementation (See our quickstarts)
1. Get your secret API key
If you’re ready:
- Sign in and go to the API keys page in the Fingerprint dashboard.
- Create a new secret API key.
- Copy it somewhere safe so you can use it to retrieve full visitor identification data from the Server API.
2. Set up your project
We’ll start by creating a PHP server that exposes a POST endpoint for account creation. If you already have a project you want to use, skip to the next section.- Create a project folder, move into it, and set up Composer with the required packages:
Terminal
- Create a
.envfile to store your Fingerprint secret API key (replace with your actual key):
Terminal
- Create a new file called
index.phpand load your dependencies:
index.php
- Then create a POST route for
/api/create-account. For now, this will just return a placeholder message so you can confirm the server is running:
index.php
3. Initialize Fingerprint and retrieve visitor data
Now you’ll configure the Fingerprint server SDK using your secret API key and use it to fetch detailed visitor data for each signup attempt. When making the initial visitor identification request in the front end, you received arequestId. This ID is unique to each identification event. Your server can then use the Fingerprint Events API to retrieve complete identification data, including the trusted visitor ID and other actionable insights like whether they are using a VPN or are a bot.
- Import the Fingerprint SDK classes and the Guzzle HTTP client at the top of
index.php(after your other use statements):
index.php
- Initialize the Fingerprint client using your secret API key and your specific workspace region. (After loading your .env variables):
index.php
- In your
/api/create-account route, retrieve the inputs sent from your front end and fetch the full visitor identification details withgetEvent():
index.php
requestId the Fingerprint server client will retrieve the full data for the visitor identification request. The returned object will contain the visitor ID, IP address, device and browser details, and Smart Signals like bot detection, incognito mode detection, and detections for VPN or virtual machine use.
You can see a full example of the event structure, and test it with your own device, in our demo playground.
For additional checks to ensure the validity of the data coming from your front end view how to protect from client-side tampering and replay attacks in our documentation.
4. Block bots and suspicious devices
This optional step uses the Bot Detection Smart Signal which is available only
on paid plans.
event object includes the Bot Detection Smart Signal that flags automated activity, making it easy to reject bot traffic.
- Continuing in your
/api/create-accountroute, after thetry/catchwhere you fetch the event, extract the bot detection signal and decide whether to allow the signup:
index.php
good for known bots like search engines, bad for automation tools, headless browsers, or other signs of automation, and notDetected when no bot activity is found. You can also layer in other Smart Signals to catch more suspicious devices. For example, you can use Fingerprint’s Suspect Score to determine when to add additional friction to create an account.
5. Prevent multiple signups from the same device
To catch repeated signups from the same device, you can use thevisitorId from the Fingerprint identification event. By saving this ID alongside each created account, you can easily detect and block duplicate signups from the same device. For this quickstart, we’ll use SQLite because it’s a simple to use database with little setup.
- Create a file called
setup.phpwith the following code to initialize a simple SQLite table:
setup.php
- Run the script once to create the database file and table:
Terminal
- In
index.php, open a SQLite connection after loading your environment variables:
index.php
- In your
/api/create-accountroute, after the bot check, extract the trusted visitor ID from the event:
index.php
- Check if this device has already created an account:
index.php
- Insert the new account with the visitor ID and return success:
index.php
This is a minimal example to show how to use the Fingerprint SDK. In a real
application, make sure to implement proper security practices, especially
around password handling and storage.
6. Test your implementation
Now that everything is set up, you can test the full flow using your existing front end.Before you test
If your front end is running on a different port (like localhost:5173 or localhost:3000), you may run into CORS issues for testing. To quickly fix this for local development & testing:- Add the following at the top of
index.php, right after your require and use statements:
Test the implementation
- Start your PHP server:
Terminal
- In your front end, trigger a sign-up request that sends the
requestId,username, andpasswordto your server’s/api/create-accountendpoint. To see the reply messages make sure to parse and display or console log the response from your server. - Within your front end, input a username and password to create a user. Then try to create another user and see that the second attempt will be rejected.
- Bonus: Try creating an account using a headless browser.