# Update custom rate limit

PUT //localhost:8080/api/v1/policies/custom-rate-limit
Content-Type: application/json

Update custom rate limit (Pro+). Free returns 403 (10-policies.md endpoint 13).

Reference: https://api.alephant.io/api-reference/saa-s-api/policies/update-custom-rate-limit

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: saas-openapi
  version: 1.0.0
paths:
  /api/v1/policies/custom-rate-limit:
    put:
      operationId: update-custom-rate-limit
      summary: Update custom rate limit
      description: >-
        Update custom rate limit (Pro+). Free returns 403 (10-policies.md
        endpoint 13).
      tags:
        - subpackage_policies
      responses:
        '200':
          description: 'data: CustomRateLimitResponse'
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Policies_updateCustomRateLimit_Response_200
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '403':
          description: TIER_FEATURE_DISABLED
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '422':
          description: Unprocessable Entity
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody
      requestBody:
        description: Enabled and config
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.CustomRateLimitRequest
servers:
  - url: //localhost:8080
components:
  schemas:
    github_com_alephant_backend-saas-service_internal_api_dto.CustomRateLimitConfig:
      type: object
      properties:
        burstAllowance:
          type: integer
        maxConcurrent:
          type: integer
          description: >-
            No omitempty: 0 must round-trip so PUT can clear limits (merge
            overwrites prev[key]).
        rph:
          type: integer
        rpm:
          type: integer
        scope:
          type: string
        throttleAction:
          type: string
        tokenLimitPerMinute:
          type: integer
      title: >-
        github_com_alephant_backend-saas-service_internal_api_dto.CustomRateLimitConfig
    github_com_alephant_backend-saas-service_internal_api_dto.CustomRateLimitRequest:
      type: object
      properties:
        config:
          $ref: >-
            #/components/schemas/github_com_alephant_backend-saas-service_internal_api_dto.CustomRateLimitConfig
        enabled:
          type: boolean
      title: >-
        github_com_alephant_backend-saas-service_internal_api_dto.CustomRateLimitRequest
    Policies_updateCustomRateLimit_Response_200:
      type: object
      properties: {}
      title: Policies_updateCustomRateLimit_Response_200
    github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody:
      type: object
      properties:
        code:
          type: string
        message:
          type: string
      title: github_com_alephant_backend-saas-service_internal_api_dto.APIErrorBody

```

## SDK Code Examples

```python
import requests

url = "https://localhost:8080/api/v1/policies/custom-rate-limit"

payload = {}
headers = {"Content-Type": "application/json"}

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

print(response.json())
```

```javascript
const url = 'https://localhost:8080/api/v1/policies/custom-rate-limit';
const options = {method: 'PUT', headers: {'Content-Type': 'application/json'}, body: '{}'};

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

```go
package main

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

func main() {

	url := "https://localhost:8080/api/v1/policies/custom-rate-limit"

	payload := strings.NewReader("{}")

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

	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
require 'uri'
require 'net/http'

url = URI("https://localhost:8080/api/v1/policies/custom-rate-limit")

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

request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{}"

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

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

HttpResponse<String> response = Unirest.put("https://localhost:8080/api/v1/policies/custom-rate-limit")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://localhost:8080/api/v1/policies/custom-rate-limit', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://localhost:8080/api/v1/policies/custom-rate-limit");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://localhost:8080/api/v1/policies/custom-rate-limit")! 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()
```