Skip to main content

Request

Register a function that can be invoked by the framework or external triggers.

Examples

Basic Function Registration

{
  "type": "registerfunction",
  "id": "process_payment",
  "description": "Process a payment transaction",
  "request_format": {
    "type": "object",
    "properties": {
      "amount": { "type": "number" },
      "currency": { "type": "string" }
    },
    "required": ["amount", "currency"]
  },
  "response_format": {
    "type": "object",
    "properties": {
      "transaction_id": { "type": "string" },
      "status": { "type": "string" }
    }
  }
}

Function with HTTP Invocation and Bearer Auth

{
  "type": "registerfunction",
  "id": "external.my_lambda",
  "description": "External Lambda function",
  "invocation": {
    "url": "https://example.com/lambda",
    "method": "POST",
    "timeout_ms": 30000,
    "headers": {
      "x-custom-header": "value"
    },
    "auth": {
      "type": "bearer",
      "token_key": "LAMBDA_TOKEN"
    }
  }
}

Function with HMAC Authentication

{
  "type": "registerfunction",
  "id": "webhook.handler",
  "invocation": {
    "url": "https://api.example.com/webhook",
    "auth": {
      "type": "hmac",
      "secret_key": "WEBHOOK_SECRET"
    }
  }
}

Function with API Key Authentication

{
  "type": "registerfunction",
  "id": "external.api",
  "invocation": {
    "url": "https://api.example.com/endpoint",
    "auth": {
      "type": "api_key",
      "header": "X-API-Key",
      "value_key": "API_KEY_ENV_VAR"
    }
  }
}

Error Cases

Missing Environment Variable

If an authentication configuration references an environment variable that doesn’t exist:
{
  "code": "missing_env_var",
  "message": "Missing environment variable 'LAMBDA_TOKEN' for Bearer token authentication. Please set this environment variable before registering the function."
}

Duplicate Function ID

Attempting to register a function with an ID that’s already registered will fail. Unregister the existing function first or use a different ID.

Notes

  • Function IDs must be unique within a worker session
  • Optional fields are omitted from serialization when not provided
  • For WebSocket-based functions (no invocation), the worker must handle InvokeFunction messages
  • For HTTP-based functions, the framework will make HTTP requests to the specified endpoint
  • Authentication credentials are resolved from environment variables at registration time

Build docs developers (and LLMs) love