# Conversational Intelligence - OperatorAttachment Subresource

The OperatorAttachment subresource represents the link between a specific [Pre-built](/docs/conversational-intelligence/api/prebuilt-operator-subresource) or [Custom](/docs/conversational-intelligence/api/custom-operator-subresource) Operator and a specific Intelligence Service. When you attach an Operator to a Service, it's available for use in that Service.

## Operator Properties

```json
{"type":"object","refName":"intelligence.v2.operator_attachment","modelName":"intelligence_v2_operator_attachment","properties":{"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^GA[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Service."},"operator_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^LY[0-9a-fA-F]{32}$","nullable":true,"description":"The unique SID identifier of the Operator."},"url":{"type":"string","format":"uri","nullable":true,"description":"The URL of this resource."}}}
```

## Create an Operator Attachment

`POST https://intelligence.twilio.com/v2/Services/{ServiceSid}/Operators/{OperatorSid}`

This endpoint attaches an Operator to an Intelligence Service.

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^GA[0-9a-fA-F]{32}$"},"required":true},{"name":"OperatorSid","in":"path","description":"The unique SID identifier of the Operator. Allows both Custom and Pre-built Operators.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^LY[0-9a-fA-F]{32}$"},"required":true}]
```

Create an Operator

```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 createOperatorAttachment() {
  const operatorAttachment = await client.intelligence.v2
    .operatorAttachment(
      "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    .create();

  console.log(operatorAttachment.serviceSid);
}

createOperatorAttachment();
```

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

operator_attachment = client.intelligence.v2.operator_attachment(
    "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).create()

print(operator_attachment.service_sid)
```

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

using System;
using Twilio;
using Twilio.Rest.Intelligence.V2;
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 operatorAttachment = await OperatorAttachmentResource.CreateAsync(
            pathServiceSid: "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathOperatorSid: "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(operatorAttachment.ServiceSid);
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.intelligence.v2.OperatorAttachment;

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);
        OperatorAttachment operatorAttachment =
            OperatorAttachment.creator("GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
                .create();

        System.out.println(operatorAttachment.getServiceSid());
    }
}
```

```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.IntelligenceV2.CreateOperatorAttachment("GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.ServiceSid != nil {
			fmt.Println(*resp.ServiceSid)
		} else {
			fmt.Println(resp.ServiceSid)
		}
	}
}
```

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

$operator_attachment = $twilio->intelligence->v2
    ->operatorAttachment(
        "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    ->create();

print $operator_attachment->serviceSid;
```

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

operator_attachment = @client
                      .intelligence
                      .v2
                      .operator_attachment('GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
                      .create

puts operator_attachment.service_sid
```

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

twilio api:intelligence:v2:services:operators:update \
   --service-sid GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --operator-sid LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X POST "https://intelligence.twilio.com/v2/Services/GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Operators/LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "operator_sid": "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "url": "https://intelligence.twilio.com/v2/Services/GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Operators/LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Delete an Operator Attachment

`DELETE https://intelligence.twilio.com/v2/Services/{ServiceSid}/Operators/{OperatorSid}`

This endpoint detaches an Operator from an Intelligence Service.

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The unique SID identifier of the Service.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^GA[0-9a-fA-F]{32}$"},"required":true},{"name":"OperatorSid","in":"path","description":"The unique SID identifier of the Operator. Allows both Custom and Pre-built Operators.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^LY[0-9a-fA-F]{32}$"},"required":true}]
```

Delete an Operator

```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 deleteOperatorAttachment() {
  await client.intelligence.v2
    .operatorAttachment(
      "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    .remove();
}

deleteOperatorAttachment();
```

```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.intelligence.v2.operator_attachment(
    "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
).delete()
```

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

using System;
using Twilio;
using Twilio.Rest.Intelligence.V2;
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 OperatorAttachmentResource.DeleteAsync(
            pathServiceSid: "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
            pathOperatorSid: "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    }
}
```

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

import com.twilio.Twilio;
import com.twilio.rest.intelligence.v2.OperatorAttachment;

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);
        OperatorAttachment.deleter("GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").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.IntelligenceV2.DeleteOperatorAttachment("GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
		"LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	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->intelligence->v2
    ->operatorAttachment(
        "GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
        "LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    )
    ->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
  .intelligence
  .v2
  .operator_attachment('GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  .delete
```

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

twilio api:intelligence:v2:services:operators:remove \
   --service-sid GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
   --operator-sid LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X DELETE "https://intelligence.twilio.com/v2/Services/GAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Operators/LYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```
