# Assistant Tools Resource

Manage Tools connected to an Assistant

## Tool Properties

<OperationTable type="properties" data={{"type":"object","required":["name","description","type","requires_auth","enabled","meta","id","date_updated","date_created"],"refName":"assistants.v1.service.tool","modelName":"assistants_v1_service_tool","properties":{"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","description":"The SID of the [Account](/docs/iam/api/account) that created the Tool resource."},"description":{"description":"The description of the tool.","type":"string"},"enabled":{"description":"True if the tool is enabled.","type":"boolean"},"id":{"type":"string","pattern":"^aia_tool_.+$","description":"The tool ID."},"meta":{"description":"The metadata related to method, url, input_schema to used with the Tool.","type":"object"},"name":{"description":"The name of the tool.","type":"string"},"requires_auth":{"description":"The authentication requirement for the tool.","type":"boolean"},"type":{"description":"The type of the tool. ('WEBHOOK')","type":"string"},"url":{"type":"string","description":"The url of the tool resource."},"date_created":{"description":"The date and time in GMT when the Tool was created specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.","format":"date-time","type":"string"},"date_updated":{"description":"The date and time in GMT when the Tool was last updated specified in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format.","format":"date-time","type":"string"}}}} />

## List all Tools connected to an Assistant

`GET https://assistants.twilio.com/v1/Assistants/{assistantId}/Tools`

### Path parameters

```json
[{"in":"path","name":"assistantId","description":"The assistant ID.","required":true,"schema":{"type":"string"}}]
```

### Query parameters

```json
[{"name":"Page","in":"query","description":"The page index. This value is simply for client state.","schema":{"type":"integer","minimum":0}},{"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","minimum":1,"maximum":1000}},{"name":"PageToken","in":"query","description":"The page token. This is provided by the API.","schema":{"type":"string"}}]
```

List all Tools connected to an Assistant

```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 listToolsByAssistant() {
  const assistantsTools = await client.assistants.v1
    .assistants("aia_asst_00000000-1111-2222-3333-444444444444")
    .assistantsTools.list({ limit: 20 });

  assistantsTools.forEach((a) => console.log(a.accountSid));
}

listToolsByAssistant();
```

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

assistants_tools = client.assistants.v1.assistants(
    "aia_asst_00000000-1111-2222-3333-444444444444"
).assistants_tools.list(limit=20)

for record in assistants_tools:
    print(record.account_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Assistants.V1.Assistant;
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 assistantsTools = await AssistantsToolResource.ReadAsync(
            pathAssistantId: "aia_asst_00000000-1111-2222-3333-444444444444", limit: 20);

        foreach (var record in assistantsTools) {
            Console.WriteLine(record.AccountSid);
        }
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.assistants.v1.assistant.AssistantsTool;
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<AssistantsTool> assistantsTools =
            AssistantsTool.reader("aia_asst_00000000-1111-2222-3333-444444444444").limit(20).read();

        for (AssistantsTool record : assistantsTools) {
            System.out.println(record.getAccountSid());
        }
    }
}
```

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

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

	resp, err := client.AssistantsV1.ListToolsByAssistant("aia_asst_00000000-1111-2222-3333-444444444444",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		for record := range resp {
			fmt.Println(resp[record].AccountSid)
		}
	}
}
```

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

$assistantsTools = $twilio->assistants->v1
    ->assistants("aia_asst_00000000-1111-2222-3333-444444444444")
    ->assistantsTools->read(20);

foreach ($assistantsTools as $record) {
    print $record->accountSid;
}
```

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

assistants_tools = @client
                   .assistants
                   .v1
                   .assistants('aia_asst_00000000-1111-2222-3333-444444444444')
                   .assistants_tools
                   .list(limit: 20)

assistants_tools.each do |record|
   puts record.account_sid
end
```

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

twilio api:assistants:v1:assistants:tools:list \
   --assistant-id aia_asst_00000000-1111-2222-3333-444444444444
```

```bash
curl -X GET "https://assistants.twilio.com/v1/Assistants/aia_asst_00000000-1111-2222-3333-444444444444/Tools?PageSize=20" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "meta": {
    "first_page_url": "https://www.example.com",
    "key": "key",
    "next_page_url": "https://www.example.com",
    "page": 42,
    "page_size": 42,
    "previous_page_url": "https://www.example.com",
    "url": "https://www.example.com"
  },
  "tools": [
    {
      "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "description": "description",
      "enabled": false,
      "id": "aia_tool_#",
      "meta": {},
      "name": "name",
      "requires_auth": false,
      "type": "type",
      "url": "https://www.example.com",
      "date_created": "2009-07-06T20:30:00Z",
      "date_updated": "2009-07-06T20:30:00Z"
    }
  ]
}
```

## Connect a Tool to an Assistant

`POST https://assistants.twilio.com/v1/Assistants/{assistantId}/Tools/{id}`

