Ruby Integration

Integrate VerifyWall with Ruby on Rails in minutes

Add fraud detection to your Rails application using Ruby's built-in HTTP libraries or the Faraday gem.

1

Install dependencies

Add the Faraday HTTP client to your Gemfile and configure your API key via credentials or environment variables.

gem 'faraday'
2

Create an API client

Create a service object that wraps the VerifyWall API. Rails service objects keep your controllers clean.

class VerifyWall
  BASE_URL = ENV.fetch("VERIFYWALL_URL", "https://api.verifywall.com")

  def initialize
    @conn = Faraday.new(url: BASE_URL) do |f|
      f.response :json
      f.headers["Authorization"] = "Bearer #{ENV.fetch("VERIFYWALL_API_KEY")}"
    end
  end

  def check(subject)
    response = @conn.get("/v1/check", { q: subject })
    response.body["data"]["attributes"]
  end
end
3

Add to your registration controller

Call VerifyWall in your registrations controller to score each signup before creating the user.

class RegistrationsController < ApplicationController
  def create
    check = VerifyWall.new.check(params[:email])

    if check["risk_level"] == "high"
      render json: {
        error: "Registration blocked."
      }, status: :unprocessable_entity
      return
    end

    user = User.create!(
      email: params[:email],
      password: params[:password],
      risk_score: check["risk_score"]
    )

    sign_in(user)
    redirect_to dashboard_path
  end
end
4

Test the integration

Test from the Rails console to confirm your API key and connection are working.

# Run: rails console
result = VerifyWall.new.check("[email protected]")
puts result
# => {"risk_score"=>65, "risk_level"=>"high", ...}

Frequently asked questions

Does VerifyWall work with Rails 7 and Rails 8?

Yes. VerifyWall is a REST API, so it works with any Rails version. The Faraday gem is compatible with all modern Rails versions, and you can also use Net::HTTP from the Ruby standard library if you prefer no dependencies.

Can I use Net::HTTP instead of Faraday?

Yes. Ruby's built-in Net::HTTP works fine. Faraday is recommended because it provides a cleaner API and handles JSON serialization automatically, but either approach works.

How do I run checks in a background job?

Create a Sidekiq or ActiveJob worker that calls VerifyWall.new.check() and updates the user record. This is useful if you want to let users sign up immediately and flag risky accounts asynchronously.

Ready to integrate?

Get your API key and start protecting your Ruby application in minutes.