---
title: Archive Segment
description: "Reference for the PUT /console/v1/segments/{id}/archive API endpoint."
product: general
token_estimate: 1821
---
# Archive Segment

> For AI agents: a documentation index is available at [/llms.txt](/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

## Archive Segment

**PUT** `/console/v1/segments/{id}/archive`

Full URL: `https://statsigapi.net/console/v1/segments/{id}/archive`

Archive Segment

## Authorizations

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| STATSIG-API-KEY | string | Yes | — | apiKey (header) |

## Path parameters

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| id (path) | string | Yes | — | id |

## Response (application/json)

**200** — Archive Segment Success

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| message | string | Yes | — | A simple string explaining the result of the operation. |
| data | object | Yes | — | — |
| data.isEnabled | boolean | Yes | — | Is the segment enabled. |
| data.type | string | Yes | — | Allowed values: id_list, rule_based, analysis_list, user_store_id_list |
| data.count | number | No | — | For id_list segments: the length of the ID list Constraints: format: double |
| data.rules | object[] | No | — | Rule Object |
| data.rules.name | string | Yes | — | The name of this rule. |
| data.rules.passPercentage | number | Yes | — | Of the users that meet the conditions of this rule, what percent should return true. Constraints: min: 0, max: 100 |
| data.rules.conditions | object[] | Yes | — | An array of Condition objects. |
| data.rules.conditions.targetValue | oneOf | No | — | Constraints: nullable, string[], number[], string, number |
| data.rules.conditions.operator | string | No | — | — |
| data.rules.conditions.field | string | No | — | Constraints: nullable |
| data.rules.conditions.customID | string | No | — | Constraints: nullable |
| data.rules.conditions.type | string | Yes | — | Allowed values: app_version, browser_name, browser_version, country, custom_field, email, environment_tier, fails_gate, fails_segment, ip_address, locale, os_name, os_version, passes_gate, passes_segment, public, time, unit_id, user_id, user_agent, url, javascript, device_model, target_app, experiment_group |
| data.rules.environments | string[] | No | — | The environments this rule is enabled for. Constraints: nullable |
| data.rules.id | string | No | — | The Statsig ID of this rule. |
| data.rules.baseID | string | No | — | The base ID of this rule, i.e. without any added metadata. Will remain the exact same throughout |
| data.rules.returnValue | object | No | — | The return value of the rule. |
| data.tags | string[] | No | — | Optional tags for categorization. |
| data.id | string | Yes | — | ID |
| data.name | string | No | — | Optional name for the configuration. |
| data.idType | string | Yes | — | Type of ID |
| data.description | string | Yes | — | Detailed description of the configuration’s purpose. |
| data.lastModifierID | string | Yes | — | ID of the last modifier. Constraints: nullable |
| data.lastModifiedTime | number | Yes | — | Time of the last modification. Constraints: format: double, nullable |
| data.lastModifierEmail | string | Yes | — | Email of the last modifier. Constraints: nullable |
| data.lastModifierName | string | Yes | — | Name of the last modifier. Constraints: nullable |
| data.creatorID | string | Yes | — | ID of the user who created the entity. Constraints: nullable |
| data.createdTime | number | Yes | — | Timestamp when the entity was created. Constraints: format: double |
| data.creatorName | string | Yes | — | Name of the creator. Constraints: nullable |
| data.creatorEmail | string | Yes | — | Email of the creator. Constraints: nullable |
| data.targetApps | string[] | No | — | List of target applications associated with this configuration. |
| data.holdoutIDs | string[] | No | — | Holdouts applied to this configuration. |
| data.team | string | No | — | Optional name for the responsible team. Constraints: nullable |
| data.teamID | string | No | — | Optional ID of the responsible team. Constraints: nullable |
| data.version | number | No | — | Version number Constraints: format: double |

```json
{
  "message": "Segment archived successfully."
}
```

**401** — This endpoint only accepts an active CONSOLE key, but an invalid key was sent. Key: console-xxxXXXxxxXXXxxx

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| status | integer | Yes | — | Allowed values: 401 |
| message | string | Yes | — | — |

```json
{
  "status": 401,
  "message": "This endpoint only accepts an active CONSOLE key, but an invalid key was sent. Key: console-xxxXXXxxxXXXxxx"
}
```

**404** — Segment not found.

| Name | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| status | integer | Yes | — | Allowed values: 404 |
| message | string | Yes | — | — |

```json
{
  "status": 404,
  "message": "Not Found. The requested resource could not be found."
}
```

## Code samples

### cURL

```bash
curl -X PUT "https://statsigapi.net/console/v1/segments/{id}/archive" \
  -H "Content-Type: application/json" \
  -H "STATSIG-API-KEY: YOUR_API_KEY"
```

### Python

```python
import requests

response = requests.put(
    "https://statsigapi.net/console/v1/segments/{id}/archive",
    headers={
        "Content-Type": "application/json",
        "STATSIG-API-KEY": "YOUR_API_KEY"
    }
)
data = response.json()
```

### JavaScript

```javascript
const response = await fetch("https://statsigapi.net/console/v1/segments/{id}/archive", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "STATSIG-API-KEY": "YOUR_API_KEY"
  }
});
const data = await response.json();
```

### PHP

```php
<?php
$ch = curl_init("https://statsigapi.net/console/v1/segments/{id}/archive");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json",
    "STATSIG-API-KEY: YOUR_API_KEY"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
```

### Go

```go
package main

import (
  "bytes"
  "net/http"
)

func main() {
req, _ := http.NewRequest("PUT", "https://statsigapi.net/console/v1/segments/{id}/archive", nil)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("STATSIG-API-KEY", "YOUR_API_KEY")
  client := &http.Client{}
  resp, _ := client.Do(req)
  defer resp.Body.Close()
}
```

### Java

```java
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
      .uri(URI.create("https://statsigapi.net/console/v1/segments/{id}/archive"))
      .method("PUT", HttpRequest.BodyPublishers.noBody())
.header("Content-Type", "application/json")
      .header("STATSIG-API-KEY", "YOUR_API_KEY")
      .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
```

### Ruby

```ruby
require "net/http"
require "json"

uri = URI("https://statsigapi.net/console/v1/segments/{id}/archive")
request = Net::HTTP::Put.new(uri)
request["Content-Type"] = "application/json"
request["STATSIG-API-KEY"] = "YOUR_API_KEY"
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end
```

