API Reference

Adding Spriv to your own application

If you already run your own website, app or internal system, Spriv can add a second security check to it a tap on the user's phone, a text message reply, or a 6-digit code. This page explains what that looks like in everyday terms first, then gives your developer every endpoint, parameter, sample response and status code.

Who this page is for: the first half is written for anyone no technical background needed. The second half is a reference your developer or IT provider will use. You don't have to understand the code samples to decide whether Spriv is right for you.
In plain English

What an integration actually does#

Today, someone signs into your system with a username and a password. If that password is stolen, guessed or reused from another site, whoever has it gets in. Spriv adds a second step that the thief almost certainly can't pass: proving they are holding the real user's phone.

Your system keeps doing what it already does. At the moment it would normally say "password correct, let them in," it asks Spriv first. Spriv contacts the user's phone, waits for an answer, and tells your system yes or no. Nothing about your existing login screen has to change.

The flow

What happens when someone signs in#

  1. The user enters their username and password

    On your own login page, exactly as they do now.

  2. Your system asks Spriv to double-check

    It sends us the username and a few details about the sign-in which computer, which browser, and the internet address it's coming from.

  3. Spriv decides how much proof is needed

    A familiar laptop in the usual office may be let through with no interruption. An unfamiliar device, or one in a different country an hour after the last sign-in, triggers a challenge.

  4. The user confirms on their phone

    They get a notification and tap Allow or Deny. Depending on how you configure it, this can instead be a text message they reply "YES" to, or a 6-digit code from the Spriv app.

  5. Spriv tells your system the answer

    Approved, denied, or still waiting. Your system lets the person in or stops them accordingly.

One thing to set up first: every user has to be added to Spriv and have their phone paired with their username before any of this works. Pairing is a one-time step see How pairing works. Until a user is paired, there is no phone for Spriv to contact.
Glossary

Words you'll see on this page#

  • APIThe connection your developer uses to let your system and Spriv talk to each other automatically, without anyone clicking anything.
  • EndpointOne specific request your system can make, such as "add a user" or "check this sign-in." Each bordered card further down is one endpoint.
  • API key and secret keyYour company's username and password for the connection itself. They prove the request really came from your system. Treat the secret key like a password: never email it, never put it on a web page.
  • PairingThe one-time step that links one specific phone to one specific username, using a single-use link emailed to the user.
  • Push notificationThe pop-up that appears on the user's phone asking them to approve or deny a sign-in.
  • Adaptive authenticationSpriv judging each sign-in on how normal it looks, and only interrupting the user when something is unusual. Once a user approves a device, later sign-ins from that same device near the same phone can be approved automatically.
  • TOTPThe 6-digit code in the Spriv app that changes every 30 seconds. It works on a phone with no signal and no internet it only needs battery.
  • PollingYour system checking back with Spriv every second or so to ask "has the user tapped Allow yet?" while it waits.
  • Callback URLThe alternative to polling: an address on your server that Spriv contacts as soon as the user answers, so you don't have to keep asking.
  • Bypass codeA code an administrator issues so a specific user can get in without their phone, for situations like a lost or broken handset.
  • Device fingerprintA description of the computer being used, so Spriv can recognise a returning device.
Choosing a method

Which sign-in method should you use?#

  • Adaptive (continuous)The smoothest for everyday users. Most sign-ins go through untouched; only unusual ones are challenged. Recommended for customer-facing sites.
  • Allow / Deny pushEvery single sign-in asks for a tap on the phone. Best for administrator accounts and anything highly sensitive. It can never be automated, by design.
  • Two-way SMSA text message the user replies "YES" to. Use it for people who won't install an app. Also never automated.
  • TOTP codeThe user reads a 6-digit code from the app and types it in. Works with no mobile signal, and can be combined with any of the above to make a third factor.
Every call: base URL https://app.spriv.com · headers Content-Type: application/json, Accept: application/json, apiversion: 1 · spriv_key and spriv_secret in the body. Complete the Getting Started steps first, add each username, then pair it with a phone before calling any authentication endpoint.
Endpoints

