Function code
Read and replace the source code of a function service.
A function service runs a single file of code that you edit in the dashboard instead of building a repository or an image. Its source.kind is function in the service object. These routes read and replace that code. Any other service answers 409 NOT_A_FUNCTION.
Read the code
GET
/containers/services/{serviceId}/functioncurl https://api.helipod.io/api/containers/services/$SERVICE/function \
-H "Authorization: Bearer hel_your_key"{
"success": true,
"data": {
"serviceId": "9a8b7c6d-5e4f-4a3b-9c2d-1e0f9a8b7c6d",
"code": "export default async function handler(req) {\n return new Response('hello');\n}\n"
}
}code is null when no code has been saved yet.
Replace the code
PUT
/containers/services/{serviceId}/functionSaves new code. It runs from the next deploy.
Prop
Type
curl -X PUT https://api.helipod.io/api/containers/services/$SERVICE/function \
-H "Authorization: Bearer hel_your_key" -H "Content-Type: application/json" \
-d '{ "code": "export default async function handler(req) {\n return Response.json({ ok: true });\n}\n" }'The response is { "serviceId": "...", "saved": true, "needsRedeploy": true }. Start a deploy to run the new code. Code over 512 KB answers 400 INVALID_CODE.