# Schema Version resource

## Version Properties

```json
{"type":"object","refName":"events.v1.schema.schema_version","modelName":"events_v1_schema_schema_version","properties":{"id":{"type":"string","nullable":true,"description":"The unique identifier of the schema. Each schema can have multiple versions, that share the same id."},"schema_version":{"type":"integer","default":0,"description":"The version of this schema."},"date_created":{"type":"string","format":"date-time","nullable":true,"description":"The date the schema version was created, given in ISO 8601 format."},"url":{"type":"string","format":"uri","nullable":true,"description":"The URL of this resource."},"raw":{"type":"string","format":"uri","nullable":true}}}
```

## Fetch a SchemaVersion resource

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

### Path parameters

```json
[{"name":"Id","in":"path","description":"The unique identifier of the schema. Each schema can have multiple versions, that share the same id.","schema":{"type":"string"},"required":true},{"name":"SchemaVersion","in":"path","description":"The version of the schema","schema":{"type":"integer"},"required":true}]
```

Fetch Schema Version

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchSchemaVersion() {
  const version = await client.events.v1
    .schemas("Messaging.MessageStatus")
    .versions(42)
    .fetch();

  console.log(version.id);
}

fetchSchemaVersion();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

version = (
    client.events.v1.schemas("Messaging.MessageStatus").versions(42).fetch()
)

print(version.id)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Events.V1.Schema;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var schemaVersion = await SchemaVersionResource.FetchAsync(
            pathId: "Messaging.MessageStatus", pathSchemaVersion: 42);

        Console.WriteLine(schemaVersion.Id);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.events.v1.schema.SchemaVersion;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        SchemaVersion schemaVersion = SchemaVersion.fetcher("Messaging.MessageStatus", 42).fetch();

        System.out.println(schemaVersion.getId());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.EventsV1.FetchSchemaVersion("Messaging.MessageStatus",
		42)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Id != nil {
			fmt.Println(*resp.Id)
		} else {
			fmt.Println(resp.Id)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$version = $twilio->events->v1
    ->schemas("Messaging.MessageStatus")
    ->versions(42)
    ->fetch();

print $version->id;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

version = @client
          .events
          .v1
          .schemas('Messaging.MessageStatus')
          .versions(42)
          .fetch

puts version.id
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:events:v1:schemas:versions:fetch \
   --id Messaging.MessageStatus \
   --schema-version 42
```

```bash
curl -X GET "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/42" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "id": "Messaging.MessageStatus",
  "schema_version": 42,
  "date_created": "2015-07-30T20:00:00Z",
  "url": "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1",
  "raw": "https://events-schemas.twilio.com/Messaging.MessageStatus/1"
}
```

## Read multiple SchemaVersion resources

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

### Path parameters

```json
[{"name":"Id","in":"path","description":"The unique identifier of the schema. Each schema can have multiple versions, that share the same id.","schema":{"type":"string"},"required":true}]
```

### Query parameters

```json
[{"name":"PageSize","in":"query","description":"How many resources to return in each list page. The default is 50, and the maximum is 1000.","schema":{"type":"integer","format":"int64","minimum":1,"maximum":1000}},{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

Read Schema Version

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function listSchemaVersion() {
  const versions = await client.events.v1
    .schemas("Id")
    .versions.list({ limit: 20 });

  versions.forEach((v) => console.log(v.id));
}

listSchemaVersion();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

versions = client.events.v1.schemas("Id").versions.list(limit=20)

for record in versions:
    print(record.id)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Events.V1.Schema;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var schemaVersions = await SchemaVersionResource.ReadAsync(pathId: "Id", limit: 20);

        foreach (var record in schemaVersions) {
            Console.WriteLine(record.Id);
        }
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.events.v1.schema.SchemaVersion;
import com.twilio.base.ResourceSet;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        ResourceSet<SchemaVersion> schemaVersions = SchemaVersion.reader("Id").limit(20).read();

        for (SchemaVersion record : schemaVersions) {
            System.out.println(record.getId());
        }
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	events "github.com/twilio/twilio-go/rest/events/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &events.ListSchemaVersionParams{}
	params.SetLimit(20)

	resp, err := client.EventsV1.ListSchemaVersion("Id",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			if resp[record].Id != nil {
				fmt.Println(*resp[record].Id)
			} else {
				fmt.Println(resp[record].Id)
			}
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$versions = $twilio->events->v1->schemas("Id")->versions->read(20);

foreach ($versions as $record) {
    print $record->id;
}
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

versions = @client
           .events
           .v1
           .schemas('Id')
           .versions
           .list(limit: 20)

versions.each do |record|
   puts record.id
end
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:events:v1:schemas:versions:list \
   --id Id
```

```bash
curl -X GET "https://events.twilio.com/v1/Schemas/Id/Versions?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "schema_versions": [
    {
      "id": "Messaging.MessageStatus",
      "schema_version": 1,
      "date_created": "2015-07-30T20:00:00Z",
      "url": "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/1",
      "raw": "https://events-schemas.twilio.com/Messaging.MessageStatus/1"
    },
    {
      "id": "Messaging.MessageStatus",
      "schema_version": 2,
      "date_created": "2015-07-30T20:00:00Z",
      "url": "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions/2",
      "raw": "https://events-schemas.twilio.com/Messaging.MessageStatus/2"
    }
  ],
  "meta": {
    "page": 0,
    "page_size": 50,
    "first_page_url": "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0",
    "previous_page_url": null,
    "url": "https://events.twilio.com/v1/Schemas/Messaging.MessageStatus/Versions?PageSize=50&Page=0",
    "next_page_url": null,
    "key": "schema_versions"
  }
}
```
