VirtuousAI

HTTP Request Action

Make HTTP requests to external APIs from automations and chat

HTTP Request Action

The http_request action allows you to call external APIs from your automations and chat sessions. It supports all standard HTTP methods and includes built-in security protections.

Prerequisites

  • VirtuousAI account with CLI installed
  • Understanding of Automations
  • Familiarity with Actions

Overview

Use http_request to integrate with third-party APIs, fetch data from external services, or trigger webhooks in other systems.

Supported Methods: GET, POST, PUT, DELETE, PATCH

Definition Schema

When using http_request in an automation or action definition:

{
  "kind": "http_request",
  "method": "GET",
  "url": "https://api.example.com/endpoint",
  "headers": {
    "Authorization": "Bearer token"
  },
  "params": {
    "page": "1"
  },
  "body": {
    "key": "value"
  },
  "timeout_seconds": 30,
  "follow_redirects": true,
  "max_redirects": 5,
  "retry_non_idempotent": false
}

Configuration Options

OptionTypeRequiredDefaultDescription
kindstringYes-Must be "http_request"
methodstringYes-HTTP method: GET, POST, PUT, DELETE, PATCH
urlstringYes-Target URL (HTTPS required in production)
headersobjectNo{}Request headers
paramsobjectNo{}Query string parameters
bodyobjectNonullJSON request body (for POST/PUT/PATCH)
timeout_secondsnumberNo30Request timeout (max: 300)
follow_redirectsbooleanNotrueWhether to follow HTTP redirects
max_redirectsnumberNo5Maximum number of redirects to follow
retry_non_idempotentbooleanNofalseEnable retries for POST/PUT/PATCH

Response Schema

After execution, the action returns:

{
  "status_code": 200,
  "body": {},
  "body_truncated": false,
  "body_encoding": null,
  "original_size_bytes": 1234,
  "headers": {
    "content-type": "application/json"
  },
  "duration_ms": 150.5,
  "time_to_first_byte_ms": 45.2,
  "redirect_count": 0,
  "final_url": "https://api.example.com/endpoint",
  "request_redacted": {}
}
FieldDescription
status_codeHTTP response status code
bodyParsed JSON or text response
body_truncatedtrue if response exceeded 100KB limit
body_encoding"utf-8", "base64", or null (JSON)
original_size_bytesOriginal response size before truncation
headersResponse headers
duration_msTotal request duration in milliseconds
time_to_first_byte_msTime to first byte in milliseconds
redirect_countNumber of redirects followed
final_urlFinal URL after redirects
request_redactedRequest details with sensitive headers masked

CLI / Chat Tool Usage

When using http_request as a chat tool, the interface is simplified:

vai chat
> Use http_request to GET https://api.github.com/users/octocat

The chat tool accepts these parameters:

  • method - HTTP method
  • url - Target URL
  • headers - Request headers (optional)
  • body - Request body for POST/PUT/PATCH (optional)
  • timeout_seconds - Timeout in seconds (optional)

Examples

GET Request

Fetch data from an external API:

vai actions create \
  --name "Fetch GitHub User" \
  --config '{
    "kind": "http_request",
    "method": "GET",
    "url": "https://api.github.com/users/octocat",
    "headers": {
      "Accept": "application/vnd.github.v3+json"
    }
  }'
curl -X POST https://vai-dev.virtuousai.com/api/v1/actions \
  -H "Authorization: Bearer $VAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Fetch GitHub User",
    "config": {
      "kind": "http_request",
      "method": "GET",
      "url": "https://api.github.com/users/octocat",
      "headers": {
        "Accept": "application/vnd.github.v3+json"
      }
    }
  }'

POST with JSON Body

Send data to an external API:

vai actions create \
  --name "Create Item" \
  --config '{
    "kind": "http_request",
    "method": "POST",
    "url": "https://api.example.com/items",
    "headers": {
      "Content-Type": "application/json",
      "Authorization": "Bearer your-token"
    },
    "body": {
      "name": "New Item",
      "description": "Item description"
    }
  }'
curl -X POST https://vai-dev.virtuousai.com/api/v1/actions \
  -H "Authorization: Bearer $VAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Create Item",
    "config": {
      "kind": "http_request",
      "method": "POST",
      "url": "https://api.example.com/items",
      "headers": {
        "Content-Type": "application/json",
        "Authorization": "Bearer your-token"
      },
      "body": {
        "name": "New Item",
        "description": "Item description"
      }
    }
  }'

Security

VirtuousAI includes multiple security protections for HTTP requests.

HTTPS Enforcement

EnvironmentRule
ProductionOnly HTTPS URLs are allowed
DevelopmentHTTP allowed for localhost and 127.0.0.1 only

SSRF Protection

All URLs are validated before requests are made to prevent Server-Side Request Forgery:

  • DNS resolution is checked to prevent requests to private/internal IPs
  • Blocked IP ranges: private, loopback, link-local, reserved
  • Redirect targets are also validated (prevents redirect-based SSRF)

Requests to internal networks, private IP ranges, and cloud metadata endpoints are blocked for security.

Sensitive Header Redaction

The following headers are automatically redacted in logs and stored results:

  • Authorization
  • X-Api-Key
  • Api-Key
  • X-Auth-Token
  • Cookie
  • Set-Cookie

The request_redacted field in the response shows the request with these headers masked.

Limits

LimitValue
Max response body100 KB (truncated if exceeded)
Default timeout30 seconds
Max timeout300 seconds
Max redirects5 (configurable)

If a response exceeds 100KB, it will be truncated and body_truncated will be set to true. The original_size_bytes field shows the full size.

Error Handling

Error CodeDescriptionRetryable
invalid_urlURL validation failed (non-HTTPS, invalid hostname)No
redirect_to_private_ipRedirect led to blocked IPNo
http_4xxClient error (400-499)No
http_5xxServer error (500-599)Yes (GET/DELETE only)
timeoutRequest timed outYes (GET/DELETE only)
request_errorNetwork/connection errorYes (GET/DELETE only)

By default, only idempotent methods (GET, DELETE) are retried on failure. Set retry_non_idempotent: true to enable retries for POST, PUT, and PATCH methods.

Next Steps

On this page