> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://learning.postman.com/llms.txt.

# Update a ruleset

PATCH https://api.postman.com/rulesets/{rulesetId}
Content-Type: application/merge-patch+json

Updates a ruleset. Only the fields present in the request body are updated. If `content` is provided, it replaces the entire contents of the ruleset.

**Note:**

Postman-managed system rulesets (`type: system`) can't be updated and return an HTTP `403 Forbidden` response.


Reference: https://learning.postman.com/api-docs/api-reference/api-governance/update-ruleset

## Authentication

- `x-api-key` header (required) — API Key authentication via header

## Servers

- `https://api.postman.com` (https://api.postman.com, default)
- `https://api.eu.postman.com` (https://api.eu.postman.com)

## Request

### Path parameters

- `rulesetId` (string, required) — The ruleset's ID.

### Body (application/merge-patch+json)

This endpoint expects a rulesetUpdate.

- `name` (string, optional) — The ruleset's name.
- `description` (string, optional) — The ruleset's description.
- `content` (string, optional) — The ruleset's content, up to a maximum of 500 KB (UTF-8).

## Response

### 200

Ruleset Updated

- `id` (string, required) — The resource's ID.

## Errors

### 400 Bad Request Error

Bad Request

- `UpdateRulesetRequestBadRequestError`

### 401 Unauthorized Error

Unauthorized

- `UpdateRulesetRequestUnauthorizedError`

### 403 Forbidden Error

Forbidden

- `UpdateRulesetRequestForbiddenError`

### 404 Not Found Error

Not Found

- `type` (CommonErrorTypeTitleDetailStatusType, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — Information about the error.
- `status` (integer, optional) — The error's HTTP status code.

### 409 Conflict Error

Conflict

- `type` (CommonErrorTypeTitleDetailStatusType, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — Information about the error.
- `status` (integer, optional) — The error's HTTP status code.

### 500 Internal Server Error

Internal Server Error

- `UpdateRulesetRequestInternalServerError`

## Types

### commonErrorTypeTitleDetail

- `type` (string, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (CommonErrorTypeTitleDetailDetail, optional) — Information about the error.

### commonErrorTypeTitleDetailStatus

- `type` (CommonErrorTypeTitleDetailStatusType, optional) — The type of error.
- `title` (string, optional) — A short summary of the problem.
- `detail` (string, optional) — Information about the error.
- `status` (integer, optional) — The error's HTTP status code.

### commonErrorNameMessageDetails

- `error` (CommonErrorNameMessageDetailsError, optional) — Information about the error.

### commonErrorNameMessage

- `error` (CommonErrorNameMessageError, optional) — Information about the error.

### CommonErrorTypeTitleDetailStatusType

The type of error.

### CommonErrorTypeTitleDetailDetail

Information about the error.

### CommonErrorNameMessageDetailsError

Information about the error.

- `name` (string, optional) — The error name.
- `message` (string, optional) — The error message.
- `details` (CommonErrorNameMessageDetailsErrorDetails, optional) — Information about the error.

### CommonErrorNameMessageError

Information about the error.

- `name` (string, optional) — The error name.
- `message` (string, optional) — The error message.

### CommonErrorNameMessageDetailsErrorDetails

Information about the error.

## Examples

### Ruleset Updated

**Request**

```json
undefined
```

**Response**

```json
{
  "id": "01JABCDEF0123456789ABCDEFG"
}
```

**SDK Code**

```python Ruleset Updated
import requests

url = "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG"

headers = {"x-api-key": "<apiKey>"}

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

print(response.json())
```

```javascript Ruleset Updated
const url = 'https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG';
const options = {method: 'PATCH', headers: {'x-api-key': '<apiKey>'}};

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

```go Ruleset Updated
package main

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

func main() {

	url := "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG"

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

	req.Header.Add("x-api-key", "<apiKey>")

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

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

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

}
```

```ruby Ruleset Updated
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")

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

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'

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

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

HttpResponse<String> response = Unirest.patch("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")
  .header("x-api-key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG', [
  'headers' => [
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Ruleset Updated
using RestSharp;

var client = new RestClient("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift Ruleset Updated
import Foundation

let headers = ["x-api-key": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```

### Update Metadata

**Request**

```json
{
  "name": "API_Style_Guide_v2",
  "description": "Updated company-wide rules for API specifications."
}
```

**Response**

```json
{
  "id": "01JABCDEF0123456789ABCDEFG"
}
```

**SDK Code**

```python Update Metadata
import requests

url = "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG"

payload = "{\n  \"name\": \"API_Style_Guide_v2\",\n  \"description\": \"Updated company-wide rules for API specifications.\"\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/merge-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Update Metadata
const url = 'https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/merge-patch+json'},
  body: '{\n  "name": "API_Style_Guide_v2",\n  "description": "Updated company-wide rules for API specifications."\n}'
};

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

```go Update Metadata
package main

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

func main() {

	url := "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG"

	payload := strings.NewReader("{\n  \"name\": \"API_Style_Guide_v2\",\n  \"description\": \"Updated company-wide rules for API specifications.\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/merge-patch+json")

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

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

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

}
```

```ruby Update Metadata
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")

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

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/merge-patch+json'
request.body = "{\n  \"name\": \"API_Style_Guide_v2\",\n  \"description\": \"Updated company-wide rules for API specifications.\"\n}"

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

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

HttpResponse<String> response = Unirest.patch("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/merge-patch+json")
  .body("{\n  \"name\": \"API_Style_Guide_v2\",\n  \"description\": \"Updated company-wide rules for API specifications.\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG', [
  'body' => '{
  "name": "API_Style_Guide_v2",
  "description": "Updated company-wide rules for API specifications."
}',
  'headers' => [
    'Content-Type' => 'application/merge-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Update Metadata
using RestSharp;

var client = new RestClient("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/merge-patch+json");
request.AddParameter("application/merge-patch+json", "{\n  \"name\": \"API_Style_Guide_v2\",\n  \"description\": \"Updated company-wide rules for API specifications.\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Metadata
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/merge-patch+json"
]

let postData = NSData(data: "{
  "name": "API_Style_Guide_v2",
  "description": "Updated company-wide rules for API specifications."
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```

### Replace Content

**Request**

```json
{
  "content": "rules:\n  operation-operationId: true\n  operation-description: true"
}
```

**Response**

```json
{
  "id": "01JABCDEF0123456789ABCDEFG"
}
```

**SDK Code**

```python Replace Content
import requests

url = "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG"

payload = "{\n  \"content\": \"rules:\\n  operation-operationId: true\\n  operation-description: true\"\n}"
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/merge-patch+json"
}

response = requests.patch(url, data=payload, headers=headers)

print(response.json())
```

```javascript Replace Content
const url = 'https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/merge-patch+json'},
  body: '{\n  "content": "rules:\n  operation-operationId: true\n  operation-description: true"\n}'
};

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

```go Replace Content
package main

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

func main() {

	url := "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG"

	payload := strings.NewReader("{\n  \"content\": \"rules:\\n  operation-operationId: true\\n  operation-description: true\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/merge-patch+json")

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

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

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

}
```

```ruby Replace Content
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")

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

request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/merge-patch+json'
request.body = "{\n  \"content\": \"rules:\\n  operation-operationId: true\\n  operation-description: true\"\n}"

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

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

HttpResponse<String> response = Unirest.patch("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/merge-patch+json")
  .body("{\n  \"content\": \"rules:\\n  operation-operationId: true\\n  operation-description: true\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG', [
  'body' => '{
  "content": "rules:\\n  operation-operationId: true\\n  operation-description: true"
}',
  'headers' => [
    'Content-Type' => 'application/merge-patch+json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Replace Content
using RestSharp;

var client = new RestClient("https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/merge-patch+json");
request.AddParameter("application/merge-patch+json", "{\n  \"content\": \"rules:\\n  operation-operationId: true\\n  operation-description: true\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Replace Content
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/merge-patch+json"
]

let postData = NSData(data: "{
  "content": "rules:\n  operation-operationId: true\n  operation-description: true"
}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/rulesets/01JABCDEF0123456789ABCDEFG")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
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()
```