Skip to main content

Overview

In this quickstart, you’ll add Fingerprint to a Go 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 Go server (using the gorilla/mux router) with a Fingerprint integration
  • Retrieve visitor identification data using the Server API
  • Block bots and suspicious devices
  • Prevent multiple signups from the same device
This guide focuses on the back-end integration and must be completed after identifying a visitor and generating a request ID. Before starting this quickstart, start with one of our front-end or mobile quickstarts to see how to identify a visitor in your front-end.
Estimated time: < 10 minutes

Prerequisites

Before you begin, make sure you have the following:
  • A completed front-end or mobile Fingerprint implementation (See our quickstarts)
  • Go (v1.24 or later)
  • Your favorite code editor
  • Basic knowledge of Go

1. Get your secret API key

Before starting this quickstart, you should already have a front-end Fingerprint implementation that sends the requestId to your server. If not, pause here and check out one of our front-end or mobile quickstarts first.
If you’re ready:
  1. Sign in and go to the API keys page in the Fingerprint dashboard.
  2. Create a new secret API key.
  3. Copy it somewhere safe so you can use it to retrieve full visitor identification data from the Server API.

2. Set up your project

To get started, set up a basic server. If you already have a project you want to use, you can skip to the next section.
  1. Create a new Go module and install gorilla/mux and the Fingerprint Server SDK:
Terminal
mkdir fingerprint-go-quickstart && cd fingerprint-go-quickstart
go mod init fingerprint.com/go-quickstart
go get github.com/gorilla/mux github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk
Note: This quickstart is written for Fingerprint SDK version 7.x
  1. Create a new file called main.go and add a basic gorilla/mux server setup:
main.go
package main

import (
	"context"
	"encoding/json"
	"log"
	"net/http"
	"os"

	"github.com/gorilla/mux"
)

func main() {
	r := mux.NewRouter()
	r.HandleFunc("/api/create-account", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Set("Content-Type", "application/json")
		w.WriteHeader(http.StatusOK)
		json.NewEncoder(w).Encode(map[string]string{"status": "Account created!"})
	}).Methods("POST")

	http.Handle("/", r)
	srv := &http.Server{
		Handler: r,
		Addr:    "localhost:3000",
	}

	log.Printf("Server is running on http://localhost:3000")
	log.Fatal(srv.ListenAndServe())
}

Here we are running the server at port 3000 and have created a new POST route for account creation. Note that the /api/create-account route should match what you have set up in your front-end implementation where you are sending the Fingerprint requestId to your server. Your server will receive the initial identification information from identifying a visitor on the front end and use it to get the full visitor data on the back end.

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 a requestId. 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.
  1. At the top of your main.go file, import the Fingerprint SDK:
main.go
import (
  // ...
	// Add this import:
	"github.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/v7/sdk"
	// ...
)
  1. At the beginning of the main() function, initialize the client with your secret API key. Change the region, if required:
main.go
func main() {
	cfg := sdk.NewConfiguration()
	client := sdk.NewAPIClient(cfg)
	cfg.ChangeRegion(sdk.RegionUS)

	auth := context.WithValue(
		context.Background(),
		sdk.ContextAPIKey,
		sdk.APIKey{Key: "<your-secret-api-key>"},
	)
    // Rest of function
    // ...
}
For a production implementation make sure to store and reference your secret key securely.
  1. In your /api/create-account handler, retrieve the requestId you are sending from the front end and fetch the full visitor identification details with GetEvent():
