Function Version Content
The /Content endpoint for each FunctionVersion lets you retrieve the code.
Property nameTypeRequiredPIIDescriptionChild properties
The unique string that we created to identify the Function Version resource.
Pattern:
^ZN[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the Account that created the Function Version resource.
Pattern:
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the Service that the Function Version resource is associated with.
Pattern:
^ZS[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the Function that is the parent of the Function Version.
Pattern:
^ZH[0-9a-fA-F]{32}$Min length: 34Max length: 34GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Functions/{FunctionSid}/Versions/{Sid}/Content
Property nameTypeRequiredPIIDescription
The SID of the Function that is the parent of the Function Version content to fetch.
Pattern:
^ZH[0-9a-fA-F]{32}$Min length: 34Max length: 34The SID of the Function Version content to fetch.
Pattern:
^ZN[0-9a-fA-F]{32}$Min length: 34Max length: 341// 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 at twilio.com/console5// Provision API Keys at twilio.com/console/runtime/api-keys6// and set the environment variables. See http://twil.io/secure7// For local testing, you can use your Account SID and Auth token8const accountSid = process.env.TWILIO_ACCOUNT_SID;9const apiKey = process.env.TWILIO_API_KEY;10const apiSecret = process.env.TWILIO_API_SECRET;11const client = twilio(apiKey, apiSecret, { accountSid: accountSid });1213async function fetchFunctionVersionContent() {14const functionVersionContent = await client.serverless.v115.services("ServiceSid")16.functions("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")17.functionVersions("ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")18.functionVersionContent()19.fetch();2021console.log(functionVersionContent.sid);22}2324fetchFunctionVersionContent();
Response
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}