Import
createClient
Signature
HttpClient) pre-configured with base URL, headers, retry logic, and optional debug logging. All standard Axios request methods (get, post, put, patch, delete, request, etc.) are available on the returned client.
ClientProps
The base URL prepended to every request (e.g.
"https://api.acme.com/v2").Expected response format. Passed directly to Axios. Common values:
"json", "arraybuffer", "text", "document".Headers sent with every request. Typically used for
Authorization or Content-Type.URL search parameters added to every request.
Maximum time in milliseconds to wait for a response. Defaults to no timeout.
When
true, logs all request and response details (URL, headers, method, status) using context.logger. Large payloads (over 10 KB) and buffers are summarized by size.Retry configuration. See RetryConfig below.
Return value
RetryConfig
Number of retry attempts. Set to
0 to disable retries.Fixed delay in milliseconds between retries, or a function
(retryCount, error) => number. Ignored when useExponentialBackoff is true.When
true, retries on all error responses including 4xx. When false, retries only on 5xx and network errors (unless overridden by retryCondition).When
true, uses exponential backoff between retries (1×, 2×, 4×, 8× the base delay). If retryDelay is a number, that number is used as the base. Otherwise, uses axios-retry’s built-in exponential delay function.Custom function to decide whether a specific error should trigger a retry. Overrides the default behavior when
retryAllErrors is false.Authentication helpers
toAuthorizationHeaders (internal)
The HTTP client module exports a privatetoAuthorizationHeaders helper used by buildRawRequestAction. It inspects a Connection and returns the correct Authorization header:
| Connection type | Header value |
|---|---|
OAuth 2.0 (has token.access_token) | Bearer <access_token> |
API key (has fields.apiKey) | Bearer <apiKey> |
Basic auth (has fields.username + fields.password) | Basic <base64(username:password)> |
toFormData (internal)
Builds amultipart/form-data FormData object from key-value pairs. File data is converted to a Buffer via util.types.toBufferDataPayload.
handleErrors
Signature
message, data, status, and headers. Otherwise returns the error unchanged. Use in a catch block to surface HTTP response details.
sendRawRequest
Signature
buildRawRequestAction. Throws when both data and form data inputs are specified simultaneously.
buildRawRequestAction
Signature
connection input plus the standard HTTP inputs.
Pre-built inputs
Theinputs export provides pre-built InputDefinition objects for all standard HTTP request fields. Import them when building custom HTTP actions:
| Input key | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Relative or absolute URL path |
method | string | Yes | HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, LINK, PURGE, UNLINK) |
data | string | No | Request body payload |
formData | keyvaluelist | No | Form fields for multipart form upload |
fileData | keyvaluelist | No | File fields for multipart form upload |
fileDataFileNames | keyvaluelist | No | File names to apply to fileData keys |
queryParams | keyvaluelist | No | URL query parameters |
headers | keyvaluelist | No | Request headers |
responseType | string | Yes | Expected response type: json, text, arraybuffer, document. Default: json |
timeout | string | No | Request timeout in milliseconds |
debugRequest | boolean | No | Log request and response details |
maxRetries | string | No | Maximum retry attempts. Default: 0 |
retryDelayMS | string | No | Delay between retries in milliseconds. Default: 0 |
retryAllErrors | boolean | No | Retry on all errors, including 4xx. Default: false |
useExponentialBackoff | boolean | No | Use exponential backoff for retries. Default: false |
Examples
Related
- util.types — type coercion helpers used throughout the HTTP client
- createConnection — create test connection values for unit tests
