> For a complete page index, fetch https://docs.synthflow.ai/llms.txt. For full documentation content, fetch https://docs.synthflow.ai/llms-full.txt.

# Attach phone numbers to an outbound agent

PUT https://api.synthflow.ai/v2/assistants/{model_id}/phone_numbers
Content-Type: application/json

Attach multiple outbound phone numbers to an agent by phone numbers or by slugs.

Reference: https://docs.synthflow.ai/api-reference/platform-api/agents/attach-phone-numbers-to-assistant

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Synthflow APIs
  version: 1.0.0
paths:
  /assistants/{model_id}/phone_numbers:
    put:
      operationId: attach-phone-numbers-to-assistant
      summary: Attach phone numbers to an outbound agent
      description: >-
        Attach multiple outbound phone numbers to an agent by phone numbers or
        by slugs.
      tags:
        - ''
      parameters:
        - name: model_id
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/model_id'
        - name: Authorization
          in: header
          description: Bearer authentication
          required: true
          schema:
            type: string
      responses:
        '200':
          description: '200'
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/attach-phone-numbers-to-assistant_Response_200
        '404':
          description: '404'
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Attach-phone-numbers-to-assistantRequestNotFoundError
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/attach-phone-numbers-to-assistant_Request'
servers:
  - url: https://api.synthflow.ai/v2
  - url: https://api.us.synthflow.ai/v2
  - url: https://api.eu.synthflow.ai/v2
components:
  schemas:
    model_id:
      type: string
      description: Agent ID. You can find it on the agent’s page in your dashboard.
      title: model_id
    AttachPhoneNumbersToAssistantRequest0:
      type: object
      properties:
        phone_numbers:
          type: array
          items:
            type: string
          description: Phone numbers array.
      required:
        - phone_numbers
      title: AttachPhoneNumbersToAssistantRequest0
    AttachPhoneNumbersToAssistantRequest1:
      type: object
      properties:
        phone_number_slugs:
          type: array
          items:
            type: string
          description: Phone number slugs.
      required:
        - phone_number_slugs
      title: AttachPhoneNumbersToAssistantRequest1
    attach-phone-numbers-to-assistant_Request:
      oneOf:
        - $ref: '#/components/schemas/AttachPhoneNumbersToAssistantRequest0'
        - $ref: '#/components/schemas/AttachPhoneNumbersToAssistantRequest1'
      title: attach-phone-numbers-to-assistant_Request
    attach-phone-numbers-to-assistant_Response_200:
      type: object
      properties:
        status:
          type: string
      title: attach-phone-numbers-to-assistant_Response_200
    AssistantsModelIdPhoneNumbersPutResponsesContentApplicationJsonSchemaDetail:
      type: object
      properties:
        status:
          type: string
        description:
          type: string
        request_id:
          type: string
        category:
          type: string
      required:
        - status
        - description
        - request_id
        - category
      title: >-
        AssistantsModelIdPhoneNumbersPutResponsesContentApplicationJsonSchemaDetail
    Attach-phone-numbers-to-assistantRequestNotFoundError:
      type: object
      properties:
        detail:
          $ref: >-
            #/components/schemas/AssistantsModelIdPhoneNumbersPutResponsesContentApplicationJsonSchemaDetail
      title: Attach-phone-numbers-to-assistantRequestNotFoundError
  securitySchemes:
    sec0:
      type: http
      scheme: bearer

```

## SDK Code Examples

```python attach-phone-numbers-to-assistant_example
import requests

url = "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers"

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, headers=headers)

print(response.json())
```

```go attach-phone-numbers-to-assistant_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers"

	req, _ := http.NewRequest("PUT", url, nil)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby attach-phone-numbers-to-assistant_example
require 'uri'
require 'net/http'

url = URI("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'

response = http.request(request)
puts response.read_body
```

```java attach-phone-numbers-to-assistant_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

```csharp attach-phone-numbers-to-assistant_example
using RestSharp;

var client = new RestClient("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift attach-phone-numbers-to-assistant_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

```python Attach by phone numbers
import requests

url = "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers"

payload = { "phone_numbers": ["+16286666348", "+12131231214"] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```go Attach by phone numbers
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers"

	payload := strings.NewReader("{\n  \"phone_numbers\": [\n    \"+16286666348\",\n    \"+12131231214\"\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Attach by phone numbers
require 'uri'
require 'net/http'

url = URI("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phone_numbers\": [\n    \"+16286666348\",\n    \"+12131231214\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Attach by phone numbers
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phone_numbers\": [\n    \"+16286666348\",\n    \"+12131231214\"\n  ]\n}")
  .asString();
```

```csharp Attach by phone numbers
using RestSharp;

var client = new RestClient("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"phone_numbers\": [\n    \"+16286666348\",\n    \"+12131231214\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Attach by phone numbers
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["phone_numbers": ["+16286666348", "+12131231214"]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

```python Attach by slugs
import requests

url = "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers"

payload = { "phone_number_slugs": ["16286666348", "1231242151"] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```go Attach by slugs
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers"

	payload := strings.NewReader("{\n  \"phone_number_slugs\": [\n    \"16286666348\",\n    \"1231242151\"\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Attach by slugs
require 'uri'
require 'net/http'

url = URI("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"phone_number_slugs\": [\n    \"16286666348\",\n    \"1231242151\"\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Attach by slugs
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"phone_number_slugs\": [\n    \"16286666348\",\n    \"1231242151\"\n  ]\n}")
  .asString();
```

```csharp Attach by slugs
using RestSharp;

var client = new RestClient("https://api.synthflow.ai/v2/assistants/model_id/phone_numbers");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"phone_number_slugs\": [\n    \"16286666348\",\n    \"1231242151\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Attach by slugs
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["phone_number_slugs": ["16286666348", "1231242151"]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.synthflow.ai/v2/assistants/model_id/phone_numbers")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```