main.go
r.HandleFunc("/api/create-account", func(w http.ResponseWriter, r *http.Request) {
    var createAccountRequest CreateAccountRequest
    err := json.NewDecoder(r.Body).Decode(&createAccountRequest)
    if err != nil {
        http.Error(w, "Invalid JSON", http.StatusBadRequest)
        return
    }

    event, _, err := client.FingerprintApi.GetEvent(auth, createAccountRequest.RequestId)
    if err != nil {
        // An error may occur because the requestId is invalid or missing, or there is an issue with the configuration.
        http.Error(w, "Error processing request", http.StatusBadRequest)
        return
    }
    //...
  1. To support the JSON decoding, declare the CreateAccountRequest struct just before the main() function:
main.go
type CreateAccountRequest struct {
	RequestId string `json:"requestId"`
	Username  string `json:"username"`
	Password  string `json:"password"`
}
Using the 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.
A simple but powerful way to prevent fraudulent account creation is to block automated signups that come from bots. The event object includes the Bot Detection Smart Signal that flags automated activity, making it easy to reject bot traffic.
  1. Continuing in your /api/create-account route, check the bot signal returned in the event object:
main.go
if *event.Products.Botd.Data.Bot.Result != sdk.BotdBotResult_NOT_DETECTED {
    http.Error(w, "Failed to create account.", http.StatusForbidden)
    return
}
This signal returns 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 the visitorId 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. We’ll be using a simple database to demonstrate how this works with SQLite.
  1. Install the modernc.org/sqlite SQLite package:
Terminal
go get modernc.org/sqlite
  1. At the top of your main.go file, add these imports:
main.go
import (
	"database/sql"_ "modernc.org/sqlite"

    // ...
)
  1. Then after the Fingerprint configuration code in main(), initialize the database:
main.go
db, err := sql.Open("sqlite", "database.db")
if err != nil {
    log.Fatal(err)
    os.Exit(1)
}
db.Exec(`CREATE TABLE IF NOT EXISTS accounts (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    username TEXT,
    password TEXT,
    visitorId TEXT
)`)
defer db.Close()
  1. In your /api/create-account route handler, after getting the event, extract the visitorId:
main.go
visitorId := event.Products.Identification.Data.VisitorId
  1. Check if this device has already created an account; if yes, block the account creation:
main.go
// Check if the visitorId already exists in the database
existingRow := db.QueryRow("SELECT COUNT(*) FROM accounts WHERE visitorId = ?", visitorId)
var count int
existingRow.Scan(&count)

if count > 0 {
    http.Error(w, "Failed to create account.", http.StatusTooManyRequests)
    return
}

_, err = db.Exec("INSERT INTO accounts (username, password, visitorId) VALUES (?, ?, ?)",
    createAccountRequest.Username, createAccountRequest.Password, visitorId)

if err != nil {
    http.Error(w, "Failed to create account.", http.StatusInternalServerError)
    return
}
This gives you a basic system to detect and block repeat signups. You can expand on this by allowing a limited number of accounts per device, adjusting your response based on business rules, only evaluating recent signups, etc.
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:3001), you may run into CORS issues for testing. To quickly fix this for local development & testing:
  1. Install the gorilla/handlers module:
Terminal
go get github.com/gorilla/handlers
  1. Add "github.com/gorilla/handlers" to your imports in main.go, then set up the CORS configuration and attach it to the handler at the end of your main() function:
main.go
originsOk := handlers.AllowedOrigins([]string{"*"})
methodsOk := handlers.AllowedMethods([]string{"GET", "HEAD", "POST", "PUT", "OPTIONS"})
headersOk := handlers.AllowedHeaders([]string{"Accept", "Accept-Language", "Content-Type", "Content-Language", "Origin"})

srv := &http.Server{
    Handler: handlers.CORS(originsOk, methodsOk, headersOk)(r),
    Addr:    "localhost:3000",
}

log.Printf("Server is running on http://localhost:3000")
log.Fatal(srv.ListenAndServe())

Test the implementation

  1. Start your Go server:
Terminal
go run main.go
  1. In your front end, trigger a sign-up request that sends the requestId, username, and password to your /api/create-account endpoint. To see the reply messages make sure to parse and display or console log the response from your server.
  2. 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.
  3. Bonus: Try creating an account using a headless browser.

Next steps

You now have a working back-end fraud check using Fingerprint. From here, you can expand your logic with more Smart Signals, adjust thresholds based on your risk tolerance, or introduce additional checks for suspicious users. These same techniques apply to a wide range of fraud prevention use cases, from detecting fake reviews to blocking payment abuse or preventing account takeovers. To go further, check out our use case tutorials for step-by-step guides tailored to specific problems you can solve with Fingerprint. Check out these related resources: