v1

latestOpenAPI 3.1.02026-07-22115189303.8 KB
Functions

Invoke function

Execute a deployed serverless function with a custom JSON payload. The request body is forwarded directly to your function code.

Request payload structure is completely flexible - send any valid JSON that your function expects. Your function receives the payload as the request body and can parse it however needed.

Successful response behavior depends on invoke_response_mode:

  • New functions default to passthrough, so Kapso forwards the function response body, success status code, and Content-Type directly
  • Legacy wrapped functions can keep wrapped, which preserves the legacy API shape and returns successful JSON results under data

The function must be in 'deployed' status to be invoked. If the function is in 'draft' or 'error' status, the request will fail with 422 validation error.

Authentication:

  • Private functions require X-API-Key
  • Public Cloudflare functions (public_endpoint=true) can be invoked without an API key
  • Private and unknown functions both return 404 from this route

Execution tracking:

  • All invocations are tracked with timing and request/response data
  • Failed invocations return an invocation_id for debugging
  • Check function invocation history via GET /functions/{id} (extended view)

Error handling:

  • Function execution errors are captured and returned with details
  • Errors are truncated to 512 characters for storage
  • Original error context is preserved in invocation record
post/functions/{function_id}/invoke

Request body

FunctionInvokeRequest required

Payload to send to the function. Structure is completely flexible - send any valid JSON that your function expects. The payload will be forwarded to your function as the request body.

Example request

{
  "weight": 5.5,
  "distance": 120,
  "service": "express"
}

Response

Function executed successfully. wrapped functions return successful JSON under data. passthrough functions may also return other 2xx status codes and non-JSON content types depending on the function response.

OR

Example response

{
  "data": {
    "cost": 24.75,
    "currency": "USD"
  }
}