> This page is for Postman API Docs.

> 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 component

PATCH https://api.postman.com/components/{componentId}
Content-Type: application/json

Updates a component:
  - `name` — Rename the component. The new name must be unique within the team. Archived components can't be renamed.
  - `status` — Changes the component's lifecycle state:
    - `archive` — Marks the component as read-only. Archived components aren't deleted and can't be edited or published, but their existing versions remain accessible.
    - `active` — Restores the component. Only active components can be edited and published.

**Note:**

You can't update a name and archived state in a single call. To change both properties, make separate calls to update the name and status.


Reference: https://learning.postman.com/api-docs/api-reference/components/update-component

## 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

- `componentId` (string, required) — The component's ID.

### Body (application/json)

This endpoint expects an updateComponent.

- `name` (string, optional) — The component's name. The new name must be unique within the team.
- `status` (enum, optional) — The component's lifecycle state: - `active` — The component is active and can be edited and published. - `archive` — The component is archived and read-only. Archived components can't be edited or published, but their existing versions remain accessible.
  - Allowed values: `active`, `archive`

## Response

### 200

Component Updated

- `id` (string, optional) — The component's ID.
- `name` (string, optional) — The component's name.
- `status` (enum, optional) — The component's lifecycle state: - `active` — The component is active and can be edited and published. - `archive` — The component is archived and read-only. Archived components can't be edited or published, but their existing versions remain accessible.
  - Allowed values: `active`, `archive`

## Errors

### 400 Bad Request Error

Bad Request

- `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.

### 401 Unauthorized Error

Unauthorized

- `UpdateComponentRequestUnauthorizedError`
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message): commonErrorNameMessage

### 403 Forbidden Error

Forbidden

- `UpdateComponentRequestForbiddenError`
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message): commonErrorNameMessage

### 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

- `UpdateComponentRequestInternalServerError`
  - Error (Type, Title, Detail): commonErrorTypeTitleDetail
  - Error (Type, Title, Detail, Status): commonErrorTypeTitleDetailStatus
  - Error (Name, Message): commonErrorNameMessage

## Types

### CommonErrorTypeTitleDetailStatusType

The type of error.

- string
- string

### 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.

### commonErrorNameMessage

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

### commonErrorTypeTitleDetail

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

### CommonErrorNameMessageError

Information about the error.

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

### CommonErrorTypeTitleDetailDetail

Information about the error.

- string
- map from string to any

## Examples

### Component Updated

**Response**

```json
{
  "id": "01KT964C30J3DPJQKEACZH39N8",
  "name": "updated-component-name",
  "status": "active"
}
```

**SDK Code**

```python Component Updated
import requests

url = "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8"

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

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

print(response.json())
```

```javascript Component Updated
const url = 'https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8';
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 Component Updated
package main

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

func main() {

	url := "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8"

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

url = URI("https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")

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 Component Updated
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

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

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

$client = new \GuzzleHttp\Client();

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

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

```csharp Component Updated
using RestSharp;

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

```swift Component Updated
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")! 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()
```

### Rename Component

**Request**

```json
{
  "name": "update-component-name"
}
```

**Response**

```json
{
  "id": "01KT964C30J3DPJQKEACZH39N8",
  "name": "updated-component-name",
  "status": "active"
}
```

**SDK Code**

```python Rename Component
import requests

url = "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8"

payload = { "name": "update-component-name" }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Rename Component
const url = 'https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"update-component-name"}'
};

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

```go Rename Component
package main

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

func main() {

	url := "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8"

	payload := strings.NewReader("{\n  \"name\": \"update-component-name\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Rename Component
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")

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/json'
request.body = "{\n  \"name\": \"update-component-name\"\n}"

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

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

HttpResponse<String> response = Unirest.patch("https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"update-component-name\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8', [
  'body' => '{
  "name": "update-component-name"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Rename Component
using RestSharp;

var client = new RestClient("https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"update-component-name\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Rename Component
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["name": "update-component-name"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")! 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()
```

### Update Component Status

**Request**

```json
{
  "name": "update-component-name",
  "status": "archive"
}
```

**Response**

```json
{
  "id": "01KT964C30J3DPJQKEACZH39N8",
  "name": "updated-component-name",
  "status": "active"
}
```

**SDK Code**

```python Update Component Status
import requests

url = "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8"

payload = {
    "name": "update-component-name",
    "status": "archive"
}
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Update Component Status
const url = 'https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8';
const options = {
  method: 'PATCH',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"name":"update-component-name","status":"archive"}'
};

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

```go Update Component Status
package main

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

func main() {

	url := "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8"

	payload := strings.NewReader("{\n  \"name\": \"update-component-name\",\n  \"status\": \"archive\"\n}")

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

	req.Header.Add("x-api-key", "<apiKey>")
	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 Update Component Status
require 'uri'
require 'net/http'

url = URI("https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")

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/json'
request.body = "{\n  \"name\": \"update-component-name\",\n  \"status\": \"archive\"\n}"

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

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

HttpResponse<String> response = Unirest.patch("https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"update-component-name\",\n  \"status\": \"archive\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8', [
  'body' => '{
  "name": "update-component-name",
  "status": "archive"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

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

```csharp Update Component Status
using RestSharp;

var client = new RestClient("https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8");
var request = new RestRequest(Method.PATCH);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"name\": \"update-component-name\",\n  \"status\": \"archive\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Update Component Status
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "name": "update-component-name",
  "status": "archive"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.postman.com/components/01KT964C30J3DPJQKEACZH39N8")! 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()
```