> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.awork.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.awork.com/_mcp/server.

# Archives or unarchives an agent.

POST https://api.awork.com/api/v1/agents/{agentId}/setarchived
Content-Type: application/json

Archives or unarchives the specified custom agent and returns its updated configuration.
Set IsArchived to true to archive the agent, or false to unarchive it.
The user must have manage access to the agent.

Reference: https://developers.awork.com/apiv1/custom-agents/post-agents-set-archived-by-agent-id

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `agentId` (string, required) — The agent id.

### Body (application/json)

This endpoint expects a SetAgentArchivedRequestModel.

- `isArchived` (boolean, required) — Whether the agent should be archived.

## Response

### 200

OK

- `id` (string, optional) — The id of the entity.
- `createdOn` (string, optional) — The date this entity was created.
- `createdBy` (string, optional) — The id of the user who created this entity.
- `updatedOn` (string, optional) — The date this entity was last modified.
- `updatedBy` (string, optional) — The id of the user who last modified this entity.
- `type` (string, optional, nullable) — The public agent type.
- `connectors` (list of AgentConnectorLinkResponseModel, optional, nullable) — The linked connectors.
- `name` (string, optional, nullable) — The name shown to users.
- `description` (string, optional, nullable) — A short explanation of what the agent does.
- `currentSystemPromptVersionId` (string, optional, nullable) — The current system prompt version.
- `modelProvider` (string, optional, nullable) — The configured model provider when no preset is selected.
- `modelName` (string, optional, nullable) — The configured model name when no preset is selected.
- `presetKey` (string, optional, nullable) — The configured workspace model preset key.
- `reasoningLevel` (string, optional, nullable) — The configured reasoning level.
- `systemPrompt` (string, optional, nullable) — The current system prompt.
- `webSearchEnabled` (boolean, optional) — Whether web search is enabled.
- `aworkAccessEnabled` (boolean, optional) — Whether awork access is enabled.
- `googleGenAiAccessEnabled` (boolean, optional) — Whether Google image generation is enabled.
- `openAiImageGenerationAccessEnabled` (boolean, optional) — Whether OpenAI image generation is enabled.
- `skillIds` (list of string, optional, nullable) — The skills linked to the agent.
- `hasImage` (boolean, optional) — Whether the agent has a profile image.
- `isArchived` (boolean, optional) — Whether the agent is archived.
- `workspaceAccessLevel` (enum, optional, nullable) — The workspace-wide access level.
  - Allowed values: `read`, `manage`
- `accessLevel` (enum, optional) — The requesting user's access level.
  - Allowed values: `read`, `manage`

## Errors

### 400 Bad Request Error

Bad Request

- `code` (string, required) — The error code.
- `description` (string, required) — The description of the error.
- `link` (string, required) — The link to the API documentation page.
- `details` (list of string, optional, nullable) — A list of details describing the error.
- `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property.
- `traceId` (string, optional, nullable) — The request trace id for tracking the request.

### 401 Unauthorized Error

Unauthorized

- `code` (string, required) — The error code.
- `description` (string, required) — The description of the error.
- `link` (string, required) — The link to the API documentation page.
- `details` (list of string, optional, nullable) — A list of details describing the error.
- `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property.
- `traceId` (string, optional, nullable) — The request trace id for tracking the request.

### 404 Not Found Error

Not Found

- `code` (string, required) — The error code.
- `description` (string, required) — The description of the error.
- `link` (string, required) — The link to the API documentation page.
- `details` (list of string, optional, nullable) — A list of details describing the error.
- `validationErrors` (list of ValidationErrorResponse, optional, nullable) — If a validation error occurred, this contains the validation errors for each property.
- `traceId` (string, optional, nullable) — The request trace id for tracking the request.

## Types

### AgentConnectorLinkResponseModel

A connector linked to a custom agent, with settings shared by everyone who uses the agent.

- `id` (string, optional) — The linked connector identifier.
- `name` (string, optional, nullable) — The connector name.
- `status` (string, optional, nullable) — Always pending in this shared response. It does not indicate whether an account is connected. Read the agent's configuration endpoint for the current user's connection status.
- `connectionMode` (string, optional, nullable) — How the agent chooses an account: actingUser lets each user supply their own; specificConnection uses the editor-provided account for everyone.
- `connectionId` (string, optional, nullable) — The editor-provided account id in specificConnection mode; otherwise null.

### ValidationErrorResponse

The validation error response.

- `property` (string, optional, nullable) — The name of the property that failed validation.
- `message` (string, optional, nullable) — The reason why this property failed validation.

## Examples

**Request**

```json
{
  "isArchived": true
}
```

**Response**

```json
{
  "id": "23e68187-91d6-4f7e-8d31-e3f2c60d7427",
  "createdOn": "2022-03-11T15:33:47.100Z",
  "createdBy": "9ad63972-4396-4b0b-9e7d-40b852cdebf8",
  "updatedOn": "2022-03-11T21:15:00.100Z",
  "updatedBy": "3d844c62-7410-4df9-a5b2-78805c0ee260",
  "type": "custom-agent",
  "connectors": [
    {
      "id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
      "name": "Google Drive",
      "status": "pending",
      "connectionMode": "specificConnection",
      "connectionId": "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
    }
  ],
  "name": "Client Status Reporter",
  "description": "Prepares client-ready project status reports.",
  "currentSystemPromptVersionId": "fd077515-d4a8-4f79-9fbf-19271bd0123d",
  "modelProvider": "openai",
  "modelName": "gpt-5.6-terra",
  "presetKey": "balanced",
  "reasoningLevel": "medium",
  "systemPrompt": "Prepare concise client-ready project updates from awork data.",
  "webSearchEnabled": true,
  "aworkAccessEnabled": true,
  "googleGenAiAccessEnabled": false,
  "openAiImageGenerationAccessEnabled": false,
  "skillIds": [
    "string"
  ],
  "hasImage": true,
  "isArchived": false,
  "workspaceAccessLevel": null,
  "accessLevel": "manage"
}
```

**SDK Code**

```python
import requests

url = "https://api.awork.com/api/v1/agents/agentId/setarchived"

payload = { "isArchived": True }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.awork.com/api/v1/agents/agentId/setarchived';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"isArchived":true}'
};

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://api.awork.com/api/v1/agents/agentId/setarchived"

	payload := strings.NewReader("{\n  \"isArchived\": true\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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://api.awork.com/api/v1/agents/agentId/setarchived")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"isArchived\": true\n}"

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.post("https://api.awork.com/api/v1/agents/agentId/setarchived")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"isArchived\": true\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.awork.com/api/v1/agents/agentId/setarchived', [
  'body' => '{
  "isArchived": true
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.awork.com/api/v1/agents/agentId/setarchived");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"isArchived\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["isArchived": true] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.awork.com/api/v1/agents/agentId/setarchived")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
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()
```