# Marketplace API Migration Guide for publishers

> \[!WARNING]
>
> The Marketplace Preview API is deprecated. Migrate from Preview to v1 to ensure uninterrupted service.

The Marketplace v1 API replaces the Preview API and provides increased reliability for production environments. All Marketplace users and publishers should use v1.

This migration guide shows you how to migrate your calls from Preview to v1 and lists the Marketplace API resources that require migration.

## How to migrate

To migrate from Preview to v1, update the base URL of your API calls.

For calls made using curl, update the base URL from `https://preview.twilio.com/marketplace` to `https://marketplace.twilio.com/v1`.

For calls made using the Twilio server-side SDK, update the method from `preview` to `marketplace`. The specific change depends on the programming language used, as shown in the following migration example.

### Migration example

The following example shows how to migrate a call to the AvailableAddOns resource from Preview to v1.

```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 listMarketplaceAvailableAddOn() {
  const availableAddOns = await client.preview.marketplace.availableAddOns.list(
    { limit: 20 }
  );

  availableAddOns.forEach((a) => console.log(a.sid));
}

listMarketplaceAvailableAddOn();
```

```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)

available_add_ons = client.preview.marketplace.available_add_ons.list(limit=20)

for record in available_add_ons:
    print(record.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Preview.Marketplace;
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 availableAddOns = await AvailableAddOnResource.ReadAsync(limit: 20);

        foreach (var record in availableAddOns) {
            Console.WriteLine(record.Sid);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.preview.marketplace.AvailableAddOn;
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<AvailableAddOn> availableAddOns = AvailableAddOn.reader().limit(20).read();

        for (AvailableAddOn record : availableAddOns) {
            System.out.println(record.getSid());
        }
    }
}
```

```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);

$availableAddOns = $twilio->preview->marketplace->availableAddOns->read(20);

foreach ($availableAddOns as $record) {
    print $record->sid;
}
```

```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)

available_add_ons = @client
                    .preview
                    .marketplace
                    .available_add_ons
                    .list(limit: 20)

available_add_ons.each do |record|
   puts record.sid
end
```

```bash
curl -X GET "https://preview.twilio.com/marketplace/AvailableAddOns?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

To migrate to v1, update the base URL:

```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 listAvailableAddOn() {
  const availableAddOns = await client.marketplace.v1.availableAddOns.list({
    limit: 20,
  });

  availableAddOns.forEach((a) => console.log(a.sid));
}

listAvailableAddOn();
```

```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)

available_add_ons = client.marketplace.v1.available_add_ons.list(limit=20)

for record in available_add_ons:
    print(record.sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Marketplace.V1;
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 availableAddOns = await AvailableAddOnResource.ReadAsync(limit: 20);

        foreach (var record in availableAddOns) {
            Console.WriteLine(record.Sid);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.marketplace.v1.AvailableAddOn;
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<AvailableAddOn> availableAddOns = AvailableAddOn.reader().limit(20).read();

        for (AvailableAddOn record : availableAddOns) {
            System.out.println(record.getSid());
        }
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	marketplace "github.com/twilio/twilio-go/rest/marketplace/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 := &marketplace.ListAvailableAddOnParams{}
	params.SetLimit(20)

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

```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);

$availableAddOns = $twilio->marketplace->v1->availableAddOns->read(20);

foreach ($availableAddOns as $record) {
    print $record->sid;
}
```

```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)

available_add_ons = @client
                    .marketplace
                    .v1
                    .available_add_ons
                    .list(limit: 20)

available_add_ons.each do |record|
   puts record.sid
end
```

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

twilio api:marketplace:v1:available-add-ons:list
```

```bash
curl -X GET "https://marketplace.twilio.com/v1/AvailableAddOns?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Affected API resources

As a Publisher, you need to change the base URL for each API resource as follows:

* Replace the **Module resource** from the Preview API with [Listing Resource](/docs/marketplace/api/listing) in v1. Update both the API base URL and resource name to migrate to v1. Refer to the [Listing Resource](/docs/marketplace/api/listing) documentation for more information and v1 examples.
  * Preview: `https://preview.twilio.com/marketplace/Module/{{ModuleSid}}`
  * v1: `https://marketplace.twilio.com/v1/Listing/{{ListingSid}}`
* [Installed Add-ons Usage Subresource](/docs/marketplace/api/installed-add-ons-usage)
  * Preview: `https://preview.twilio.com/marketplace/InstalledAddOns/{{InstalledAddOnSid}}/Usage`
  * v1: `https://marketplace.twilio.com/v1/InstalledAddOns/{{InstalledAddOnSid}}/Usage`
