> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# SQ_GetAgents

POST https://api.voximplant.com/platform_api/SQ_GetAgents

Gets agents.

**Example request:** Get all agents with their current statuses.

Reference: https://docs.voximplant.ai/api-reference/management-api/reference/smartqueue/sq-get-agents

## Authentication

- `Authorization` header (bearer token, required) — Voximplant Management API uses signed JWT tokens generated from your service-account private key. Pass the token in the `Authorization` header as a Bearer value: ``` Authorization: Bearer $VOXIMPLANT_TOKEN ``` See [Authorization](/api-reference/management-api/authorization) for ready-to-copy snippets in bash, Python, Node.js and Go that turn your `credentials.json` into a token.

## Request

### Query parameters

- `application_id` (integer, required) — Application ID to search by
- `application_name` (string, optional) — Application name to search by. Can be used instead of **application_id**
- `sq_queue_id` (list of integer, optional) — List of SmartQueue IDs separated by semicolons (;). Use 'all' to select all the queues
- `sq_queue_name` (list of string, optional) — List of SmartQueue names separated by semicolons (;). Can be used instead of **sq_queue_id**
- `excluded_sq_queue_id` (integer, optional) — ID of the SmartQueue to exclude
- `excluded_sq_queue_name` (string, optional) — Name of the SmartQueue to exclude. Can be used instead of **excluded_sq_queue_id**
- `sq_skills` (map from string to any, optional) — Skills to filter in the json array format. The array should contain objects with the **sq_skill_id**/**sq_skill_name**, **min_sq_skill_level**, and **max_sq_skill_level** keys where skill levels range from 1 to 5
- `user_id` (list of integer, optional) — List of user IDs separated by semicolons (;)
- `user_name` (list of string, optional) — List of user names separated by semicolons (;). Can be used instead of **user_id**
- `user_name_template` (string, optional) — Substring of the user name to filter
- `sq_statuses` (map from string to any, optional) — Filter statuses in the json array format. The array should contain objects with the **sq_status_type** and **sq_status_name** keys. Possible values for **sq_status_type** are 'CALL' and 'IM'. Possible values for **sq_status_name** are 'OFFLINE', 'ONLINE', 'READY', 'IN_SERVICE', 'AFTER_SERVICE', 'DND'
- `with_sq_skills` (boolean, optional, default: false) — Whether to display agent skills
- `with_sq_queues` (boolean, optional, default: false) — Whether to display agent queues
- `with_sq_statuses` (boolean, optional, default: false) — Whether to display agent current statuses
- `count` (integer, optional, default: 20) — Number of items to show in the output
- `offset` (integer, optional, default: 0) — Number of items to skip in the output
- `handle_calls` (boolean, required) — Whether the agent can handle calls. When set to false, the agent is excluded from the CALL-request distribution

## Response

### 200

Successful response

- `result` (list of GetSQAgentsResult, optional) — The found agent(s)
- `count` (integer, optional)
- `total_count` (integer, optional)

## Types

### GetSQAgentsResult

The [SQ_GetAgents] function result.

- `user_id` (integer, optional) — ID of the user
- `user_name` (string, optional) — Name of the user
- `user_display_name` (string, optional) — Display name of the user
- `max_simultaneous_conversations` (integer, optional) — Maximum number of chats that the user processes simultaneously
- `sq_statuses` (GetSqAgentsResultSqStatuses, optional) — Agent statuses info
- `sq_queues` (map from string to any, optional) — JSON array of the agent's queues
- `sq_skills` (map from string to any, optional) — JSON array of the agent's skills
- `user_name:` (string, optional)

### GetSqAgentsResultSqStatuses

Agent statuses info

- list of any
- GetSqAgentsResultSqStatuses1

### GetSqAgentsResultSqStatuses1

- `CALL` (GetSqAgentsResultSqStatusesOneOf1Call, optional)
- `IM` (GetSqAgentsResultSqStatusesOneOf1Im, optional)

### GetSqAgentsResultSqStatusesOneOf1Call

- `sq_status_name` (string, optional)

### GetSqAgentsResultSqStatusesOneOf1Im

- `sq_status_name` (string, optional)

## Examples

**Response**

```json
{
  "result": [
    {
      "user_id": 2,
      "user_display_name": "John",
      "max_simultaneous_conversations": 3,
      "sq_statuses": {
        "CALL": {
          "sq_status_name": "READY"
        },
        "IM": {
          "sq_status_name": "ONLINE"
        }
      },
      "user_name:": "johnDoe"
    }
  ],
  "count": 1,
  "total_count": 1
}
```

**SDK Code**

```python Example 1
import requests

url = "https://api.voximplant.com/platform_api/SQ_GetAgents"

querystring = {"application_id":"1","handle_calls":"true"}

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Example 1
const url = 'https://api.voximplant.com/platform_api/SQ_GetAgents?application_id=1&handle_calls=true';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Example 1
package main

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

func main() {

	url := "https://api.voximplant.com/platform_api/SQ_GetAgents?application_id=1&handle_calls=true"

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

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

```ruby Example 1
require 'uri'
require 'net/http'

url = URI("https://api.voximplant.com/platform_api/SQ_GetAgents?application_id=1&handle_calls=true")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

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

```java Example 1
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.voximplant.com/platform_api/SQ_GetAgents?application_id=1&handle_calls=true")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Example 1
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.voximplant.com/platform_api/SQ_GetAgents?application_id=1&handle_calls=true', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

echo $response->getBody();
```

```csharp Example 1
using RestSharp;

var client = new RestClient("https://api.voximplant.com/platform_api/SQ_GetAgents?application_id=1&handle_calls=true");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Example 1
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.voximplant.com/platform_api/SQ_GetAgents?application_id=1&handle_calls=true")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```