Skip to main content

Overview

This guide shows how to call the Research Defender respondent search endpoint from client-side JavaScript. You can use either a GET or a POST request. Both return the same result. After the request completes, you can read:

Prerequisites

  • A Research Defender publishable key
  • Your survey number (sy_nr)
  • The respondent’s session ID (sn_ud)
Only use your publishable key in client-side code. Never expose a secret key in a browser.

Endpoint

string
required
The Research Defender environment, for example prod.
string
required
Your Research Defender publishable key.

Request parameters

string
required
The survey number.
string
required
The respondent’s session ID.
Requests must be sent with credentials (credentials: "include") so Research Defender cookies are included.

Examples

post-search.js

Full HTML pages

If you want a complete page you can open in a browser, use one of the samples below. Replace the placeholder values at the top of the script before running.
basic-post-integration.html
basic-get-integration.html

Handling errors

A non-200 status means the lookup did not succeed. The samples throw an error in that case so you can decide how to handle it, for example by letting the respondent continue or logging the failure.
Decide in advance what your survey should do when a lookup fails, so a temporary error never blocks legitimate respondents.