Skip to main content

Service Task — REST API 🌍

Makes HTTP calls to external REST APIs.

Node type: serviceTask (subtype: REST API) Category: Integration Actor: serviceTask (2 threads)


Description

The REST API Service Task sends HTTP requests to external APIs and captures the response as workflow variables. It supports all standard HTTP methods, configurable headers, authentication, and request bodies.

Credentials (base URL, auth tokens) are stored in a REST API Integration — the node only configures the specific endpoint path and request details.


Properties

PropertyTypeRequiredDescription
restApiConnectionIdstringYesID of the REST API integration (base URL + auth config)
endpointPathtextYesPath appended to the base URL. Supports {varName} references
methodselectYesHTTP method: GET, POST, PUT, PATCH, DELETE
bodytextareaNoRequest body (JSON string). Supports {varName} references

Inputs

Use {varName} syntax in endpointPath and body:

endpointPath: /customers/{customerId}/orders
method: POST
body: {
"orderId": "{orderId}",
"amount": "{total}",
"currency": "USD",
"customerEmail": "{email}"
}

Outputs

The Service Task captures the HTTP response and stores it as:

VariableTypeDescription
{serviceTaskResponse}string/objectThe response body (auto-parsed if JSON)
{serviceTaskStatusCode}numberHTTP status code (e.g., 200, 404)
{serviceTaskHeaders}objectResponse headers

If the response body is valid JSON, individual fields are accessible:

  • {serviceTaskResponse.id} — accesses the id field of the JSON response
  • {serviceTaskResponse.data.name} — nested access

Custom Output Variable

You can configure a custom output variable name in the node properties to avoid conflicts when multiple service tasks run in sequence.


Connection Flow

ConditionConnection Used
HTTP 2xx responsesuccessFlow (or sequenceFlow if no success flow defined)
HTTP 4xx / 5xx responseerrorFlow
Request timeouttimeoutFlow

Example: Fetch Customer Data

{
"nodeId": "fetch-customer-1",
"name": "Fetch Customer Details",
"nodeType": "serviceTask",
"properties": {
"restApiConnectionId": "int_crm_api",
"endpointPath": "/v2/customers/{customerId}",
"method": "GET"
},
"timeout": {
"duration": 10,
"durationUom": "SECONDS",
"action": "FAIL"
},
"retry": {
"maxAttempts": 3,
"delay": 2,
"delayUom": "SECONDS"
}
}

The response is stored as {serviceTaskResponse}. Access fields like {serviceTaskResponse.name}, {serviceTaskResponse.email} in downstream nodes.


Example: Create Order (POST)

{
"nodeId": "create-order-1",
"name": "Create Order in ERP",
"nodeType": "serviceTask",
"properties": {
"restApiConnectionId": "int_erp_api",
"endpointPath": "/orders",
"method": "POST",
"body": "{\"customerId\": \"{customerId}\", \"items\": {orderItems}, \"total\": {orderTotal}}"
}
}

Authentication

Authentication is configured at the Integration level, not the node level:

Auth TypeHow Configured
NoneNo auth header sent
Bearer TokenAdds Authorization: Bearer {token} header automatically
Basic AuthAdds Authorization: Basic {base64} header
API Key HeaderAdds custom header (e.g., X-API-Key: {value})
OAuth2 Client CredentialsFetches + caches access token before each call

You can also add static headers at the integration level (e.g., Accept: application/json).


Error Handling

ScenarioVariableValue
HTTP 4xx error{serviceTaskStatusCode}400, 401, 404, etc.
HTTP 5xx error{serviceTaskStatusCode}500, 502, 503, etc.
Response body on error{serviceTaskResponse}Error response body from the API
Connection timeoutTakes timeoutFlow
DNS resolution failureTakes errorFlow_error = CONNECTION_ERROR

Best Practices

  • Always configure successFlow and errorFlow connections for production workflows
  • Set a timeout — external APIs can hang indefinitely without one
  • Use retry (2–3 attempts) for idempotent GET requests; be careful with POST/PUT
  • Store API base URLs and credentials in integrations, not in node properties
  • Use {serviceTaskStatusCode} in downstream If/Else nodes to handle specific HTTP error codes differently
  • For APIs that return paginated results, use a Loop node to iterate through pages