> ## Documentation Index
> Fetch the complete documentation index at: https://docs.repdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Asynchronous Response

> Learn how to integrate ReDem with your survey tools

<Info>To integrate with ReDem, you must have a ReDem account. <br /> Don’t have an account yet? Get started by [setting up your account](/redem/account-setup).</Info>

<Steps titleSize="h3">
  <Step title="Request an API key">
    Contact us at [support@redem.io](mailto:support@redem.io) to request an API key.
  </Step>

  <Step title="Prepare your request data">
    Ensure your data is formatted correctly according to the guidelines before sending it via the API. Below is a sample request object to help you structure your data properly.

    <p>For an asynchronous response approach, the `synchronousResponse` field **must always be set to `false`**. This allows you to continue engaging with your respondents without waiting for a response from ReDem.</p>

    ```javascript Example request body theme={null}
    {
      "respondentId": "RESP497770", 
      "surveyName": "Global Vacation Insights 2024",
      "dataPoints": [ 
        {
          "qualityCheck": "OES",
          "dataPointId": "Q1",
          "question": "Where did you spend your last vacation?",
          "answer": "We were at Lake Garda in Italy",
          "keywords": ["Beach", "Mountains", "Lake", "Museums", "Europe", "Asia", "Destination"],
          "activateDuplicateDetection": true,
          "allowedLanguages": ["en"]
        },
        {
          "qualityCheck": "TS",
          "dataPointId": "durationQ1", 
          "duration": 42670
        },
        // ... other data points ...
      ],
      "activateCleaning": true,
      "cleaningSettings": {
        "redemScore": 60,
        "OES": {
          "score": 60,
          "minDataPoints":2,
          "categories": {
            "BAD_LANGUAGE": {"activate": true, "minDataPoints":2},
            "GIBBERISH": {"activate": true, "minDataPoints":2},
            "OFF_TOPIC": {"activate": true, "minDataPoints":2},
            "WRONG_LANGUAGE": {"activate": true, "minDataPoints":2},
            "AI_SUSPECT": {"activate": true, "minDataPoints":2},
            // ... other categories ...
          }
        },
        "CHS": {"score": 50},
        "GQS": {"score": 40, "minDataPoints":2},
        "TS": {"score": 30}
      },
      "synchronousResponse": false,
    }
    ```

    <Note>For a full example and detailed guidance on using this request object, visit the [Add Respondent](/redem/api-reference/endpoints/v3/addRespondent) endpoint. It includes explanations of all fields and their usage.</Note>
  </Step>

  <Step title="Make an API request">
    <p> At the end of the survey, just before the respondent reaches the ‘complete’ state, submit an API request to ReDem including the respondent’s information and your API key.</p>

    ```javascript Example request (JavaScript) theme={null}
    const options = {
      method: 'POST',
      headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
      body: '{"respondentId":"RESP497770","projectName":"Global Vacation Insights 2024","dataPoints":[{"qualityCheck":"OES","dataPointId":"Q1","question":"Where did you spend your last vacation?","answer":"We were at Lake Garda in Italy","keywords":["Beach","Mountains","Lake","Museums","Europe","Asia","Destination"],"activateDuplicateDetection":true,"allowedLanguages":["en","de","it"]},{"qualityCheck":"TS","dataPointId":"durationQ1","duration":42670},{"qualityCheck":"GQS","dataPointId":"Q2","gridAnswersPattern":[7,8,9,1,3,5,2,5,9,6]},{"qualityCheck":"OES","dataPointId":"Q3","question":"What was the most memorable part of your last vacation?","answer":"Italian cuisine, especially pizza and fine wine.","keywords":["Cuisine","Food","Art","Adventure","History","Landscape","Culture"],"activateDuplicateDetection":true,"allowedLanguages":["en","de","it"]},{"qualityCheck":"TS","dataPointId":"durationQ3","duration":69720},{"qualityCheck":"CHS","dataPointId":"CHS_Question","interviewData":[{"question":"What mode of transport did you use?","answer":"Car"},{"question":"How many days did you stay?","answer":5},{"question":"Did you travel with family?","answer":"yes"},{"question":"What was your approximate total budget for the trip (in EUR)?","answer":1500},{"question":"What type of accommodation did you stay in?","answer":"Hotel"}]},{"qualityCheck":"GQS","dataPointId":"Q4","gridAnswersPattern":[2,1,4,3,5,2,3,1,1,1]},{"qualityCheck":"TS","dataPointId":"totalDuration","duration":256843}],"cleaningSettings":{"standardSettings":false,"CustomSettings":{"redemScore":60,"OES":{"score":30,"minimumAnswers":2,"categories":{"genericAnswers":{"exclude":true,"minDataPoints":2},"noInformation":{"exclude":true,"minDataPoints":2},"badLanguage":{"exclude":true,"minDataPoints":2},"nonsense":{"exclude":true,"minDataPoints":1},"duplicateAnswer":{"exclude":true,"minDataPoints":1},"duplicateRespondent":{"exclude":true,"minDataPoints":1},"wrongTopic":{"exclude":true,"minDataPoints":1},"wrongLanguage":{"exclude":true,"minDataPoints":1},"copyPastAnswer":{"exclude":true,"minDataPoints":1},"fakeAnswer":{"exclude":true,"minDataPoints":1}}},"CHS":{"score":20},"GQS":{"score":10,"minimumItems":15},"TS":{"score":30}}},"synchronousResponse":false}'
    };

    fetch('https://api.redem.io/respondent/add', options)
      .then(response => response.json())
      .then(response => console.log(response))
      .catch(err => console.error(err));
    ```
  </Step>

  <Step title="Use the ReDem API response to trigger your next step">
    <p>Retrieve the response from ReDem to ensure your request was successfully submitted and is still in progress.</p>

    ```javascript Example response (JavaScript) theme={null}
      {
        "success": true,
        "message": "Respondent Queued for Evaluation",
        "results": {
          "status": "QUEUED"
        }
      }
    ```

    <Note>For a full example and detailed guidance on using this response object, visit the [Add Respondent](api-reference/endpoints/v3/addRespondent) endpoint. It includes explanations of all fields and their usage.</Note>
  </Step>

  <Step title="Synchronize respondent evaluations">
    <p>Since an asynchronous response approach is recommended, you can synchronize respondent evaluations from ReDem at any time.</p>

    <p> To streamline the process, you can set up an automated job that performs the synchronization on a regular basis, ensuring your data remains up-to-date without requiring manual intervention. </p>

    <p>To do this, you can use the [Get Respondent](/redem/api-reference/endpoints/v3/getRespondent) endpoint or the [Get All Respondents](/redem/api-reference/endpoints/v3/getAllRespondents) endpoint.</p>
  </Step>
</Steps>
