In a Custom Container runtime, Function Compute communicates with your container over HTTP. This page explains the HTTP contract your server must implement to handle event-driven function invocations, and provides a working Node.js example.
How it works
When a Custom Container function is invoked, Function Compute forwards the request to the HTTP server running inside your container. The runtime cycle follows these steps:
Receive the invocation — Function Compute sends a
POSTrequest to/invokewith the event payload in the request body and common request headers in the request headers.Process the event — Extract the
contextandeventparameters from the request headers and body, then run your business logic.Return the result — Send an HTTP response with the handler return value, an HTTP status code, and the
x-fc-statusresponse header.Report errors — If the invocation fails, set
x-fc-statusto a non-success value so Function Compute records the error stack in logs.
For event handler implementations using function signatures from FC-supported runtimes (such as the Go runtime), see Event handlers in a custom runtime.
POST /invoke
The HTTP server must handle POST /invoke for function invocations, and optionally POST /initialize for instance initialization (Initializer hook).
Request
| Field | Value |
|---|---|
| Method | POST |
| Path | /invoke |
Content-Type | application/octet-stream |
| Request body | The event payload specified when calling InvokeFunction |
| Request headers | Common request headers |
Content-Type must be application/octet-stream.
Response
The response body is the return value of the handler. Include both fields in every response:
| Field | Type | 200 | 404 |
|---|---|---|---|
HTTP status code (StatusCode) | HTTP response status | Succeeded | Failed |
x-fc-status | Response header | Succeeded | Failed |
Always set bothStatusCodeandx-fc-statusin your HTTP response.
What happens when `x-fc-status` is omitted
If x-fc-status is absent, Function Compute treats the invocation as successful even when an error occurs inside the handler. Business logic may not be affected, but errors are not recorded — reducing the observability of your function. The following figure shows an example.

What happens when `x-fc-status` is set
When x-fc-status is present, Function Compute uses its value to determine whether the invocation succeeded. On failure, the error stack is recorded in logs. The following figure shows an example.

Node.js example
The following Node.js Express example implements both the Initializer hook (POST /initialize) and the event handler (POST /invoke). The context and event parameters are read from req.headers and req.body.
'use strict';
const express = require('express');
// The constants.
const PORT = 9000;
const HOST = '0.0.0.0';
const app = express();
// Parse the JSON-formatted request body.
app.use(express.json({type:['application/json', 'application/octet-stream']}))
// The example of the Initializer hook. You must configure the initializer hook when you create the function.
app.post('/initialize', (req, res) => {
console.log(req.body)
res.send('Hello FunctionCompute, /initialize\n');
});
// Invoke the event function.
app.post('/invoke', (req, res) => {
console.log(req.body)
res.send('Hello FunctionCompute, event function\n');
});
var server = app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);
server.timeout = 0; // Never time out.
server.keepAliveTimeout = 0; // keepalive, never timeoutExamples for other languages
Use Serverless Devs to deploy and invoke Custom Container event functions with minimal setup. The following GitHub repositories provide ready-to-run examples: