Skip to contentSkip to navigationSkip to topbar
On this page

Schema Resource


Schemas define how information is organized within an event's data attribute. You can use the schema to explore the fields in an event type before subscribing to it. You can use also it in production to validate that the events you receive match their published schemas.

There are two ways to find the schema id of an Event-Type.

  1. You can fetch any event type resource through the Event Type API and find the schema_id in its properties.
  2. If you are already receiving events in your sink, the metadata of the event will contain the url of its schema in a field called dataschema. The schema id is part of the url. For example, if the url is https://events-schemas.twilio.com/VoiceInsights.CallSummary/1(link takes you to an external page), the schema id is VoiceInsights.CallSummary.

Schema Properties

schema-properties page anchor
Property nameTypeRequiredDescriptionChild properties
idstring

Optional

Not PII

The unique identifier of the schema. Each schema can have multiple versions, that share the same id.


urlstring<uri>

Optional

The URL of this resource.


linksobject<uri-map>

Optional

Contains a dictionary of URL links to nested resources of this schema.


latest_version_date_createdstring<date-time>

Optional

The date that the latest schema version was created, given in ISO 8601 format.


latest_versioninteger

Optional

The latest version published of this schema.

Default: 0

GET https://events.twilio.com/v1/Schemas/{Id}

Path parameters

path-parameters page anchor
Property nameTypeRequiredPIIDescription
Idstringrequired

The unique identifier of the schema. Each schema can have multiple versions, that share the same id.

Fetch schemaLink to code sample: Fetch schema
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 fetchSchema() {
11
const schema = await client.events.v1
12
.schemas("Messaging.MessageStatus")
13
.fetch();
14
15
console.log(schema.id);
16
}
17
18
fetchSchema();

Output

1
{
2
"id": "Messaging.MessageStatus",
3
"url": "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus",
4
"latest_version_date_created": "2020-07-30T20:00:00Z",
5
"latest_version": 1,
6
"links": {
7
"versions": "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions"
8
}
9
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.