Tasks
API Call
Calls external APIs from a Stubber action and returns data for later tasks. Useful for REST integrations, data lookup, webhooks, and service-to-service automation.
Use cases
- Integrate seamlessly with a REST API endpoint.
- Perform a POST request with a specified body.
- Trigger an API call upon executing a specific action.
- Retrieve data from third-party systems.
- Call an API endpoint requiring client certificate authentication.
- Invoke a webhook on a stub.
Basic usage
Parameters
apiurl required string
The endpoint that the task will invoke.
query_params optional object
Query string parameters to append to the URL. Each key-value pair is added as a query parameter. This is an alternative to embedding query strings directly in apiurl.
Example:
method optional string
The HTTP method to be used for the API call.
For example you can use GET, POST, PUT, DELETE, PATCH.
Any HTTP verbs are supported.
Default: GET
headers optional object
Any headers that you wish to include in the request. This is where you would typically put the Authorization header.
Default:
body optional object
The body in JSON that you would like to send as part of the request. The body would typically use variable substitution to bring in data values from the stub or stubpost.data.
allow_body_on_get optional boolean
When true, allows a body to be sent with a GET request. This is technically valid HTTP but uncommon — some APIs (particularly older or non-standard ones) require it. Has no effect on other HTTP methods.
Default: false
Example:
timeout_seconds optional number
The seconds after which the apicall will time out.
Default: 15
org_credentials optional object
The org credentials to use for an API call. This requires setting up the org credentials on the Credentials page of Stubber Console.
Example:
response_merge optional object
An object that is deep-merged into the apiresult after the API call completes, before the result is made available to subsequent tasks or stub/stubpost data. This allows you to overwrite, hide, or transform fields in the response.
response_merge is interpolated using the apicall interpolator, not the standard one. This means interpolation happens after the API call, giving you access to payload.apiresult in your expressions. To target this step explicitly, use the ~~#target 'apicall'# syntax. See Hashtag Helpers: Target for details.
Example — hash a sensitive field from the response:
response_options optional object
Configuration options that control what is included in the apiresult returned by the task.
Example:
Result
Properties
apiresult.status
The status code indicating the outcome of the API call.
apiresult.statusText
A textual description of the result status.
apiresult.body
Contains the body of the API result, providing the actual data retrieved from the external API. The type depends on the API response but is typically a JSON object or array.
Examples
These are some more complex examples
Request with body
Include a body in your apicall request
Request with headers
Include custom headers in your apicall request
Upload file with multipart/formdata
Upload a file as part of a multipart/form-data request
Custom Header Org Credential
This requires the Custom Header credential to be created in the organization's Credentials page of Stubber Manage.
Response merge
Use response_merge to overwrite fields in the API response before they are exposed to the rest of the template. This is useful for hiding sensitive data or limiting what gets stored in stub/stubpost data.
In this example, meta and reviews are removed from the result and price is replaced with its MD5 hash using the apicall interpolator, which has access to payload.apiresult.
NTLM Org Credential
This requires the NTLM credential to be created in the organization's Credentials page of Stubber Manage. Typically used for authenticating with older Microsoft systems.
OAuth Org Credential
This requires the Generic OAuth credential to be created in the organization's Credentials page of Stubber Manage.