Skip to main content

Execute a Service Call

POST /v1/execute/:providerId/:endpointSlug
Execute a call to a provider’s endpoint. ACN validates the request, deducts the call cost, proxies to the provider, and returns the response with metadata.
Authentication required. Use an API key or wallet signature.

Path Parameters

ParameterTypeDescription
providerIdstringProvider identifier (from discovery results)
endpointSlugstringEndpoint slug (from discovery results)

Request Body

The request body is pass-through — it’s forwarded directly to the provider after validation against the endpoint’s schema. Refer to the endpoint.parameters field from discovery results for the expected schema.

Example

curl -X POST https://api.acn.exchange/v1/execute/coingecko/get-price \
  -H "Authorization: Bearer acn_sk_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "ids": "bitcoin,ethereum",
    "vs_currencies": "usd"
  }'

Response

{
  "acn": {
    "call_id": "call_7f8a9b2c",
    "provider_id": "coingecko",
    "endpoint": "get-price",
    "charged_usdc": "0.001",
    "remaining_balance_usdc": "10.499",
    "latency_ms": 145
  },
  "data": {
    "bitcoin": { "usd": 67542.00 },
    "ethereum": { "usd": 3521.80 }
  }
}

Response Fields

FieldTypeDescription
acn.call_idstringUnique identifier for this call
acn.provider_idstringProvider that served the request
acn.endpointstringEndpoint that was called
acn.charged_usdcstringAmount charged for this call
acn.remaining_balance_usdcstringYour remaining balance after the charge
acn.latency_msnumberTotal round-trip time in milliseconds
dataobjectThe provider’s response (varies by endpoint)

Execution Pipeline

  1. Resolve — Verify the provider and endpoint exist
  2. Validate — Check the request body against the endpoint’s schema
  3. Debit — Atomically deduct the call cost from your balance
  4. Proxy — Forward the request to the provider
  5. Log — Record the call with metadata (timing, cost, status)
  6. Return — Wrap the provider’s response with ACN metadata

Automatic Refunds

Provider ResponseRefund?
2xx (success)No — call charged normally
4xx (client error)No — the request was malformed (caller’s responsibility)
5xx (server error)Yes — automatic refund
TimeoutYes — automatic refund

Error Codes

CodeDescription
ACN-EXE-001Provider not found
ACN-EXE-002Endpoint not found
ACN-EXE-003Request validation failed — body doesn’t match endpoint schema
ACN-EXE-004Provider error — upstream returned 5xx (refund issued)
ACN-EXE-005Provider timeout (refund issued)
ACN-PAY-001Insufficient balance
ACN-AUTH-001Missing or invalid authentication

Idempotency

To prevent duplicate charges on retries, use the Idempotency-Key header:
curl -X POST https://api.acn.exchange/v1/execute/resend/send-email \
  -H "Authorization: Bearer acn_sk_your_key" \
  -H "Idempotency-Key: my-unique-request-id" \
  -H "Content-Type: application/json" \
  -d '{ ... }'
If a request with the same idempotency key has already been processed, the original response is returned without re-executing or re-charging.