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

# GetRules

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

Gets the rules.

Allowed roles: `Owner`, `Admin`, `Developer`, `Supervisor`, `Call list manager`, `Support`.

**Example request:** Get the first rule for the template 74951234567.

Reference: https://docs.voximplant.ai/api-reference/management-api/reference/rules/get-rules

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: management-api
  version: 1.0.0
paths:
  /GetRules:
    post:
      operationId: get-rules
      summary: GetRules
      description: >-
        Gets the rules.


        Allowed roles: `Owner`, `Admin`, `Developer`, `Supervisor`, `Call list
        manager`, `Support`.


        **Example request:** Get the first rule for the template 74951234567.
      tags:
        - subpackage_rules
      parameters:
        - name: application_id
          in: query
          description: >-
            The application ID. **Required** unless **application_name** is
            provided.
          required: false
          schema:
            type: integer
        - name: application_name
          in: query
          description: >-
            The application name. **Required** unless **application_id** is
            provided.
          required: false
          schema:
            type: string
        - name: rule_id
          in: query
          description: The rule ID to filter
          required: false
          schema:
            type: integer
        - name: rule_name
          in: query
          description: The rule name part to filter
          required: false
          schema:
            type: string
        - name: video_conference
          in: query
          description: Whether it is a video conference to filter
          required: false
          schema:
            type: boolean
        - name: attached_key_id
          in: query
          description: >-
            The service account ID bound to the rule. Read more in the
            [guide](/docs/guides/voxengine/management-api)
          required: false
          schema:
            type: string
        - name: template
          in: query
          description: Search for template matching
          required: false
          schema:
            type: string
        - name: with_scenarios
          in: query
          description: Whether to get bound scenarios info
          required: false
          schema:
            type: boolean
        - name: count
          in: query
          description: The max returning record count
          required: false
          schema:
            type: integer
            default: 20
        - name: offset
          in: query
          description: The first **N** records are skipped in the output
          required: false
          schema:
            type: integer
            default: 0
        - name: Authorization
          in: header
          description: >-
            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.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/rules_GetRules_Response_200'
servers:
  - url: https://api.voximplant.com/platform_api
components:
  schemas:
    ScenarioInfoType:
      type: object
      properties:
        scenario_id:
          type: integer
          description: The scenario ID
        scenario_name:
          type: string
          description: The scenario name
        scenario_script:
          type: string
          description: The scenario text
        modified:
          type: string
          description: |-
            Timestamp in YYYY-MM-DD HH:mm:ss format.

            The scenario editing UTC date in 24-h format: YYYY-MM-DD HH:mm:ss
        parent:
          type: boolean
          description: >-
            Whether the scenario belongs to the parent account, 'false' if the
            scenario belongs to the current account
      description: The [GetScenarios] function result.
      title: ScenarioInfoType
    RuleInfoType:
      type: object
      properties:
        rule_id:
          type: integer
          description: The rule ID
        application_id:
          type: integer
          description: The application ID
        rule_name:
          type: string
          description: The rule name
        rule_pattern:
          type: string
          description: The rule pattern regex
        rule_pattern_exclude:
          type: string
          description: The rule pattern excluding regex
        video_conference:
          type: boolean
          description: Whether video conference is required
        scenarios:
          type: array
          items:
            $ref: '#/components/schemas/ScenarioInfoType'
          description: The bound scenarios
        modified:
          type: string
          description: |-
            Timestamp in YYYY-MM-DD HH:mm:ss format.

            The rule editing UTC date in 24-h format: YYYY-MM-DD HH:mm:ss
      description: The [GetRules] function result item.
      title: RuleInfoType
    rules_GetRules_Response_200:
      type: object
      properties:
        result:
          type: array
          items:
            $ref: '#/components/schemas/RuleInfoType'
        total_count:
          type: integer
          description: The total found rule count
        count:
          type: integer
          description: The returned rule count
      title: rules_GetRules_Response_200
  securitySchemes:
    JwtAuth:
      type: http
      scheme: bearer
      description: >-
        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.

```

## SDK Code Examples

```python Example 1
import requests

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

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

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

print(response.json())
```

```javascript Example 1
const url = 'https://api.voximplant.com/platform_api/GetRules';
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/GetRules"

	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/GetRules")

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/GetRules")
  .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/GetRules', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Example 1
using RestSharp;

var client = new RestClient("https://api.voximplant.com/platform_api/GetRules");
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/GetRules")! 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()
```