Managing users#

These calls keep Spriv's list of people in step with your own call them from wherever your system already creates, edits and removes accounts. The user's details are nested inside a user object.

POST/manage_usersAdd Users#

In plain terms: registers a person with Spriv so they can be protected. Call it when a new account is created in your system.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • user[email]stringRequiredA valid email address the pairing link is sent here.
  • user[first_name]stringRequiredThe user's first name.
  • user[last_name]stringRequiredThe user's last name.
  • user[mobile_phone]stringRequiredMobile number starting with the country code.
  • user[person_id]stringOptionalYour own internal ID for this person.

Store the returned user_id the update, delete and pairing calls all need it.

Request
POST https://app.spriv.com/manage_users

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "user": {
    "email": "example@company.com",
    "first_name": "joe",
    "last_name": "doe",
    "mobile_phone": "914444556677",
    "person_id": "12277"
  }
}
Response
{
  "user_id": 10,
  "status": 200,
  "message": "User created successfully."
}
PUT/manage_users/<user id>Update User#

In plain terms: changes someone's details most often a new phone number after they change handsets.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • userobjectRequiredThe same fields as Add Users. status_id in the response is the account's current state; status_timeout is how long a temporary state such as bypass still has left.
Request
PUT https://app.spriv.com/manage_users/<user id>

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "user": {
    "email": "example@company.com",
    "first_name": "joe",
    "last_name": "doe",
    "mobile_phone": "914444556677",
    "person_id": "12277"
  }
}
Response
{
  "status": 200,
  "message": "User details updated successfully!",
  "user": {
    "id": 10,
    "first_name": "joe",
    "last_name": "doe",
    "email": "example@company.com",
    "person_id": "12277",
    "mobile_phone": "914444556677",
    "status_id": "bypass",
    "status_timeout": null
  }
}
DELETE/manage_users/<user id>Delete User#

In plain terms: removes someone from Spriv, for example when they leave the company. Their phone stops being able to approve sign-ins.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
Request
DELETE https://app.spriv.com/manage_users/<user id>

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key"
}
Response
{
  "status": 200,
  "message": "User removed successfully."
}
POST/manage_users/pair/<user id>Pairing#

In plain terms: emails the user a single-use link that ties their phone to their username. Nothing else on this page works until this is done.

Spriv sends a unique 32-bit URL to the user's email address. The user completes pairing in two clicks: open the link, then tap Pair. Spriv then sends a push notification to your callback URL, and from that moment the user can be authenticated. If the user is already paired, calling this endpoint unpairs them and sends a fresh pairing email.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • emailstringRequiredThe address the pairing link is sent to.
  • idintegerRequiredThe user ID returned by Add Users.
  • recovery_codestringAutoGenerated by Spriv.
  • qr_codestringAutoGenerated by Spriv.
  • ip_addressesstringOptionalComma-separated list of safe IPs.

The pairing link can be used only once. A second attempt with the same link returns "Invalid pairing code" see How pairing works.

Request
POST https://app.spriv.com/manage_users/pair/<user id>

{
  "spriv_key": "your spriv key",
  "spriv_secret": "your spriv secret",
  "email": "example@company.com",
  "id": 83
}
Endpoints

Checking a sign-in#

These are the calls you make at the moment of login, once the password has already been accepted. Pick the one that matches the method you chose above you can use different methods for different groups of users.

Each of them can return an answer in one of two ways. Send "poll": true and you get back a poll_service_url to check repeatedly until the user answers; leave it out and Spriv contacts your callback URL instead. If you rely on the callback and haven't configured one, the API returns status 416.

POST/authentication/adaptive_authenticationAdaptive#

