POST
/
functions
Create a new function
curl --request POST \
  --url https://app.kapso.ai/api/v1/functions \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '{
  "function": {
    "name": "New Function",
    "description": "This function processes incoming webhooks",
    "code": "export default function handler(request) {\n  const body = await request.json();\n  // Process the request\n  return new Response(JSON.stringify({ processed: true }));\n}\n",
    "runtime_config": {
      "timeout": 30,
      "memory": 128
    }
  }
}'
{
  "data": {
    "id": "function-123abc",
    "name": "Process Order",
    "slug": "process-order",
    "description": "Function to process incoming orders",
    "code": "export default function handler(request) {\n  return new Response(JSON.stringify({ status: 'success' }));\n}\n",
    "version": 1,
    "status": "deployed",
    "last_deployed_at": "2023-11-07T05:31:56Z",
    "runtime_config": {},
    "project_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "created_by_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "endpoint_url": "https://app.kapso.ai/api/v1/functions/function-123abc/invoke",
    "cf_worker_url": "https://kapso-functions.workers.dev/function-123abc",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  }
}

Authorizations

X-API-Key
string
header
required

API key required for all endpoints

Body

application/json

Response

201
application/json

Function created successfully

The response is of type object.