Skip to main content

Send Request Context from Your Backend

The Opportify JS script describes the browser it runs in. Some signups never go through it: an OAuth callback, a plain email form, a server-rendered page, or a request from a script that skipped your page entirely. For those, your backend is the only place that saw the visitor's HTTP request.

The Request Context standard lets your backend forward that request to the Fraud Protection API as a few short strings. It is optional. If you send nothing, scoring is unchanged.

What to send​

Add these keys to formData in the analyze request, together with the top-level userIp.

KeyValueNotes
user_agentThe visitor's User-Agent header, unmodifiedThe visitor's, not your server's. Your HTTP client's own agent (axios/1.x, python-requests/2.x) is the wrong value.
accept_languageThe visitor's Accept-Language headerStored with the analysis record.
refererThe visitor's Referer, reduced to scheme, host and pathRemove the query string and fragment first. They can carry tokens or personal data.
sec_ch_uaThe visitor's Sec-CH-UA headerSend it only when the header is present. Chromium browsers send it; Firefox and Safari do not.
sec_ch_ua_platformThe visitor's Sec-CH-UA-Platform headerSend it only when present.
sec_ch_ua_mobileThe visitor's Sec-CH-UA-Mobile headerSend it only when present.

Rules that apply to every formData entry:

  • formData is a flat map of strings. Numbers, booleans, arrays and nested objects return 400 MALFORMED_REQUEST.
  • At most 20 keys. Keys up to 100 characters. Values up to 512 characters. Empty values are dropped.
  • Send the IP in the top-level userIp field. A source_ip key inside formData is not used for scoring.
POST https://api.opportify.ai/intel/v1/fraud/analyze
Content-Type: application/json
x-opportify-token: YOUR_API_KEY

{
"email": "jhon.doe@gmail.com",
"userIp": "203.0.113.42",
"submissionType": "signup",
"formData": {
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
"accept_language": "pt-BR,pt;q=0.9,en;q=0.8",
"referer": "https://www.example.com/signup",
"sec_ch_ua": "\"Chromium\";v=\"142\", \"Google Chrome\";v=\"142\", \"Not_A Brand\";v=\"99\"",
"sec_ch_ua_platform": "\"macOS\"",
"sec_ch_ua_mobile": "?0"
}
}

Examples​

const analysis = await fraud.analyze({
email: req.body.email,
userIp: req.ip, // set "trust proxy" so this is the visitor, not your load balancer
submissionType: 'signup',
formData: {
user_agent: req.get('user-agent'),
accept_language: req.get('accept-language'),
referer: stripQuery(req.get('referer')),
sec_ch_ua: req.get('sec-ch-ua'),
sec_ch_ua_platform: req.get('sec-ch-ua-platform'),
sec_ch_ua_mobile: req.get('sec-ch-ua-mobile'),
},
});

stripQuery and strip_query are your own helpers that keep only the scheme, host and path of a URL. Skip any header that is missing. Do not send empty strings or placeholders.

Get the visitor's IP right

Behind a load balancer or CDN, your framework may report the proxy's address. Configure your framework's trusted-proxy setting so userIp is the visitor's address. Do not read X-Forwarded-For directly unless your proxy overwrites it, because visitors can set it themselves.

What Opportify does with it​

SignalWhen it appearsMeaning
request:tool-user-agentuser_agent names an HTTP library, command-line tool or headless automation toolThe request was likely made by a script, not a person in a browser. Native mobile app agents are not flagged.
session:ua-mismatchYou also send the opportifyToken, and the browser family or operating system in user_agent differs from the one the JS script recordedThe request that reached your backend did not come from the browser that loaded your page. Small version differences are ignored.
request:client-hints-mismatchA sec_ch_ua* value contradicts user_agent: a different Chromium version, a different operating system, a mobile flag that disagrees, or sec_ch_ua sent with a Firefox or Safari agentThe request was probably built by a tool that set a browser user agent without matching hints. A missing hint never counts.

How these signals behave:

  • They add to the score, they do not decide it. A script-like agent on a clean address with a clean email stays in the middle of the range. The same agent together with another risk signal, such as a risky IP or a disposable email, raises the score further. You keep the decision.
  • No context, no signal. Missing keys never count against a visitor.
  • They can be spoofed. The values come from your server, and the visitor controls what the browser sends. Treat them as one input among several, not as proof.
  • accept_language and referer are stored with the analysis record. They do not change the score today.

These keys are not treated as form content, so a long user-agent string is never scored as gibberish.

Device and network fingerprints without the script​

When a request has no opportifyToken, Opportify builds the same device, network and client fingerprints the JS script would have produced, from user_agent and userIp. A visitor already known to Opportify is then recognized even when your backend calls the API directly. If that fingerprint is on a blocklist, the response carries request:client-fingerprint-blocklisted and a high score. The fingerprints themselves are internal and are not returned in the response. Send user_agent and userIp together to get this.

Not a replacement for the JS script

The script observes behavior in the page: typing, pointer movement, timing, and automation tools. Request Context only carries what your server received. Use the script where you can, and Request Context where you cannot.

Next steps​