# Deactivations resource

The Deactivations resource retrieves a list of United States phone numbers that have been deactivated by mobile carriers. These phone numbers are no longer in service for the subscriber who used to own that number. Twilio updates the set of available reports daily.

These reports should be used periodically to remove deactivated phone numbers from your opted-in subscriber list. For more information how to use these reports, see the ["Handling Deactivated Phone Numbers" Help Center article](https://help.twilio.com/hc/en-us/articles/360042744973-Handling-Deactivated-Phone-Numbers).

API requests to the Deactivations resource are free of charge.

## Deactivation Properties

```json
{"type":"object","refName":"messaging.v1.deactivation","modelName":"messaging_v1_deactivation","properties":{"redirect_to":{"type":"string","format":"uri","nullable":true,"description":"Returns an authenticated url that redirects to a file containing the deactivated numbers for the requested day. This url is valid for up to two minutes."}}}
```

## Retrieve a list of Deactivations

`GET https://messaging.twilio.com/v1/Deactivations`

Retrieve a list of deactivated numbers for a specific date.

You must include the Date parameter with a date value in `YYYY-MM-DD` format.

Twilio's response contains a `redirect_to` property with a signed URL for the requested date's deactivations list in `.txt` format.

### Query parameters

```json
[{"name":"Date","in":"query","description":"The request will return a list of all United States Phone Numbers that were deactivated on the day specified by this parameter. This date should be specified in YYYY-MM-DD format.","schema":{"type":"string","format":"date"}}]
```

Fetch deactivations for August 13, 2023

```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 fetchDeactivation() {
  const deactivation = await client.messaging.v1
    .deactivations()
    .fetch({ date: "2023-08-13" });

  console.log(deactivation.redirectTo);
}

fetchDeactivation();
```

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

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

deactivation = client.messaging.v1.deactivations().fetch(date=date(2023, 8, 13))

print(deactivation.redirect_to)
```

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

using System;
using Twilio;
using Twilio.Rest.Messaging.V1;
using System.Threading.Tasks;
using Twilio.Converters;

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 deactivations = await DeactivationsResource.FetchAsync(
            date: MarshalConverter.DateTimeFromString("2023-08-13"));

        Console.WriteLine(deactivations.RedirectTo);
    }
}
```

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

import java.time.LocalDate;
import com.twilio.Twilio;
import com.twilio.rest.messaging.v1.Deactivations;

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);
        Deactivations deactivations = Deactivations.fetcher().setDate(LocalDate.of(2023, 8, 13)).fetch();

        System.out.println(deactivations.getRedirectTo());
    }
}
```

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

import (
	"fmt"
	"github.com/twilio/twilio-go"
	messaging "github.com/twilio/twilio-go/rest/messaging/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 := &messaging.FetchDeactivationParams{}
	params.SetDate("2023-08-13")

	resp, err := client.MessagingV1.FetchDeactivation(params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.RedirectTo != nil {
			fmt.Println(*resp.RedirectTo)
		} else {
			fmt.Println(resp.RedirectTo)
		}
	}
}
```

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

$deactivation = $twilio->messaging->v1
    ->deactivations()
    ->fetch(["date" => new \DateTime("2023-08-13")]);

print $deactivation->redirectTo;
```

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

deactivation = @client
               .messaging
               .v1
               .deactivations
               .fetch(date: Date.new(2023, 8, 13))

puts deactivation.redirect_to
```

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

twilio api:messaging:v1:deactivations:fetch \
   --date 2023-08-13
```

```bash
curl -X GET "https://messaging.twilio.com/v1/Deactivations?Date=2023-08-13" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "redirect_to": "https://com-twilio-dev-messaging-deactivations.s3.amazonaws.com"
}
```
