Skip to main content
API Call stage showing documents enriched with external HTTP API data
The API Call stage enriches documents by calling external HTTP APIs. This enables integration with third-party services like Stripe, GitHub, weather APIs, and more to augment documents with real-time data.
Stage Category: APPLY (1-1 Enrichment)Transformation: N documents → N documents (same count, expanded schema)

When to Use

Use CaseDescription
Customer data lookupEnrich with Stripe billing data, CRM info
Repository infoFetch GitHub commit stats, stars
Real-time dataAdd weather, stock prices, currency rates
Data validationVerify addresses, phone numbers
External contextLookup additional context from any API

When NOT to Use

ScenarioRecommended Alternative
Untrusted/user-provided URLsMajor security risk (SSRF)
API credentials can’t be securedUse organization secrets vault
High-volume enrichmentRate limits apply
Time-critical responsesNetwork latency adds 100-500ms
Internal-only APIs behind firewallsUse sql_lookup for databases

Parameters

Required Parameters

ParameterTypeDescription
urlstringAPI endpoint URL. Supports {DOC.field} and {INPUT.field} templates.
allowed_domainsstring[]Domain allowlist for SSRF protection. Never use *.
output_fieldstringDot-path where API response should be stored (e.g., metadata.stripe_data).

Optional Parameters

ParameterTypeDefaultDescription
methodstringGETHTTP method: GET, POST, PUT, PATCH, DELETE
authobjectnullAuthentication configuration (see below)
headersobject{}Additional HTTP headers (supports templates)
bodyobjectnullRequest body for POST/PUT/PATCH (JSON)
timeoutinteger10Request timeout in seconds (1-60)
max_response_sizeinteger10485760Maximum response size in bytes (default: 10MB)
response_pathstringnullJSONPath to extract specific field from response
rate_limitobjectnullRate limiting per domain
whenobjectnullConditional filter for selective enrichment
on_errorstringskipError handling: skip, remove, or raise

Authentication Types

OAuth 2.0, JWT tokens - Most modern APIs (GitHub, OpenAI, Stripe)
{
  "auth": {
    "type": "bearer",
    "secret_ref": "stripe_api_key"
  }
}
Adds header: Authorization: Bearer {secret_value}

Error Handling

StrategyBehaviorBest For
skipKeep document unchangedOptional enrichment
removeRemove document from resultsMandatory enrichment
raiseFail entire pipelineDebugging, critical failures

Configuration Examples

{
  "stage_type": "apply",
  "stage_id": "api_call",
  "parameters": {
    "url": "https://api.stripe.com/v1/customers/{DOC.metadata.stripe_id}",
    "method": "GET",
    "allowed_domains": ["api.stripe.com"],
    "auth": {
      "type": "bearer",
      "secret_ref": "stripe_api_key"
    },
    "output_field": "metadata.stripe_data",
    "timeout": 10,
    "on_error": "skip"
  }
}

Security

SSRF Protection RequiredThis stage makes external HTTP requests which can be exploited for Server-Side Request Forgery attacks. Always use allowed_domains to whitelist permitted domains.

Security Best Practices

  1. Never use * in allowed_domains - Explicitly list each domain
  2. Never store credentials in configuration - Always use auth.secret_ref to reference vault secrets
  3. Set rate limits - Prevent abuse and excessive costs
  4. Use HTTPS - HTTP URLs are automatically upgraded
  5. Audit configurations - Review before deployment to prevent data exfiltration

Storing Secrets

# Create a secret in the organization vault
curl -X POST "$MP_API_URL/v1/organizations/secrets" \
  -H "Authorization: Bearer $MP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "secret_name": "stripe_api_key",
    "secret_value": "sk_live_..."
  }'
Then reference in configuration:
{
  "auth": {
    "type": "bearer",
    "secret_ref": "stripe_api_key"
  }
}

Performance

MetricValue
Latency per request100-500ms (network dependent)
Timeout range1-60 seconds
Max response size10MB (configurable)
ParallelizationDocuments processed concurrently

Template Variables

URLs, headers, and body values support template variables:
NamespaceDescriptionExample
DOCCurrent document fields{DOC.metadata.customer_id}
INPUTQuery inputs{INPUT.api_version}