API: Functions
Endpoints
| Method | Path | Description |
|---|
| POST | /v1/functions | Create a function |
| GET | /v1/functions | List all functions |
| GET | /v1/functions/{id} | Get function details |
| DELETE | /v1/functions/{id} | Delete a function |
| POST | /v1/functions/{id}/invoke | Invoke a function |
## Create Function
POST /v1/functions
Request Body
{
"metadata": {"name": "data-processor"},
"spec": {
"runtime": "python",
"handler": "handler.process",
"code_uri": "s3://functions/processor-v1.zip",
"memory_mb": 512,
"timeout_seconds": 60,
"min_instances": 1,
"max_instances": 10
}
}
Response (201)
{
"id": "fn-a1b2c3",
"metadata": {"name": "data-processor", "created_at": "2025-01-15T10:30:00Z"},
"spec": {
"runtime": "python",
"handler": "handler.process",
"code_uri": "s3://functions/processor-v1.zip",
"memory_mb": 512,
"timeout_seconds": 60,
"min_instances": 1,
"max_instances": 10
},
"status": {
"state": "ready",
"active_instances": 1,
"invocation_count": 0,
"last_invoked_at": null
}
}
Invoke Function
POST /v1/functions/fn-a1b2c3/invoke
Request Body
{
"data": {"records": [1, 2, 3]}
}
Response (200)
{
"status_code": 200,
"body": "{"processed": 3}",
"duration_ms": 45,
"billed_ms": 100
}
FunctionSpec Fields
| Field | Type | Required | Description |
|---|
runtime | string | Yes | go, python, node, or rust |
handler | string | Yes | Entry point function path |
code_uri | string | Yes | URI to the code archive |
memory_mb | int | No | Memory allocation (default: 128) |
timeout_seconds | int | No | Max execution time (default: 30) |
min_instances | int | No | Minimum warm instances (default: 0) |
max_instances | int | No | Max concurrent instances (default: 10) |