Here are the changes to webhook data structure in Impact Stack 2 compared to Impact Stack 1.

As a reminder, the documentation for Impact Stack webhooks is here: https://impact-stack.readthedocs.io/en/latest/events/

1. The structure of optins has changed

This is how the optins object is sent over by Impact Stack 1. In the example below, the numbers (”32” and “2”) would be the id of the component. This is a Drupal-specific thing that doesn’t exist in Impact Stack 2.

{
  "optins": {
    "32": {
      "channel": "email",
      "operation": "opt-in"
    },
    "2": {
      "channel": "phone",
      "operation": "no-change"
    }
  }
}

Impact Stack 2 uses a more explicit data structure for optins. Integrations that handle opt-in data may need to look in the optins array instead.

Read specific guidance on optins in the webhook documentation here: https://impact-stack.readthedocs.io/en/latest/events/form-submission.html#opt-in-data-optins

{
  "optins": [
    {
      "channel": "phone",
      "operation": "no-change"
    },
    {
      "channel": "email",
      "operation": "opt-in"
    }
  ]
}

2. Form fields must now be read from data

Version 1 put form submission data on both the root-level and in a dedicated data object. In these examples email and first_name are the identifiers of the form fields asking for the supporter’s email address and first name. This is known as the “form key” in the user interface of Impact Stack 1 and the “field name” in Impact Stack 2.

email: [email protected]
first_name: First

data:
  email: [email protected]
  first_name: First

Version 2 only has the data object.

data:
  email: [email protected]
  first_name: First

You may already use event.data to access form submission data eg event.data.email in which case you shouldn’t need to make changes.

In case you are currently using the root-level data eg event.email, you will need to change your integration to use, for example, event.data.email to access the email address in a form submission instead.

3. Various dates consolidated into date

If you look for any of the following to get the date a submission was made, they have changed. Use date instead.

completed_at
submitted_at
_completed_at
_submitted_at

4. Identify test submissions with test_mode