Knowledge Base

View Categories

Postback URL and DSU Variables

Understanding Postback URL and DSU Variables

This guide explains how to use Postback URL and Direct Scan to URL (DSU) features for efficient data collection and validation, even when Internet connectivity is unavailable. Follow these steps to ensure seamless functionality and maximize the value of your scanning services.

Recording Scans Without Connectivity

When using Postback URL or DSU, Internet connectivity is required for validating scans against an online database. However, you can enable offline recording for uninterrupted operation:

  • Enable Auto-Sync: On the Advanced settings of your service, turn on “Auto-Sync.”
  • Set Auto-Next Scan to “Always”: Under “Auto-Next Scan,” select “Always (Save if error).”

Once connectivity is restored, saved records are automatically uploaded to the designated Postback URL or DSU.

Adding a Custom Key

Until API 2.0 is released, adding a custom HTTP header to posts isn’t supported. Here’s how you can include a custom key:

  • Append a Key to the URL: Add your key as a query parameter, e.g., ?key=1234567890.
  • Use an Export Template: Add the key via the “Custom Field” option in the Export Template.

Note: For DSU, you can only use default variables since Export Templates are not supported.

IP Whitelisting for Secure Access

To ensure secure communication, whitelist the necessary IP addresses. You can find the required IPs in the API section of your Account page.

Handling HTML Responses

When responding with HTML, ensure that all content is properly escaped. For example, avoid using raw HTML tags without escaping. Refer to general escaping guidelines for assistance.

Timestamp Information

  • Postback URL: Scans include timestamps in Eastern Time. Additionally, a UTC timestamp is provided under the scanned_at_utc variable.
  • DSU: Scans include both the scanned_at_utc variable (UTC) and the device_timestamp variable (in the device’s local time zone).

Postback Variables vs. Export Templates

  • Postback URL: Customize the data your server receives using an Export Template.
  • DSU: Variables are fixed and cannot be customized via templates.

Echo Postback for Debugging

To test what data your server receives:

  • Add an echo at the beginning of your Postback script.
  • Use a command like this to email the POST data:
    • mail(“my@email.com”, “Echo POSTBACK”, print_r($_POST,true));

This ensures you receive the POST data even if there’s an issue with your script.

Using WebHook.Site for Testing

WebHook.Site is an alternative to Echo Postback. It allows you to visualize form and raw data submitted via Postback and supports Question data.

Managing Question and Answer Data

array for postback

When handling questions and answers, treat the data as an associative array where keys represent question IDs.
For example:

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

Key Consideration:

  • Pre-submit questions generate answers in the same POST.
  • Post-submit questions create separate posts with identical IDs for easy correlation.