logo_smallAxellero.io

REST API

Execute HTTP requests to REST APIs with authentication and response handling.

REST API Node

Make HTTP requests to REST APIs with full support for all HTTP methods, authentication schemes, and response processing in Axellero workflows.

Features

  • Complete HTTP Method Support: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
  • Flexible Authentication: API Key, Bearer Token, Basic Auth, OAuth2, Custom Headers
  • Dynamic Request Building: Headers, query parameters, request body configuration
  • Response Processing: Status code handling, header extraction, JSON/XML parsing
  • Error Handling: Configurable retry logic and error response processing

Workflow Integration

REST API nodes have access to workflow execution context, allowing use of data from previous nodes, variables, and user information in API requests.

Quick Navigation

Connector Configuration

The REST API node uses reusable connector configuration for common API settings:

ParameterTypeRequiredDescription
baseUrlTEXTYesBase URL of the API (e.g., https://api.example.com)
timeoutINTNoRequest timeout in milliseconds (default: 30000)
retryAttemptsINTNoNumber of retry attempts on failure (default: 0)
retryDelayINTNoDelay between retries in milliseconds (default: 1000)

Authentication Methods

Credential Security

Do not hardcode credentials in workflows. Use environment variables or secure credential references.

API Key Authentication

Configure API key authentication in headers or query parameters:

{
  "baseUrl": "https://api.example.com",
  "headers": {
    "X-API-Key": "{{ctx.consts.API_KEY}}",
    "Content-Type": "application/json"
  }
}
{
  "baseUrl": "https://api.example.com",
  "queryParams": {
    "apikey": "{{ctx.consts.API_KEY}}",
    "format": "json"
  }
}

Bearer Token Authentication

For OAuth2 and JWT token-based authentication:

{
  "baseUrl": "https://api.example.com",
  "headers": {
    "Authorization": "Bearer {{ctx.vars.accessToken}}",
    "Content-Type": "application/json"
  }
}

Basic Authentication

HTTP Basic Authentication with username and password:

{
  "baseUrl": "https://api.example.com",
  "auth": {
    "type": "basic",
    "username": "{{ctx.consts.USERNAME}}",
    "password": "{{ctx.consts.PASSWORD}}"
  }
}

OAuth2 Authentication

OAuth2 flow with automatic token refresh:

{
  "baseUrl": "https://api.example.com",
  "auth": {
    "type": "oauth2",
    "clientId": "{{ctx.consts.OAUTH_CLIENT_ID}}",
    "clientSecret": "{{ctx.consts.OAUTH_CLIENT_SECRET}}",
    "tokenUrl": "https://api.example.com/oauth/token",
    "scope": "read write"
  }
}

HTTP Methods

GET Request

Retrieve data from an API endpoint:

ParameterTypeRequiredDescription
endpointTEXTYesAPI endpoint path (e.g., /users/123)
queryParamsOBJECTNoQuery parameters as key-value pairs
headersOBJECTNoAdditional HTTP headers
{
  "method": "GET",
  "endpoint": "/users/{{ctx.vars.userId}}",
  "queryParams": {
    "include": "profile,settings",
    "fields": "id,name,email"
  },
  "headers": {
    "Accept": "application/json",
    "X-Client-Version": "2.1.0"
  }
}

POST Request

Create new resources or submit data:

ParameterTypeRequiredDescription
endpointTEXTYesAPI endpoint path
bodyOBJECT/STRINGNoRequest body data
contentTypeTEXTNoContent-Type header (auto-detected from body)
headersOBJECTNoAdditional HTTP headers
{
  "method": "POST",
  "endpoint": "/users",
  "body": {
    "name": "{{ctx.nodes.userInput.outputs.name}}",
    "email": "{{ctx.nodes.userInput.outputs.email}}",
    "role": "user"
  },
  "headers": {
    "Content-Type": "application/json"
  }
}

PUT Request

Update existing resources completely:

{
  "method": "PUT",
  "endpoint": "/users/{{ctx.vars.userId}}",
  "body": {
    "name": "{{ctx.vars.updatedName}}",
    "email": "{{ctx.vars.updatedEmail}}",
    "status": "active"
  }
}

PATCH Request

Partial updates to existing resources:

{
  "method": "PATCH",
  "endpoint": "/users/{{ctx.vars.userId}}",
  "body": {
    "status": "{{ctx.vars.newStatus}}"
  }
}

DELETE Request

Remove resources from the API:

{
  "method": "DELETE",
  "endpoint": "/users/{{ctx.vars.userId}}",
  "headers": {
    "X-Reason": "{{ctx.vars.deletionReason}}"
  }
}

Workflow Context Integration

📖 Reference

For context documentation, see the Workflow Context reference.

Dynamic URL Construction

Build endpoints using workflow data:

{
  "method": "GET",
  "endpoint": "/organizations/{{ctx.user.attrs.orgId}}/users",
  "queryParams": {
    "page": "{{ctx.vars.currentPage}}",
    "limit": "{{ctx.consts.PAGE_SIZE}}",
    "role": "{{ctx.nodes.roleFilter.outputs.selectedRole}}"
  }
}

Conditional Request Headers

Add headers based on workflow conditions:

{
  "method": "POST",
  "endpoint": "/data/upload",
  "headers": {
    "Content-Type": "{{ctx.vars.fileType || 'application/json'}}",
    "X-User-Role": "{{ctx.user.roles[0]}}",
    "X-Workspace": "{{ctx.workspace_slug}}"
  },
  "body": "{{ctx.nodes.dataProcessor.outputs.processedData}}"
}

Request Body from Previous Nodes

Use outputs from other workflow nodes:

{
  "method": "POST",
  "endpoint": "/analytics/events",
  "body": {
    "eventType": "{{ctx.nodes.eventClassifier.outputs.type}}",
    "data": "{{ctx.nodes.dataTransformer.outputs.result}}",
    "timestamp": "{{ctx.nodes.timer.outputs.currentTime}}",
    "userId": "{{ctx.user.id}}"
  }
}

Response Processing

Success Response Format

{
  "statusCode": 200,
  "headers": {
    "content-type": "application/json",
    "x-rate-limit-remaining": "99"
  },
  "data": {
    "id": 12345,
    "name": "John Doe",
    "email": "john@example.com"
  },
  "success": true
}

Error Response Format

{
  "statusCode": 404,
  "headers": {
    "content-type": "application/json"
  },
  "data": {
    "error": "User not found",
    "code": "USER_NOT_FOUND"
  },
  "success": false,
  "error": "HTTP 404: User not found"
}

Status Code Handling

Automatic Success Detection

Status codes 200-299 are automatically marked as successful. Use workflow conditions to handle specific status codes for business logic.

Response Validation Example:

{
  "method": "GET",
  "endpoint": "/health",
  "validateStatus": [200, 201, 202],
  "onError": "continue"
}

Editor Features

REST API Editor Capabilities:

  • Endpoint Auto-completion: Suggestions for common REST patterns
  • Header Templates: Pre-configured headers for popular APIs
  • Authentication Helpers: Guided setup for common auth methods
  • Request Validation: Real-time validation of request structure
  • Response Preview: Live preview of API responses during testing

For complete editor details, see Code Editing & Schema Reference.

Common Patterns

Pagination Handling

{
  "method": "GET",
  "endpoint": "/data",
  "queryParams": {
    "page": "{{ctx.vars.page || 1}}",
    "limit": "50"
  }
}

Error Retry Logic

{
  "method": "POST",
  "endpoint": "/critical-operation",
  "retryAttempts": 3,
  "retryDelay": 2000,
  "retryOn": [502, 503, 504]
}

Rate Limiting Awareness

{
  "method": "GET",
  "endpoint": "/api/data",
  "headers": {
    "X-Rate-Limit-Tier": "premium"
  },
  "timeout": 45000
}

Security Best Practices

Security Guidelines

  • Never hardcode credentials in request configurations
  • Use HTTPS for all API communications
  • Validate SSL certificates in production environments
  • Implement proper error handling to avoid credential leaks
  • Use least-privilege access with API keys and tokens

Getting Started

  1. Configure Base Settings: Set up your API's base URL and authentication
  2. Choose HTTP Method: Select the appropriate method for your operation
  3. Configure Endpoint: Define the specific API endpoint and parameters
  4. Set Up Authentication: Add API keys, tokens, or other auth methods
  5. Test the Request: Validate the request configuration and response handling
  6. Handle Responses: Process success and error responses in your workflow

Resources