> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/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.

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
