Postback URL and DSU Variables

Helpful tips when programming for Postback URL and DSU

Variables vs. Export Template

When using Postback URL, you can define what your server receives based on an Export Template.

Miscellaneous Notes

  1. Adding your own KEY.  Until API 2.0 is released (Q4 2019), there isn’t an option to add a custom HTTP header to posts. Here are your current options:
    • To the URL you can add your own key; for example ?key=1234567890.
    • Another option is using the Export Template’s “Custom Field” option for the key. If you are using the API to create services, please look here for how to add a template to the service creation API.
      • Note: For Direct Scan to URL (DSU) you will only receive the default variables shown below since you cannot use an Export Template with DSU.
  2. You can find the IP addresses for whitelisting on the Account page under the API tab.
  3. Responding with HTML: You need to escape what goes inside the text node. For example, you can’t just put “html” with brackets (general escaping examples here).

Echo Postback

If you want to see what is posted to your server, you can put an ‘echo’ at the beginning of your postback. Then, the post received will be emailed to you. Also, if placed at the beginning of your script, you should still get the email even if there’s a problem with your script.

Though setting up an echo will vary based on your programming language, here’s one example:

mail(“”, “Echo POSTBACK”, print_r($_POST,true));

Questions and Answers

Treat answers not as a plain array but as an associative array or a dictionary where the keys are question IDs.

A normal index array is this:

answers[1] = answer X
answers[2] = answer Y
answers[n] = answer Z

We are not posting it that way. We are posting based on the questions created and assigned to the service. Thus, given assigned questions with question id #1111 and #2222 to your service, when someone scans and submits the post will be:

answers[1111] = answer for question id 1111
answers[2222] = answer for question id 2222

array for postback

Note: Also, you need to consider when the answers are submitted. If you have pre-submit questions, the answers will come with the one post. Moreover, if you have post-submit questions, you will receive two posts with the same ID for you to know the relation.