Skip to main content

Invoke API reference

The runtime implements the AWS Lambda™ Invoke API on LOCH_RUNTIME_INVOKE_ADDR (0.0.0.0:8080), plain HTTP.

Endpoint​

POST /2015-03-31/functions/{name}/invocations
PartAccepted values
{name}function or AWS_LAMBDA_FUNCTION_NAME; <name>:$LATEST; the ARN arn:aws:lambda:<AWS_REGION>:000000000000:function:<name>; the partial ARN 000000000000:function:<name>
?Qualifier=Absent or $LATEST
MethodPOST only; any other method gets 405 and never invokes
BodyThe raw event, up to LOCH_RUNTIME_MAX_PAYLOAD (6 MiB). An empty body is passed as is

Request headers​

HeaderEffect
AuthorizationBearer token or SigV4 signature, unless the caller is on the loopback
X-Amz-Invocation-TypeRequestResponse (default); DryRun answers 204; Event answers 400 (not supported)
X-Amz-Log-Type: TailReturns the last 4 KB of the invocation logs, base64, in X-Amz-Log-Result
X-Amz-Client-ContextBase64 JSON object, 3,583 bytes at most; passed to the function
X-Amzn-Trace-IdBecomes the trace id when valid

With SigV4, every x-amz-* header and Content-Type must be signed, as on AWS.

Function results​

The delivery answers 200, with x-amzn-RequestId, X-Amz-Executed-Version: $LATEST and Content-Type.

ResultBody
SuccessThe function's response, never truncated
Function errorX-Amz-Function-Error: Unhandled and the error the function posted, verbatim
Init errorX-Amz-Function-Error: Unhandled and the init error (Runtime.ImportModuleError, Runtime.HandlerNotFound, …)
Response over 6 MiB + 100 bytesFunction.ResponseSizeTooLarge, then re-init
TimeoutSandbox.Timedout, Task timed out after N seconds, then re-init
Out of memoryRuntime.OutOfMemory, then re-init
Bootstrap exitedRuntime.ExitError, Runtime exited with error: exit status N, then re-init

Error bodies are {"errorType":"…","errorMessage":"…"}. Match on errorType, not on the message.

Errors of the API​

Errors of the API itself (not of the function) have the header x-amzn-ErrorType: <Name>, x-amzn-RequestId, and the body {"Type":"User","message":"…"} ("Type":"Service" for 5xx). A 429 body also has "Reason":"ReservedFunctionConcurrentInvocationLimitExceeded".

StatusNameWhen
400InvalidParameterValueExceptionX-Amz-Invocation-Type: Event, or another invalid parameter
400InvalidRequestContentExceptionInvalid X-Amz-Client-Context
401MissingAuthenticationTokenExceptionNo credential
403UnrecognizedClientExceptionWrong bearer token or unknown access key id
403InvalidSignatureException, IncompleteSignatureExceptionWrong, expired or malformed SigV4 signature
403AccessDeniedExceptionRequest from a web browser (Origin, Sec-Fetch-Site, Sec-Fetch-Dest, Sec-Fetch-User)
404ResourceNotFoundExceptionUnknown function name, qualifier or route
405MethodNotAllowedExceptionMethod other than POST
408RequestTimeoutExceptionBody not received in time
413RequestTooLargeExceptionRequest over LOCH_RUNTIME_MAX_PAYLOAD
429TooManyRequestsExceptionQueue full or wait too long, too many connections or requests from one IP. Retry-After is set; AWS SDKs retry by themselves
503ServiceExceptionThe runtime is shutting down. Retry-After: 1

Authentication errors close the connection.

Other routes​

RouteCredentialAnswer
GET /_loch/healthNone200 {"status":"ready","queueDepth":0}, or 503 with initializing, error or stopping
GET /_loch/metricsRequired, except from the loopbackPrometheus text: see Metrics reference

"AWS" and "AWS Lambda" are trademarks of Amazon.com, Inc. or its affiliates. This project is not affiliated with or endorsed by Amazon. It implements the publicly documented AWS Lambda Runtime and Invoke APIs and contains no code from the AWS Lambda Runtime Interface Emulator.