Skip to main content

Overview

AutoMFlows provides powerful API testing capabilities with two dedicated node types:
  • API Request: Configure HTTP requests with full control over method, headers, body, and authentication
  • API cURL: Import and execute cURL commands directly
Both nodes support retry strategies, response validation, and context integration.

API Request Node

The API Request node makes HTTP requests with configurable parameters.

Basic Request

{
  "type": "apiRequest",
  "data": {
    "label": "Get User Data",
    "method": "GET",
    "url": "https://api.example.com/users/123",
    "timeout": 30000,
    "contextKey": "apiResponse"
  }
}

HTTP Methods

AutoMFlows supports all standard HTTP methods:
Retrieve data from the server:
{
  "method": "GET",
  "url": "https://api.example.com/users"
}

Headers

Configure request headers for authentication and content types:
{
  "headers": {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "Content-Type": "application/json"
  }
}

Request Body

The API Request node supports multiple body types:

JSON Body

{
  "bodyType": "json",
  "body": '{"name": "John Doe", "email": "[email protected]", "age": 30}',
  "headers": {
    "Content-Type": "application/json"
  }
}
JSON bodies are automatically validated and formatted. Invalid JSON throws an error before execution.

Form Data

Send multipart form data with fields and files:
{
  "bodyType": "form-data",
  "formFields": [
    { "key": "name", "value": "John Doe" },
    { "key": "email", "value": "[email protected]" }
  ],
  "formFiles": [
    { "key": "avatar", "filePath": "./uploads/avatar.png" },
    { "key": "document", "filePath": "./uploads/resume.pdf" }
  ]
}

URL-Encoded Form

{
  "bodyType": "x-www-form-urlencoded",
  "formFields": [
    { "key": "username", "value": "[email protected]" },
    { "key": "password", "value": "secret123" }
  ]
}

Raw Body

{
  "bodyType": "raw",
  "body": "<soap:Envelope>...</soap:Envelope>",
  "headers": {
    "Content-Type": "text/xml"
  }
}

API cURL Node

Import cURL commands directly into AutoMFlows:
{
  "type": "apiCurl",
  "data": {
    "label": "Execute cURL Command",
    "curlCommand": "curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -d '{\"name\": \"John\"}'",
    "timeout": 30000,
    "contextKey": "apiResponse"
  }
}
The cURL parser automatically extracts method, URL, headers, body, and form data from the command string.

cURL Examples

curl -X GET https://api.example.com/users \
  -H "Authorization: Bearer token123" \
  -H "Accept: application/json"

Response Handling

API responses are stored in the execution context with the following structure:
{
  "status": 200,
  "statusText": "OK",
  "headers": {
    "content-type": "application/json",
    "content-length": "1234"
  },
  "body": {
    "id": 123,
    "name": "John Doe",
    "email": "[email protected]"
  },
  "duration": 234,  // ms
  "timestamp": "2026-03-07T10:00:00.000Z"
}

Accessing Response Data

Use variables to access response data in subsequent nodes:
{
  "type": "apiRequest",
  "data": {
    "url": "https://api.example.com/users/${apiResponse.body.id}/profile",
    "headers": {
      "Authorization": "Bearer ${authToken}"
    }
  }
}

API Verification

Verify API responses using the Verify node:
{
  "type": "verify",
  "data": {
    "domain": "api",
    "verificationType": "statusCode",
    "expectedValue": "200"
  }
}

Retry Strategies for APIs

Configure retry behavior for transient API failures:

Retry by Count

{
  "retryEnabled": true,
  "retryStrategy": "count",
  "retryCount": 3,
  "retryDelay": 1000,
  "retryDelayStrategy": "exponential",
  "retryMaxDelay": 10000
}
Exponential backoff increases delay between retries: 1s, 2s, 4s, 8s, 10s (capped at maxDelay).

Retry Until Condition

{
  "retryEnabled": true,
  "retryStrategy": "untilCondition",
  "retryUntilCondition": "apiResponse.status === 200 && apiResponse.body.processed === true",
  "retryCount": 10,
  "retryDelay": 2000
}
Be cautious with retry strategies on state-changing operations (POST, PUT, DELETE) to avoid duplicate actions.

Variable Interpolation

Use context variables in API requests:
{
  "url": "https://api.example.com/users/${userId}",
  "headers": {
    "Authorization": "Bearer ${authToken}",
    "X-Request-ID": "${requestId}"
  },
  "body": '{"email": "${userData.email}", "name": "${userData.name}"}'
}
Variables are interpolated at execution time using the ${variableName} syntax.

Trace Logging

Enable trace logs to see detailed request and response information:
{
  "executionMode": "single",
  "traceLogs": true,
  "workflow": { /* ... */ }
}
Trace logs include:
  • Request method, URL, headers, body
  • Response status, headers, body
  • Request duration
  • Timestamps

Complete API Test Example

Here’s a complete workflow that tests a REST API:
{
  "nodes": [
    {
      "id": "start-1",
      "type": "start",
      "data": { "label": "Start" }
    },
    {
      "id": "auth-1",
      "type": "apiRequest",
      "data": {
        "label": "Authenticate",
        "method": "POST",
        "url": "https://api.example.com/auth/login",
        "headers": { "Content-Type": "application/json" },
        "body": '{"email": "[email protected]", "password": "secret"}',
        "bodyType": "json",
        "contextKey": "authResponse"
      }
    },
    {
      "id": "verify-auth-1",
      "type": "verify",
      "data": {
        "label": "Verify Auth Success",
        "domain": "api",
        "verificationType": "statusCode",
        "expectedValue": "200"
      }
    },
    {
      "id": "get-users-1",
      "type": "apiRequest",
      "data": {
        "label": "Get Users",
        "method": "GET",
        "url": "https://api.example.com/users",
        "headers": {
          "Authorization": "Bearer ${authResponse.body.token}"
        },
        "contextKey": "usersResponse"
      }
    },
    {
      "id": "verify-users-1",
      "type": "verify",
      "data": {
        "label": "Verify Users Retrieved",
        "domain": "api",
        "verificationType": "statusCode",
        "expectedValue": "200"
      }
    },
    {
      "id": "create-user-1",
      "type": "apiRequest",
      "data": {
        "label": "Create New User",
        "method": "POST",
        "url": "https://api.example.com/users",
        "headers": {
          "Authorization": "Bearer ${authResponse.body.token}",
          "Content-Type": "application/json"
        },
        "body": '{"name": "Test User", "email": "[email protected]"}',
        "bodyType": "json",
        "contextKey": "createUserResponse",
        "retryEnabled": true,
        "retryCount": 3,
        "retryDelay": 1000
      }
    },
    {
      "id": "verify-create-1",
      "type": "verify",
      "data": {
        "label": "Verify User Created",
        "domain": "api",
        "verificationType": "statusCode",
        "expectedValue": "201"
      }
    },
    {
      "id": "verify-email-1",
      "type": "verify",
      "data": {
        "label": "Verify Email",
        "domain": "api",
        "verificationType": "jsonPath",
        "jsonPath": "$.data.email",
        "expectedValue": "[email protected]"
      }
    }
  ],
  "edges": [
    { "source": "start-1", "target": "auth-1" },
    { "source": "auth-1", "target": "verify-auth-1" },
    { "source": "verify-auth-1", "target": "get-users-1" },
    { "source": "get-users-1", "target": "verify-users-1" },
    { "source": "verify-users-1", "target": "create-user-1" },
    { "source": "create-user-1", "target": "verify-create-1" },
    { "source": "verify-create-1", "target": "verify-email-1" }
  ]
}

Executing via API

Run API tests using the AutoMFlows REST API:
curl -X POST http://localhost:3003/api/workflows/execute \
  -H "Content-Type: application/json" \
  -d @workflow.json
Use workers: 1 for API tests to avoid wait node pauses in parallel execution.

Best Practices

Use Environment Variables

Store sensitive data like API keys and tokens in config files, not hardcoded in workflows.
{
  "headers": {
    "Authorization": "Bearer ${config.apiToken}"
  }
}

Verify Status Codes

Always verify HTTP status codes after API calls to catch errors early.

Enable Retry for Transient Errors

Use exponential backoff retry strategy for network failures and rate limits.

Store Response in Context

Use unique contextKey values to store multiple API responses for later access.

Next Steps

Reports

Generate execution reports with API response data and performance metrics.

Browser Automation

Combine API testing with browser automation for end-to-end workflows.

Build docs developers (and LLMs) love