When and Why to Use
Use this to make outbound HTTP requests to approved external APIs during a survey. This is useful for:
Personalizing content based on real-time data
Validating input or IDs
Logging or syncing responses to external systems
β οΈ Note: All external domains must be allow-listed by MX8 Labs prior to use.
Configuration Options
Parameter | Type | Required | Default | Description |
|
| yes | - | Full endpoint URL (must be allow-listed) |
|
| yes | - | HTTP method: "GET" or "POST" |
|
| no |
| Data payload for |
|
| no |
| URL query parameters for |
|
| no |
| Additional HTTP headers (e.g. auth tokens) |
|
| no |
| Timeout in seconds before request fails |
Example Code
s.call_api( url="https://api.myservice.com/userinfo", method="GET", params={"user_id": respondent_id}, headers={"Authorization": "Bearer xyz123"} )
For a POST
request:
s.call_api( url="https://api.myscorer.com/evaluate", method="POST", data={"answers": user_answers}, headers={"Content-Type": "application/json"} )
Notes
Only allow-listed domains will work β contact MX8 Labs to add new domains
call_api
returns aStringResponse
, which you can capture and use in follow-up logicThe function will raise a
ValueError
if an unapproved domain is usedHandle timeout errors and unexpected responses in your downstream logic as needed