In plain terms: asks Spriv to judge how risky this sign-in looks and challenge the user only when it's unusual. Once a user approves a given device, Spriv can approve later sign-ins from that same device automatically when it is near the paired phone.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • usernamestringRequiredThe username being authenticated.
  • osstringOptionalOperating system name.
  • browserstringOptionalBrowser name.
  • computer_fingerprintstringOptionalDevice fingerprint of the computer signing in. Without it, Spriv can't recognise a returning device.
  • ip_addressstringOptionalThe user's IP address.
  • bypass_codestringOptionalOnly when an admin has allowed this user to bypass.
  • pollbooleanOptionalSend true to receive a polling URL instead of a callback.
Request
POST https://app.spriv.com/authentication/adaptive_authentication

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "username": "username of user",
  "os": "Windows 11",
  "browser": "Chrome",
  "computer_fingerprint": "user computer fingerprint",
  "ip_address": "1.1.1.1",
  "bypass_code": "your bypass code here",
  "poll": true
}
Response
// sent; decision arrives at your callback URL
{
  "status": 200,
  "message": "User verification request sent."
}

// when "poll": true was sent
{
  "status": 206,
  "message": "Sent Successfully; Pending Decision; Check URL for answer.",
  "poll_service_url": "https://app.spriv.com/poll/<polling id>"
}
POST/poll/<unique polling ID>Polling#

In plain terms: while the user is looking at their phone, your system asks Spriv every second or so whether they've answered yet. The same endpoint works for adaptive, allow/deny and SMS.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • usernamestringRequiredThe username being authenticated.
  • pollbooleanRequiredAlways true on this endpoint.
Request
POST https://app.spriv.com/poll/<unique polling ID>

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "username": "username of user",
  "poll": true
}
Response
// approved let the user in
{ "status": 200, "message": 1 }

// nothing matches this polling id treat as a failure
{
  "status": 404,
  "message": "No matching transaction found."
}

// no answer yet wait and poll again
{
  "status": 206,
  "message": "No response from mobile device yet. Please try again"
}
POST/authentication/allow_deny_authenticationAllow / Deny Push#

In plain terms: always sends a notification to the phone, on every sign-in, with a custom message and two buttons. Best for admin accounts.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • usernamestringRequiredThe username being authenticated.
  • totpstringOptional6-digit code, when combining this with TOTP for a third factor.
  • ip_addressstringOptionalThe user's IP address.
  • pollbooleanOptionalSend true to receive a polling URL instead of a callback.

There is no option to automate Allow/Deny Authentication it always requires user action. That is deliberate: it is the strongest of the four methods.

Request
POST https://app.spriv.com/authentication/allow_deny_authentication

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "totp": "742479",
  "username": "your username",
  "ip_address": "1.1.1.1",
  "poll": true
}
Response
{ "status": 200 }

// listen for a GET on /report_decision/
{
  "decision": "1",
  "transaction_id": "4C3EEA25CC20454CA7CEE929BCE50D94"
}

// no callback URL configured
{
  "status": 416,
  "errors": ["Callback URL not set. Please set it first."]
}

// when "poll": true was sent
{
  "status": 206,
  "message": "User verification request sent to device. Pending Decision. Check URL for answer.",
  "poll_service_url": "https://app.spriv.com/poll/<polling id>"
}
POST/authentication/sms_authenticationTwo-Way SMS#

In plain terms: texts the user a custom message and waits for them to reply YES. Use it for people who won't install an app.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • usernamestringRequiredThe username being authenticated.
  • ip_addressstringOptionalThe user's IP address.
  • bypass_codestringOptionalOnly when an admin has allowed this user to bypass.

There is no option to automate SMS requests each login sends a new message.

Request
POST https://app.spriv.com/authentication/sms_authentication

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "username": "username of user",
  "ip_address": "1.1.1.1",
  "bypass_code": "your bypass code here"
}
Response
// message sent, waiting on the reply
{
  "status": 206,
  "message": "Verification SMS sent successfully."
}

// when "poll": true was sent
{
  "poll_service_url": "https://app.spriv.com/poll/<polling id>",
  "status": 206,
  "message": "Sent Successfully; Pending Decision; Check URL for answer."
}

