> ## Documentation Index
> Fetch the complete documentation index at: https://confidence-auth-testing.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Archive Flags and Segments

> Learn how to archive flags and segments when they're no longer needed.

export const HowToSchema = ({name, description, steps = []}) => {
  const schema = {
    "@context": "https://schema.org",
    "@type": "HowTo",
    name,
    description
  };
  if (steps.length > 0) {
    schema.step = steps.map((s, i) => ({
      "@type": "HowToStep",
      position: i + 1,
      name: typeof s === "string" ? s : s.name,
      text: typeof s === "string" ? s : s.text || s.name
    }));
  }
  return <script type="application/ld+json" dangerouslySetInnerHTML={{
    __html: JSON.stringify(schema)
  }} />;
};

<HowToSchema
  name="Archive Flags and Segments"
  description="Learn how to archive flags and segments when they're no longer needed."
  steps={[
{ name: "Archive a Flag", text: "Archive a flag that's no longer needed:" },
{
  name: "Archive a Segment",
  text: "Archive a segment that's no longer needed:",
},
{
  name: "Verify Archive Status",
  text: "Check if a flag is archived: The response includes an archived field set to true.",
},
{
  name: "Archive Multiple Resources",
  text: "Archive multiple flags or segments in sequence:",
},
{
  name: "Find Archival Candidates",
  text: "List all flags to find archival candidates: List all segments to find archival candidates:",
},
]}
/>

Archive flags and segments when they're no longer needed instead of deleting them.

<Tip>
  See [Archiving Flags](/docs/flags/create-flags#archiving-flags) in the reference for details on what happens when you archive, when to archive, and best practices.
</Tip>

## Archive a Flag

Archive a flag that's no longer needed:

```bash theme={null}
curl -X POST "https://flags.confidence.dev/v1/flags/example-flag:archive" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

## Archive a Segment

Archive a segment that's no longer needed:

```bash theme={null}
curl -X POST "https://flags.confidence.dev/v1/segments/my-segment:archive" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

## Verify Archive Status

Check if a flag is archived:

```bash theme={null}
curl -X GET "https://flags.confidence.dev/v1/flags/example-flag" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

The response includes an `archived` field set to `true`.

## Archive Multiple Resources

Archive multiple flags or segments in sequence:

```bash theme={null}
#!/bin/bash

# Archive multiple flags
for flag in "old-feature" "test-flag" "deprecated-config"; do
  curl -X POST "https://flags.confidence.dev/v1/flags/$flag:archive" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
  echo "Archived flag: $flag"
done

# Archive multiple segments
for segment in "experiment-1" "experiment-2" "test-segment"; do
  curl -X POST "https://flags.confidence.dev/v1/segments/$segment:archive" \
    -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
  echo "Archived segment: $segment"
done
```

## Find Archival Candidates

List all flags to find archival candidates:

```bash theme={null}
curl -X GET "https://flags.confidence.dev/v1/flags" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

List all segments to find archival candidates:

```bash theme={null}
curl -X GET "https://flags.confidence.dev/v1/segments" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
```

## Next Steps

After archiving resources:

1. Remove feature flag code from your application
2. Update documentation to reflect production behavior
3. Review analytics from the archived experiment
4. Plan next experiments based on learnings
