Setting up Call API Block in Flow
Last updated
Last updated
Call API Block provides automated HTTP callback functions that you can use to perform an API request by various methods, including GET, POST, PUT, DELETE etc.
Choose a Request method and enter your URL endpoint of the external API.
You can make your URL dynamic by inserting variables into the path. For the user input variable that you set up in the flow, for example, it is called "order_num", you can call it with {{order_num}}. For custom fields, for a field called "membership", you can call it {{customFields.membership}}.
Headers in HTTP webhook requests are used to specify the purpose of the API or its content type.
It is optional to use headers. It is under Additional Settings and is turned off by default. Headers are set as key-value pairs.
e.g. key = Content-Type & value = application/json
The body of the API request is added here. This is also optional and set as off by default. The body must always be in JSON format.
Formatting Tips:
Strings and Variables must be wrapped in quotes > {{name}}
A comma is needed between 2 key-value pairs > "Email": "{{email}}", "Name": "{{name}}"
If the variable is a custom field but not a default field (i.e. name, email, phone), for example the field name is membership, the format should be > “{{customFields.membership}}“
Manually set your test variables by clicking "Add Variables".
You can test the API request by clicking on the 'Test the request' button.
You can also save the response of a request into variables or custom attributes. If your API response is a JSON with a key-value pair, you can store each of the values by passing the key name.
Storing Response Values that are Inside an Object:
If you want to store the response value that is inside an object, you need to use the objectkey.keyname
format.
Example: if you want to store the userId
, you have to use Result.userId
in the "Entire response Body" above
Storing Responses that are Inside an Array of the Object:
If you want to store the response value that is inside an Array of an object, you need to use the $.[0].objectkey.keyname[0].value
format
Example: if you want to store shipping_status
, you have to use $.[0].order_tracking.shipment_track[0].shipping_status
in the "Entire response Body" above
You can use response routing to split your flow according to response status codes. By default each Call API Block has "success" and "failed" node. You can optionally add custom status code as you need.