// the SMS could not be delivered
{
  "status": 408,
  "errors": ["Unable to send SMS. Please try again later."]
}
POST/authentication/totpTOTP#

In plain terms: the user reads the 6-digit code from the Spriv app and types it into your login screen; you pass it here to be checked. It works on a phone with no signal it only needs battery. Combine it with any other method above for three-factor authentication.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • usernamestringRequiredThe username being authenticated.
  • totpstringRequiredThe current 6-digit code from the Spriv mobile app.
Request
POST https://app.spriv.com/authentication/totp

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "totp": "742479",
  "username": "username of user"
}
Response
// success
{
  "status": 200,
  "user": {
    "id": 4,
    "first_name": "joe",
    "last_name": "doe",
    "email": "example@company.com",
    "mobile_phone": "914444556677",
    "status_id": "bypass",
    "status_timeout": 22
  }
}

// wrong code
{
  "status": 405,
  "errors": ["Incorrect OTP. Please try again"]
}

// unknown username
{
  "status": 406,
  "errors": ["No such user found with this username"]
}
Endpoints

Confirming a phone number#

Before a phone can be trusted, Spriv checks that the number really belongs to the user by texting a seven-digit code to it. The user types that code into your web page, and these two calls handle the check and the "I never got it" case.

POST/manage_users/verify_phone_pinVerify Phone#

In plain terms: the user types in the code they were texted, and you send it here to confirm the number is theirs.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • user[email]stringRequiredA valid email address.
  • user[phone_pin]stringRequiredThe seven-digit code sent to the user's mobile.
Request
POST https://app.spriv.com/manage_users/verify_phone_pin

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "user": {
    "phone_pin": "phone pin number from sms",
    "email": "example@company.com"
  }
}
Response
// success
{
  "status": 200,
  "message": "Phone number verified successfully",
  "user": { "id": 11, /* … */ }
}

// wrong PIN
{
  "status": 414,
  "errors": ["Wrong PIN number. Please enter correct one or resend SMS."]
}

// no user matches that email
{
  "status": 415,
  "errors": ["Unable to find matching user. Please try again."]
}
POST/manage_users/resend_phone_pinResend Phone PIN#

In plain terms: the text never arrived, or it expired. This cancels the previous code and sends a fresh one only the newest code will work.

  • spriv_secretstringRequiredCompany secret key.
  • spriv_keystringRequiredCompany API key.
  • user[email]stringRequiredA valid email address.
Request
POST https://app.spriv.com/manage_users/resend_phone_pin

{
  "spriv_secret": "your spriv secret",
  "spriv_key": "your spriv key",
  "user": {
    "email": "example@company.com"
  }
}
Response
{
  "status": 200,
  "message": "Phone pin sent successfully. Please check."
}

// no user matches that email
{
  "status": 413,
  "errors": ["Unable to find matching user. Please try again."]
}
Reference

Company MFA settings that affect these calls#

These four aren't endpoints they're admin-configured settings from the control panel's "Company Settings" screen, and several of the status codes below come directly from them. Change them any time from that screen.

Callback URL#

The FQDN or IP where Spriv sends push notifications, e.g. https://push.example.com/Adaptive/Two-factor-authentication.jsp. Leave it unset and every authentication call returns status 416 unless you send "poll": true.

MFA Status#
  • ActiveDefault. "Allow" acts as "Allow Always" for matching identifiers.
  • Allow Once OnlyUser must click allow every transaction, regardless of prior approvals.
  • Restricted Allow Always"Allow Always" applies only to whitelisted IPs; everything else needs manual approval each login. Returns status 435 for IPs off the list.
  • Allow AllAll logins auto-approved, bypassing MFA, except Spriv Administrator accounts.
  • Deny AllAll logins auto-denied, bypassing MFA, except Spriv Administrator accounts. Returns status 419.
Lockout controls#
  • MFA login attempts before lockoutNumber of failed attempts allowed before an account starts returning status 417.
  • MFA lockout expiration1600 minutes; 0 means the lockout never expires on its own.
  • MFA Lockout E-mailSends a notification the moment an account is locked out.
Default decisions#
  • Unpaired end-usersAllow or deny default: Allow. Governs what happens on a 422 (no paired device) instead of a hard failure.
  • Non-existing end-usersAllow or deny default: Deny. Applies before a 406 (no such user) would otherwise be returned.
Reference

Status codes#

Every response carries a status. Anything other than 200 means the user was not authenticated treat it as a refusal, not a "maybe." Each row below gives the message Spriv returns and what to do about it.

Normal

Success and waiting#

  • 200SuccessThe call worked. On a polling or TOTP call this means the user is authenticated let them in.
  • 206User verification request sent to device. Pending Decision.The request reached the phone and Spriv is waiting on the person. Keep polling, or wait for your callback.
The user

Problems with the person signing in#

  • 404No matching transaction found.The polling ID doesn't match any sign-in attempt it expired, or was already answered. Treat as a failure and start again.
  • 405Incorrect OTP. Please try againThe 6-digit TOTP code was wrong or has already rolled over. Ask for the current code.
  • 406No such user found with this usernameThat username isn't in Spriv. Check it was added via /manage_users.
  • 410No user found or some error occurredA general failure log the full response before retrying.
  • 413Unable to find matching user. Please try again.Returned by resend_phone_pin when no user matches the email address.
  • 414Wrong PIN number. Please enter correct one or resend SMS.The seven-digit phone PIN didn't match. Offer the user a resend.
  • 415Unable to find matching user. Please try again.Returned by verify_phone_pin when no user matches the email address.
  • 431No user found with matching emailThe email address given doesn't belong to any user in your company.
The account

The user exists, but can't authenticate#

  • 417User is not active. Account is either denied or locked, or incorrect bypass key.An administrator has to change the account status before this user can sign in.
  • 418Phone number is not verified yet.Send the user through phone verification verify_phone_pin before authenticating them.
  • 420No paired device found for this user and IP is not white listed.The user has no phone paired and isn't coming from a safe IP. Send a pairing email.
  • 422No paired device found.The username exists but no phone is linked to it yet pairing was never completed.
Policy

Blocked by your own company settings#

These aren't faults they're your administrator's rules being enforced. If one appears unexpectedly, check the company MFA settings above before assuming something is broken.

  • 411Cross domain email is disabled.You tried to pair an email address outside your own domain. Contact support@spriv.com to enable it.
  • 419Denying all users.A company-wide block is switched on nobody can authenticate until it's lifted.
  • 434Denying all users from this country.The sign-in came from a country your company blocks.
  • 435IP not whitelistedThe API call reached Spriv from an address that isn't on your allowed list. Add the server's IP, or correct where the call is coming from.
Setup

Something on your side needs configuring#

  • 408Unable to send SMS. Please try again later.The text couldn't be delivered. Retry, or fall back to another method.
  • 412Unable to send pairing mail.The pairing email didn't go out. Check the address, then call the pairing endpoint again.
  • 416Callback URL not set. Please set it first.Configure a callback URL on your account, or send "poll": true and use the polling URL instead.
  • 417Free trial limit reached.The free trial covers two users and two servers. Add a credit card or PayPal account to go beyond that.
  • 421Key/Secret doesn't matchYour spriv_key and spriv_secret don't belong together. Check this first when every call suddenly fails.
  • 424Invalid authentication type in request body.The method named in the request isn't one Spriv recognises. This code is a recent addition, so older integrations may not handle it.
  • 432Unable to update location details.Spriv couldn't record where the sign-in came from.
  • 433Remote server error.Raised when a call for remote server information fails.
Note on 417: the same code covers two unrelated situations an inactive, denied or locked account, and hitting the free-trial ceiling of two users and two servers. Read the message text, not just the number, before showing anything to the user.
Next: Setting up Adaptive Multi Factor Authentication →
Was this helpful?