Search through more than a hundred articles on every aspect of User.com

Grzegorz Kacperski
Written by Grzegorz Kacperski

Module guide: API call

Send an API call to your app


How it works

The module works very similarly to webhooks, but instead of triggering when a message is sent, it is used if any other conditions are met. You can send all user data to a specific URL.

The field "URL" is for where to send the request (to another app or platform), and "Extra data (JSON)" is the content you want to send in addition to the user details.

Explanation of the individual components of the module

To know exactly how to use API Call to implement your own business processes, in combination with other applications, it is good to learn how to transfer this data first.

Let us take the example given below:

  • URL - here we can add our own endpoint that will be used to connect to the selected application. What's more, if you specify pairs of variable <> value as a parameter directly in this URL, we can send these values as Query strings (values can also be handled by snippet tags, but this is only possible with the HTTP - GET method)
  • Extra data (JSON) - allows you to send complex data in JSON format. This input also supports snippet tags - you just have to remember to put these snippets in quotes, otherwise we will get the error "Enter valid JSON"
  • Exclude user info from call - we can easily use this toggle, in case when we do not want, apart from the additional data sent in the input above, all other data related to the user's profile were sent. Instead of sending the entire data list as in the example below:
 {
  "path": 6,
  "timestamp": "2021-02-01T07:27:44.469241+00:00",
  "extra": {
    "variable_1": "value_1"
  },
  "user": {
    "id": 7,
    "key": "x7NM5xw2eFxl",
    "name": "John Doe",
    "email": "johndoe@example.org",
    "gender": "unknown",
    "status": "visitor",
    "phone_number": null,
    "first_seen": "2021-01-07T13:33:24.576109Z",
    "last_seen": "2021-01-07T13:33:24.604490Z",
    "page_views": 1,
    "last_ip": "99.99.99.99",
    "timezone": "USA/DC",
    "city": null,
    "region": null,
    "country": "USA",
    "emails_enabled": true,
    "browser_language": "en",
    "score": 0,
    "browser": "Chrome",
    "os_type": "Mac OS X",
    "resolution": "1440x900",
    "created_at": "2021-01-07T13:33:24.585602Z",
    "updated_at": "2021-01-12T15:08:07.917571Z",
    "attributes": [],
    "gravatar_url": null,
    "lists": [],
    "tags": [
      {
        "id": 16,
        "name": "random_tag"
      }
    ],
    "notifications": true,
    "facebook_url": null,
    "linkedin_url": null,
    "twitter_url": null,
    "google_url": null,
    "last_contacted": "2021-01-07T13:33:40.598000Z",
    "user_id": "random_id"
  }
}

we will be able to send only the necessary data given in Extra data:

{
  "path": 6,
  "timestamp": "2021-02-01T07:34:23.815674+00:00",
  "extra": {
    "variable_1": "value_1"
  }
}
  • Add header - in case when API requests you want to use when connecting to the other application require authorization, it will be necessary to add such headers as "Authorization" or "Content-Type" with the corresponding values. Each next header is added by clicking the Add header button:


Case Study

If somebody registers on your website, let’s create an automation with the API Call to your app with the data. All you need to do is start with Event trigger: Register_newsletter (when a person subscribes), now, add the action module Send an email campaign.

Now, whenever somebody subscribes, there will be an email campaign sent to verify the email address. Through the exit node, on click, connect to the action module Update an attribute (newsletter: true).

Now, connect Event trigger to API call. (Remember to configure the module!) This way, you can send any data you need in an automated way.

Categories: