Skip to main content

You are viewing Agora Docs forBetaproducts and features. Switch to Docs

Create rule

This method creates a rule for banning specified user privileges.

Prototype

  • Method: POST
  • Endpoint: https://api.agora.io/dev/v1/kicking-rule

The user privileges that can be banned include:

  • join_channel: Joining a channel.

  • publish_audio: Publishing audio.

  • publish_video: Publishing video.

The banning rule works based on the following three fields: cname, uid, and ip.

When you set privileges as join_channel, the rule works as follows:

ipcnameUIDRule
All users with this ip cannot join any channel in the app. Using ip as a filter field may incorrectly block users who should not be blocked, for example, in a scenario where multiple users share an IP address.
No one can join the channel specified by the cname field. Using cname as a filter field directly blocks the channel with the cname.
The user with the UID cannot join any channel in the app.
The user with the UID cannot join the channel specified by the cname field.

When you set privileges as publish_audio or publish_video, the rule works as follows:

ipcnameUIDRule
The users with this ip cannot publish audio or video in any channel of the app.
No one can publish audio or video in the channel specified by the cname field.
The user with the UID cannot publish audio or video in any channel of the app.
The user with the UID cannot publish audio or video in the channel specified by the cname field.

A user who is kicked out of a channel when you set privileges as join_channel receives one of the following callbacks based on their platform:

  • Android: The onConnectionStateChanged callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3).
  • iOS/macOS: The connectionChangedToState callback reports AgoraConnectionChangedBannedByServer(3).
  • Web (3.x): The Client.on("client-banned") callback.
  • Web (4.x): The Client.on("connection-state-change") callback.
  • Windows:The onConnectionStateChanged callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3).
  • Electron: The AgoraRtcEngine.on("connectionStateChanged") callback reports 3.
  • Unity: The OnConnectionStateChangedHandler callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3).
  • React Native: The ConnectionStateChanged callback reports BannedByServer(3).
  • Flutter: The ConnectionStateChanged callback reports BannedByServer(3).
  • Cocos Creator: The onConnectionStateChanged callback reports CONNECTION_CHANGED_BANNED_BY_SERVER(3).
  • Applets: on(event: "client-banned").
Note

To maximize the success rate of core functions, create (POST), update (PUT), and delete (DELETE), the success rate and accuracy of the query (GET) method is degraded to a certain extent when the quality of the public network is abnormally low. Some request records may be missing in the returned results of the query (GET). When calling POST to create a rule (time is not set to 0), which you need to update or delete later, best practice is to:

  • Save the rule ID returned in the POST request on your server, and rely on this ID for subsequent update and delete operations.
  • To ensure that you can still obtain the rule ID returned in the POST request under poor network connections, set the timeout for the POST request to 20 seconds or higher. Make sure that the timeout is set to no less than 5 seconds.
  • In case the POST request times out or returns a 504 error, use the response of the GET method to obtain the rule ID. If the rule exists, it indicates that the POST request is successful, and you can save the rule ID on your server.

Request parameters

Request header

The Content-Type field in all HTTP request headers is application/json. All requests and responses are in JSON format. All request URLs and request bodies are case-sensitive.

The Agora Channel Management RESTful APIs only support HTTPS. Before sending HTTP requests, you must generate a Base64-encoded credential with the Customer ID and Customer Secret provided by Agora, and pass the credential to the Authorization field in the HTTP request header. See RESTful authentication for details.

Request body

Pass in the following parameters in the request body:

ParameterData typeRequired/OptionalDescription
appidStringRequiredThe App ID of the project. You can get it through one of the following methods:
  • Copy from the Agora Console
  • Call the Get all projects API, and read the value of the vendor_key field in the response body.
  • cnameStringOptionalThe channel name.
    uidNumberOptionalThe user ID. Do not set it as 0.
    ipStringOptionalThe IP address of the user. Do not set it as 0.
    timeNumberRequiredThe time duration (in minutes) to ban the user. The value range is [1,1440].

    Note

  • If the set value is between 0 and 1, Agora automatically sets the value to 1.
  • If the set value is greater than 1440, Agora automatically sets the value to 1440.
  • If the set value is 0, the banning rule does not take effect. The server sets all users that conform to the rule offline, and users can log in again to rejoin the channel.
  • Use either time or time_in_seconds. If you set both parameters, the time_in_seconds parameter takes effect; if you set neither of these parameters, the Agora server automatically sets the banning time duration to 60 minutes, that is, 3600 seconds.
  • time_in_secondsNumberRequiredThe time duration (in seconds) to ban the user. The value range is [10,86430].

    Note

  • If the set value is between 0 and 10, Agora automatically sets the value to 10.
  • If the set value is greater than 86430, Agora automatically sets the value to 86430.
  • If the set value is 0, the banning rule does not take effect. The server sets all users that conform to the rule offline, and users can log in again to rejoin the channel.
  • Use either time or time_in_seconds. If you set both parameters, the time_in_seconds parameter takes effect; if you set neither of these parameters, the Agora server automatically sets the banning time duration to 60 minutes, that is, 3600 seconds.
  • privilegesArrayRequiredThe user privileges you want to block. You can choose the following values:
  • join_channel: String. Bans a user from joining a channel or kicks a user out of a channel.
  • publish_audio: String. Bans a user from publishing audio.
  • publish_video: Bans a user from publishing video.
  • You can pass in both publish_audio and publish_video to ban a user from publishing audio and video.

    Request examples

    Test this request in Postman or use one of the following code examples:

    Shell
    • curl
      curl --request POST   --url http://api.sd-rtn.com/dev/v1/kicking-rule   --header 'Accept: application/json'   --header 'Authorization: '   --header 'Content-Type: application/json'   --data '{  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",  "cname": "channel1",  "uid": 589517928,  "ip": "",  "time": 60,  "privileges": [    "join_channel"  ]}'
    • HTTPie
      echo '{  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",  "cname": "channel1",  "uid": 589517928,  "ip": "",  "time": 60,  "privileges": [    "join_channel"  ]}' |  \  http POST http://api.sd-rtn.com/dev/v1/kicking-rule \  Accept:application/json \  Authorization:'' \  Content-Type:application/json
    • wget
      wget --quiet \  --method POST \  --header 'Authorization: ' \  --header 'Content-Type: application/json' \  --header 'Accept: application/json' \  --body-data '{\n  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",\n  "cname": "channel1",\n  "uid": 589517928,\n  "ip": "",\n  "time": 60,\n  "privileges": [\n    "join_channel"\n  ]\n}' \  --output-document \  - http://api.sd-rtn.com/dev/v1/kicking-rule
    Javascript
    • Fetch
      const url = 'http://api.sd-rtn.com/dev/v1/kicking-rule';const options = {  method: 'POST',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  },  body: '{"appid":"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2","cname":"channel1","uid":589517928,"ip":"","time":60,"privileges":["join_channel"]}'};try {  const response = await fetch(url, options);  const data = await response.json();  console.log(data);} catch (error) {  console.error(error);}
    • XMLHTTPRequest
      const url = 'http://api.sd-rtn.com/dev/v1/kicking-rule';const options = {  method: 'POST',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  },  body: '{"appid":"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2","cname":"channel1","uid":589517928,"ip":"","time":60,"privileges":["join_channel"]}'};try {  const response = await fetch(url, options);  const data = await response.json();  console.log(data);} catch (error) {  console.error(error);}
    • jQuery
      const settings = {  async: true,  crossDomain: true,  url: 'http://api.sd-rtn.com/dev/v1/kicking-rule',  method: 'POST',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  },  processData: false,  data: '{\n  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",\n  "cname": "channel1",\n  "uid": 589517928,\n  "ip": "",\n  "time": 60,\n  "privileges": [\n    "join_channel"\n  ]\n}'};$.ajax(settings).done(function (response) {  console.log(response);});
    • Axios
      import axios from 'axios';const options = {  method: 'POST',  url: 'http://api.sd-rtn.com/dev/v1/kicking-rule',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  },  data: {    appid: '4855xxxxxxxxxxxxxxxxxxxxxxxxeae2',    cname: 'channel1',    uid: 589517928,    ip: '',    time: 60,    privileges: ['join_channel']  }};try {  const { data } = await axios.request(options);  console.log(data);} catch (error) {  console.error(error);}
    Node
    • Native
      const http = require('http');const options = {  method: 'POST',  hostname: 'api.sd-rtn.com',  port: null,  path: '/dev/v1/kicking-rule',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  }};const req = http.request(options, function (res) {  const chunks = [];  res.on('data', function (chunk) {    chunks.push(chunk);  });  res.on('end', function () {    const body = Buffer.concat(chunks);    console.log(body.toString());  });});req.write(JSON.stringify({  appid: '4855xxxxxxxxxxxxxxxxxxxxxxxxeae2',  cname: 'channel1',  uid: 589517928,  ip: '',  time: 60,  privileges: ['join_channel']}));req.end();
    • Request
      const request = require('request');const options = {  method: 'POST',  url: 'http://api.sd-rtn.com/dev/v1/kicking-rule',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  },  body: {    appid: '4855xxxxxxxxxxxxxxxxxxxxxxxxeae2',    cname: 'channel1',    uid: 589517928,    ip: '',    time: 60,    privileges: ['join_channel']  },  json: true};request(options, function (error, response, body) {  if (error) throw new Error(error);  console.log(body);});
    • Unirest
      const unirest = require('unirest');const req = unirest('POST', 'http://api.sd-rtn.com/dev/v1/kicking-rule');req.headers({  Authorization: '',  'Content-Type': 'application/json',  Accept: 'application/json'});req.type('json');req.send({  appid: '4855xxxxxxxxxxxxxxxxxxxxxxxxeae2',  cname: 'channel1',  uid: 589517928,  ip: '',  time: 60,  privileges: [    'join_channel'  ]});req.end(function (res) {  if (res.error) throw new Error(res.error);  console.log(res.body);})
    • Fetch
      const fetch = require('node-fetch');const url = 'http://api.sd-rtn.com/dev/v1/kicking-rule';const options = {  method: 'POST',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  },  body: '{"appid":"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2","cname":"channel1","uid":589517928,"ip":"","time":60,"privileges":["join_channel"]}'};try {  const response = await fetch(url, options);  const data = await response.json();  console.log(data);} catch (error) {  console.error(error);}
    • Axios
      const axios = require('axios').default;const options = {  method: 'POST',  url: 'http://api.sd-rtn.com/dev/v1/kicking-rule',  headers: {    Authorization: '',    'Content-Type': 'application/json',    Accept: 'application/json'  },  data: {    appid: '4855xxxxxxxxxxxxxxxxxxxxxxxxeae2',    cname: 'channel1',    uid: 589517928,    ip: '',    time: 60,    privileges: ['join_channel']  }};try {  const { data } = await axios.request(options);  console.log(data);} catch (error) {  console.error(error);}
    Python
    • Python 3
      import http.clientimport jsonconn = http.client.HTTPConnection("api.sd-rtn.com")payload = {    "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",    "cname": "channel1",    "uid": 589517928,    "ip": "",    "time": 60,    "privileges": [        "join_channel"    ]}headers = {    'Authorization': "",    'Content-Type': "application/json",    'Accept': "application/json"}conn.request("POST", "/dev/v1/kicking-rule", json.dumps(payload), headers)res = conn.getresponse()data = res.read()print(data.decode("utf-8"))
    • Requests
      import requestsurl = "http://api.sd-rtn.com/dev/v1/kicking-rule"payload = {    "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",    "cname": "channel1",    "uid": 589517928,    "ip": "",    "time": 60,    "privileges": ["join_channel"]}headers = {    "Authorization": "",    "Content-Type": "application/json",    "Accept": "application/json"}response = requests.post(url, json=payload, headers=headers)print(response.json())
    Go
    package mainimport (    "fmt"    "strings"    "net/http"    "io")func main() {  url := "http://api.sd-rtn.com/dev/v1/kicking-rule"  payload := strings.NewReader(`{"appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2", "cname": "channel1", "uid": 589517928, "ip": "", "time": 60, "privileges": ["join_channel"]}`)  req, _ := http.NewRequest("POST", url, payload)  req.Header.Add("Authorization", "")  req.Header.Add("Content-Type", "application/json")  req.Header.Add("Accept", "application/json")  res, _ := http.DefaultClient.Do(req)  defer res.Body.Close()  body, _ := io.ReadAll(res.Body)  fmt.Println(res)  fmt.Println(string(body))}
    C
    CURL *hnd = curl_easy_init();curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "http://api.sd-rtn.com/dev/v1/kicking-rule");struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "Authorization: ");headers = curl_slist_append(headers, "Content-Type: application/json");headers = curl_slist_append(headers, "Accept: application/json");curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"appid": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\", \"cname\": \"channel1\", \"uid\": 589517928, \"ip\": \"\", \"time\": 60, \"privileges\": [\"join_channel\"]}");CURLcode ret = curl_easy_perform(hnd);
    Objective-C
    #import <Foundation/Foundation.h>NSDictionary *headers = @{ @"Authorization": @"",                           @"Content-Type": @"application/json",                           @"Accept": @"application/json" };NSDictionary *parameters = @{ @"appid": @"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",                              @"cname": @"channel1",                              @"uid": @589517928,                              @"ip": @"",                              @"time": @60,                              @"privileges": @[ @"join_channel" ] };NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://api.sd-rtn.com/dev/v1/kicking-rule"]                                                       cachePolicy:NSURLRequestUseProtocolCachePolicy                                                   timeoutInterval:10.0];[request setHTTPMethod:@"POST"];[request setAllHTTPHeaderFields:headers];[request setHTTPBody:postData];NSURLSession *session = [NSURLSession sharedSession];NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request                                            completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {                                                if (error) {                                                    NSLog(@"%@", error);                                                } else {                                                    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;                                                    NSLog(@"%@", httpResponse);                                                }                                            }];[dataTask resume];
    OCaml
    open Cohttp_lwt_unixopen Cohttpopen Lwtlet uri = Uri.of_string "http://api.sd-rtn.com/dev/v1/kicking-rule" inlet headers = Header.add_list (Header.init ()) [  ("Authorization", "");  ("Content-Type", "application/json");  ("Accept", "application/json");] inlet body = Cohttp_lwt_body.of_string "{\"appid": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\", \"cname\": \"channel1\", \"uid\": 589517928, \"ip\": \"\", \"time\": 60, \"privileges\": [\"join_channel\"]}" inClient.call ~headers ~body `POST uri>>= fun (res, body_stream) ->  (* Do stuff with the result *)
    C#
    • HTTPClient
      using System;using System.Net.Http;using System.Net.Http.Headers;using System.Threading.Tasks;class Program{    static async Task Main(string[] args)    {        var client = new HttpClient();        var request = new HttpRequestMessage        {            Method = HttpMethod.Post,            RequestUri = new Uri("http://api.sd-rtn.com/dev/v1/kicking-rule"),            Headers =            {                { "Authorization", "" },                { "Accept", "application/json" },            },            Content = new StringContent("{\"appid\": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\",\"cname\": \"channel1\",\"uid\": 589517928,\"ip\": \"\",\"time\": 60,\"privileges\": [\"join_channel\"]}")            {                Headers =                {                    ContentType = new MediaTypeHeaderValue("application/json")                }            }        };                using (var response = await client.SendAsync(request))        {            response.EnsureSuccessStatusCode();            var body = await response.Content.ReadAsStringAsync();            Console.WriteLine(body);        }    }}
    • RestSharp
      var client = new RestClient("http://api.sd-rtn.com/dev/v1/kicking-rule");var request = new RestRequest(Method.POST);request.AddHeader("Authorization", "");request.AddHeader("Content-Type", "application/json");request.AddHeader("Accept", "application/json");request.AddParameter("application/json", "{\"appid\": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\",\"cname\": \"channel1\",\"uid\": 589517928,\"ip\": \"\",\"time\": 60,\"privileges\": [\"join_channel\"]}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);
    Java
    • AsyncHttp
      AsyncHttpClient client = new DefaultAsyncHttpClient();client.prepare("POST", "http://api.sd-rtn.com/dev/v1/kicking-rule")  .setHeader("Authorization", "")  .setHeader("Content-Type", "application/json")  .setHeader("Accept", "application/json")  .setBody("{\n  \"appid\": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\",\n  \"cname\": \"channel1\",\n  \"uid\": 589517928,\n  \"ip\": \"\",\n  \"time\": 60,\n  \"privileges\": [\"join_channel\"]\n}")  .execute()  .toCompletableFuture()  .thenAccept(System.out::println)  .join();client.close();
    • NetHttp
      HttpRequest request = HttpRequest.newBuilder()    .uri(URI.create("http://api.sd-rtn.com/dev/v1/kicking-rule"))    .header("Authorization", "")    .header("Content-Type", "application/json")    .header("Accept", "application/json")    .method("POST", HttpRequest.BodyPublishers.ofString("{\n  \"appid\": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\",\n  \"cname\": \"channel1\",\n  \"uid\": 589517928,\n  \"ip\": \"\",\n  \"time\": 60,\n  \"privileges\": [\"join_channel\"]\n}"))    .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());
    • OkHttp
      OkHttpClient client = new OkHttpClient();MediaType mediaType = MediaType.parse("application/json");RequestBody body = RequestBody.create(mediaType, "{\n  \"appid\": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\",\n  \"cname\": \"channel1\",\n  \"uid\": 589517928,\n  \"ip\": \"\",\n  \"time\": 60,\n  \"privileges\": [\"join_channel\"]\n}");Request request = new Request.Builder()  .url("http://api.sd-rtn.com/dev/v1/kicking-rule")  .post(body)  .addHeader("Authorization", "")  .addHeader("Content-Type", "application/json")  .addHeader("Accept", "application/json")  .build();Response response = client.newCall(request).execute();
    • Unirest
      HttpResponse<String> response = Unirest.post("http://api.sd-rtn.com/dev/v1/kicking-rule")  .header("Authorization", "")  .header("Content-Type", "application/json")  .header("Accept", "application/json")  .body("{\n  \"appid\": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\",\n  \"cname\": \"channel1\",\n  \"uid\": 589517928,\n  \"ip\": \"\",\n  \"time\": 60,\n  \"privileges\": [\"join_channel\"]\n}")  .asString();
    Http 1.1
    POST /dev/v1/kicking-rule HTTP/1.1Authorization:Content-Type: application/jsonAccept: application/jsonHost: api.sd-rtn.comContent-Length: 160{  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",  "cname": "channel1",  "uid": 589517928,  "ip": "",  "time": 60,  "privileges": [    "join_channel"  ]}
    Clojure
    (require '[clj-http.client :as client])(client/post "http://api.sd-rtn.com/dev/v1/kicking-rule" {:headers {:Authorization ""}                                                           :content-type :json                                                           :form-params {:appid "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2"                                                                         :cname "channel1"                                                                         :uid 589517928                                                                         :ip ""                                                                         :time 60                                                                         :privileges ["join_channel"]}                                                           :accept :json})
    Kotlin
    val client = OkHttpClient()val mediaType = MediaType.parse("application/json")val body = RequestBody.create(mediaType, "{\n  \"appid\": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\",\n  \"cname\": \"channel1\",\n  \"uid\": 589517928,\n  \"ip\": \"\",\n  \"time\": 60,\n  \"privileges\": [\"join_channel\"]\n}")val request = Request.Builder()    .url("http://api.sd-rtn.com/dev/v1/kicking-rule")    .post(body)    .addHeader("Authorization", "")    .addHeader("Content-Type", "application/json")    .addHeader("Accept", "application/json")    .build()val response = client.newCall(request).execute()
    PHP
    • cURL
      <?php$curl = curl_init();curl_setopt_array($curl, [  CURLOPT_URL => "http://api.sd-rtn.com/dev/v1/kicking-rule",  CURLOPT_RETURNTRANSFER => true,  CURLOPT_ENCODING => "",  CURLOPT_MAXREDIRS => 10,  CURLOPT_TIMEOUT => 30,  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,  CURLOPT_CUSTOMREQUEST => "POST",  CURLOPT_POSTFIELDS => json_encode([    'appid' => '4855xxxxxxxxxxxxxxxxxxxxxxxxeae2',    'cname' => 'channel1',    'uid' => 589517928,    'ip' => '',    'time' => 60,    'privileges' => [        'join_channel'    ]  ]),  CURLOPT_HTTPHEADER => [    "Accept: application/json",    "Authorization: ",    "Content-Type: application/json"  ],]);$response = curl_exec($curl);$err = curl_error($curl);curl_close($curl);if ($err) {  echo "cURL Error #:" . $err;} else {  echo $response;}
    • Guzzle
      <?php$client = new GuzzleHttp\Client();$response = $client->request('POST', 'http://api.sd-rtn.com/dev/v1/kicking-rule', [    'json' => [        'appid' => '4855xxxxxxxxxxxxxxxxxxxxxxxxeae2',        'cname' => 'channel1',        'uid' => 589517928,        'ip' => '',        'time' => 60,        'privileges' => [            'join_channel'        ]    ],    'headers' => [        'Accept' => 'application/json',        'Authorization' => '',        'Content-Type' => 'application/json',    ],]);echo $response->getBody();
    PowerShell
    • WebRequest
      $headers=@{}$headers.Add("Authorization", "")$headers.Add("Content-Type", "application/json")$headers.Add("Accept", "application/json")$response = Invoke-WebRequest -Uri 'http://api.sd-rtn.com/dev/v1/kicking-rule' -Method POST -Headers $headers -ContentType 'application/json' -Body '{  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",  "cname": "channel1",  "uid": 589517928,  "ip": "",  "time": 60,  "privileges": [    "join_channel"  ]}'
    • RestMethod
      $headers=@{}$headers.Add("Authorization", "")$headers.Add("Content-Type", "application/json")$headers.Add("Accept", "application/json")$response = Invoke-RestMethod -Uri 'http://api.sd-rtn.com/dev/v1/kicking-rule' -Method POST -Headers $headers -ContentType 'application/json' -Body '{  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",  "cname": "channel1",  "uid": 589517928,  "ip": "",  "time": 60,  "privileges": [    "join_channel"  ]}'
    R
    library(httr)url <- "http://api.sd-rtn.com/dev/v1/kicking-rule"payload <- '{"appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2", "cname": "channel1", "uid": 589517928, "ip": "", "time": 60, "privileges": ["join_channel"]}'encode <- "json"response <- VERB("POST", url,                  body = payload,                  add_headers('Authorization' = ''),                  content_type("application/json"),                  accept("application/json"),                  encode = encode)content(response, "text")
    Ruby
    require 'uri'require 'net/http'url = URI("http://api.sd-rtn.com/dev/v1/kicking-rule")http = Net::HTTP.new(url.host, url.port)request = Net::HTTP::Post.new(url)request["Authorization"] = ''request["Content-Type"] = 'application/json'request["Accept"] = 'application/json'request.body = "{\"appid": \"4855xxxxxxxxxxxxxxxxxxxxxxxxeae2\", \"cname\": \"channel1\", \"uid\": 589517928, \"ip\": \"\", \"time\": 60, \"privileges\": [\"join_channel\"]}"response = http.request(request)puts response.read_body
    Swift
    import Foundationlet headers = [  "Authorization": "",  "Content-Type": "application/json",  "Accept": "application/json"]let parameters = [  "appid": "4855xxxxxxxxxxxxxxxxxxxxxxxxeae2",  "cname": "channel1",  "uid": 589517928,  "ip": "",  "time": 60,  "privileges": ["join_channel"]] as [String : Any]let postData = JSONSerialization.data(withJSONObject: parameters, options: [])let request = NSMutableURLRequest(url: NSURL(string: "http://api.sd-rtn.com/dev/v1/kicking-rule")! as URL,                                        cachePolicy: .useProtocolCachePolicy,                                    timeoutInterval: 10.0)request.httpMethod = "POST"request.allHTTPHeaderFields = headersrequest.httpBody = postData as Datalet session = URLSession.sharedlet 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()

    Response parameters

    For details about possible response status codes, see Response status codes.

    If the status code is not 200, the request fails. See the message field in the response body for the reason for this failure.

    If the status code is 200, the request succeeds, and the response body includes the following parameters:

    ParameterTypeDescription
    statusStringThe status of this request. success means the request succeeds.
    idNumberThe rule ID. Save the rule ID to update or delete this rule later.

    Response example

    The following is a response example for a successful request:


    _4
    {
    _4
    "status": "success",
    _4
    "id": 1953
    _4
    }

    Interactive Live Streaming