Skip to Content
WorkloadsFunction

Call a Function

POST
/function/{name}

A call needs a credential when the Function's spec.ingress.auth.mode, else its namespace's spec.edgeDefaults.auth.mode, is authenticated; else it needs none.

Authorization

headerAuthorizationBearer <token>

A credential of funcd's config, sent as Authorization: Bearer followed by its token.

Path Parameters

name*string

The Function's name.

Match^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$
Length1 <= length <= 63

Header Parameters

X-Funcd-Namespace?string

The Function's namespace, when the Host header names none, as shop.localhost names shop; without either, default.

Match^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$
Length1 <= length <= 63

Request Body

The call's input, any JSON value, which the handler gets as its event's data. A CloudEvent, an object with specversion or data, passes as it is.

body?unknownapplication/json

Response Body

The handler's result.

response?unknownapplication/json
Example Request
curl -X POST 'http://127.0.0.1:8081/function/string'
Example Response
null

Answers

StatusProblem typeWhenWhat to do
200The handler's result.
400urn:funcd:problem:invalidThe body did not arrive within the gateway's read timeout.Send the whole request at once, without pausing.
401urn:funcd:problem:unauthorizedThe namespace's stance asks for a credential, and the call carries none, or one that funcd does not know.Send a credential of funcd's config as a bearer token in the Authorization header, or in X-Api-Key.
401urn:funcd:problem:unauthorizedThe namespace's stance asks for a credential while server.auth.edge is off, so funcd checks none and refuses the call, whatever credential it carries.Ask funcd's operator to set server.auth.edge to true.
403urn:funcd:problem:forbiddenThe credential's role or namespaces do not allow it to call Functions in the namespace.Use a credential of the namespace, such as its developer's.
404urn:funcd:problem:not-foundThe namespace holds no Function of that name that answers at its own address: it does not exist, its ingress is off, or its ingress names a host or a path of its own.Check the name and the namespace, or call the Function at the address that its ingress names.
413urn:funcd:problem:payload-too-largeThe body is larger than 1 MiB, the most that funcd reads to build the call's event.Send a smaller body, or pass large data by reference, such as a Bucket key.
422ContractViolationThe event data does not match the Function's input contract; nothing reached its worker.Correct the values that details names.
429urn:funcd:problem:resource-exhaustedThe call is over the rate that server.limits sets.Retry after the seconds that the Retry-After header gives.
500ContractViolationThe handler's result does not match the Function's output contract, so funcd sends this instead.Correct the handler, or its output contract.
503urn:funcd:problem:unavailableThe gateway already serves as many calls at once as server.limits.maxInFlight allows.Retry the call later.
503urn:funcd:problem:unavailableThe worker failed during the call, before its answer. funcd does not retry the call.Retry it, if the handler may run twice.
503urn:funcd:problem:unavailablefuncd could not read the namespace's settings, so it does not know how to serve the call.Retry the call later.
503urn:funcd:problem:unavailablefuncd cannot read the Function's contract.Retry the call later.
503urn:funcd:problem:unavailableThe namespace is held for its data, so funcd refuses its calls until the hold is released.Retry after the seconds that the Retry-After header gives; funcdctl hold release --namespace releases the hold.
503urn:funcd:problem:unavailableThe namespace is held while a Restore loads it.Retry after the seconds that the Retry-After header gives, once the Restore has ended.
503urn:funcd:problem:unavailableNo worker of the Function became ready within invoke.activationTimeout, 30 s by default.Retry the call; if it keeps failing, read the Function's status for why its worker is not ready.
503urn:funcd:problem:unavailableThe Function is Failed; the detail names the reason, such as ShapeInvalid.Correct what the Function's status names, such as its artifact, then retry.
503urn:funcd:problem:unavailablefuncd is stopping, and the call was waiting for a worker of the Function to become ready.Retry the call once funcd runs again.
504urn:funcd:problem:deadline-exceededThe worker did not start its answer within the call's deadline: the Function's spec.timeout, else invoke.defaultTimeout.Make the handler answer sooner, or raise its spec.timeout.