The /Content
endpoint for each FunctionVersion lets you retrieve the code.
The unique string that we created to identify the Function Version resource.
^ZN[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Account that created the Function Version resource.
^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Service that the Function Version resource is associated with.
^ZS[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Function that is the parent of the Function Version.
^ZH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Functions/{FunctionSid}/Versions/{Sid}/Content
The SID of the Function that is the parent of the Function Version content to fetch.
^ZH[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The SID of the Function Version content to fetch.
^ZN[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchFunctionVersionContent() {11const functionVersionContent = await client.serverless.v112.services("ServiceSid")13.functions("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")14.functionVersions("ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")15.functionVersionContent()16.fetch();1718console.log(functionVersionContent.sid);19}2021fetchFunctionVersionContent();
1{2"sid": "ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"service_sid": "ServiceSid",5"function_sid": "ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",6"content": "exports.handler = function (context, event, callback) {\n const request = require(\"request\");\n return request(\"http://www.google.com\", function (error, response, body) {\n callback(null, response.statusCode);\n });\n};",7"url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Functions/ZH00000000000000000000000000000000/Versions/ZN00000000000000000000000000000000/Content"8}