Skip to contentSkip to navigationSkip to topbar
On this page

Function Version Content


The /Content endpoint for each FunctionVersion lets you retrieve the code.


Content Properties

content-properties page anchor
Property nameTypeRequiredDescriptionChild properties
sidSID<ZN>

Optional

Not PII

The unique string that we created to identify the Function Version resource.

Pattern: ^ZN[0-9a-fA-F]{32}$Min length: 34Max length: 34

account_sidSID<AC>

Optional

The SID of the Account that created the Function Version resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

service_sidSID<ZS>

Optional

The SID of the Service that the Function Version resource is associated with.

Pattern: ^ZS[0-9a-fA-F]{32}$Min length: 34Max length: 34

function_sidSID<ZH>

Optional

The SID of the Function that is the parent of the Function Version.

Pattern: ^ZH[0-9a-fA-F]{32}$Min length: 34Max length: 34

contentstring

Optional

The content of the Function Version resource.


urlstring<uri>

Optional


Fetch a FunctionVersionContent resource

fetch-a-functionversioncontent-resource page anchor
GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Functions/{FunctionSid}/Versions/{Sid}/Content

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
ServiceSidstringrequired

The SID of the Service to fetch the Function Version content from.


FunctionSidSID<ZH>required

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: 34

SidSID<ZN>required

The SID of the Function Version content to fetch.

Pattern: ^ZN[0-9a-fA-F]{32}$Min length: 34Max length: 34
Fetch a ContentLink to code sample: Fetch a Content
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchFunctionVersionContent() {
11
const functionVersionContent = await client.serverless.v1
12
.services("ServiceSid")
13
.functions("ZHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
14
.functionVersions("ZNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
15
.functionVersionContent()
16
.fetch();
17
18
console.log(functionVersionContent.sid);
19
}
20
21
fetchFunctionVersionContent();

Output

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
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.