Once you've [**created a tool**](/docs/alpha/ai-assistants/api/tools#create-a-tool) using the `/v1/Tools` endpoint, you must connect it to an Assistant to allow your Assistant to call the tool.

### Path parameters

```json
[{"in":"path","name":"assistantId","description":"The assistant ID.","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","description":"The tool ID.","required":true,"schema":{"type":"string"}}]
```

Connect a Tool to an Assistant

```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 createAssistantToolAttachment() {
  await client.assistants.v1
    .assistants("aia_asst_00000000-1111-2222-3333-444444444444")
    .assistantsTools("aia_tool")
    .create();
}

createAssistantToolAttachment();
```

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

client.assistants.v1.assistants(
    "aia_asst_00000000-1111-2222-3333-444444444444"
).assistants_tools("aia_tool").create()
```

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

using System;
using Twilio;
using Twilio.Rest.Assistants.V1.Assistant;
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);

        await AssistantsToolResource.CreateAsync(
            pathAssistantId: "aia_asst_00000000-1111-2222-3333-444444444444", pathId: "aia_tool");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.assistants.v1.assistant.AssistantsTool;

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);
        AssistantsTool.creator("aia_asst_00000000-1111-2222-3333-444444444444", "aia_tool").create();
    }
}
```

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

	err := client.AssistantsV1.CreateAssistantToolAttachment("aia_asst_00000000-1111-2222-3333-444444444444",
		"aia_tool")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

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

$twilio->assistants->v1
    ->assistants("aia_asst_00000000-1111-2222-3333-444444444444")
    ->assistantsTools("aia_tool")
    ->create();
```

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

@client
  .assistants
  .v1
  .assistants('aia_asst_00000000-1111-2222-3333-444444444444')
  .assistants_tools('aia_tool')
  .create
```

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

twilio api:assistants:v1:assistants:tools:update \
   --assistant-id aia_asst_00000000-1111-2222-3333-444444444444 \
   --id aia_tool
```

```bash
curl -X POST "https://assistants.twilio.com/v1/Assistants/aia_asst_00000000-1111-2222-3333-444444444444/Tools/aia_tool" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

## Detach a Tool from an Assistant

`DELETE https://assistants.twilio.com/v1/Assistants/{assistantId}/Tools/{id}`

This endpoint removes a Tool from your Assistant's configuration, so it can no longer be called by that Assistant.

### Path parameters

```json
[{"in":"path","name":"assistantId","description":"The assistant ID.","required":true,"schema":{"type":"string"}},{"in":"path","name":"id","description":"The tool ID.","required":true,"schema":{"type":"string"}}]
```

Detach a Tool from an Assistant

```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 deleteAssistantToolAttachment() {
  await client.assistants.v1
    .assistants("aia_asst_00000000-1111-2222-3333-444444444444")
    .assistantsTools("aia_tool")
    .remove();
}

deleteAssistantToolAttachment();
```

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

client.assistants.v1.assistants(
    "aia_asst_00000000-1111-2222-3333-444444444444"
).assistants_tools("aia_tool").delete()
```

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

using System;
using Twilio;
using Twilio.Rest.Assistants.V1.Assistant;
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);

        await AssistantsToolResource.DeleteAsync(
            pathAssistantId: "aia_asst_00000000-1111-2222-3333-444444444444", pathId: "aia_tool");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.assistants.v1.assistant.AssistantsTool;

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);
        AssistantsTool.deleter("aia_asst_00000000-1111-2222-3333-444444444444", "aia_tool").delete();
    }
}
```

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

	err := client.AssistantsV1.DeleteAssistantToolAttachment("aia_asst_00000000-1111-2222-3333-444444444444",
		"aia_tool")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}
}
```

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

$twilio->assistants->v1
    ->assistants("aia_asst_00000000-1111-2222-3333-444444444444")
    ->assistantsTools("aia_tool")
    ->delete();
```

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

@client
  .assistants
  .v1
  .assistants('aia_asst_00000000-1111-2222-3333-444444444444')
  .assistants_tools('aia_tool')
  .delete
```

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

twilio api:assistants:v1:assistants:tools:remove \
   --assistant-id aia_asst_00000000-1111-2222-3333-444444444444 \
   --id aia_tool
```

```bash
curl -X DELETE "https://assistants.twilio.com/v1/Assistants/aia_asst_00000000-1111-2222-3333-444444444444/Tools/aia_tool" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
