---
title: "Retention rules: Refine scope with package search syntax via web app and Terraform provider"
description: "You can now use Cloudsmith’s package search syntax to refine the scope of your repository's retention rules when configuring them via the Cloudsmith web application and via the Cloudsmith Terraform provider. This functionality builds on the existing support to scope retention rules by package search syntax via the API, and makes it easier to target exactly which packages to keep or remove."
canonical_url: "https://cloudsmith.com/changelog/refine-scope-with-package-search-syntax-via-web-app-and-terraform-provider"
last_updated: "2025-08-21T10:45:00.000Z"
---
# Retention rules: Refine scope with package search syntax via web app and Terraform provider

You can now use Cloudsmith’s package search syntax to refine the scope of your repository's retention rules when configuring them via the Cloudsmith web application and via the Cloudsmith Terraform provider. This functionality builds on the existing support to [scope retention rules by package search syntax via the API](https://cloudsmith.com/changelog/keep-only-what-matters-using-search-based-retention-rules), and makes it easier to target exactly which packages to keep or remove.

```json
{
  "_key": "25cac36222ec",
  "_type": "image",
  "alt": "New scope search field",
  "asset": {
    "_createdAt": "2025-09-08T13:16:14Z",
    "_id": "image-a87adc0d7aac4135ca7fb816aa3328db62dca654-802x842-png",
    "_rev": "EBGKLO4kbTusnSqhsRESvi",
    "_type": "sanity.imageAsset",
    "_updatedAt": "2025-09-08T13:16:14Z",
    "assetId": "a87adc0d7aac4135ca7fb816aa3328db62dca654",
    "extension": "png",
    "metadata": {
      "_type": "sanity.imageMetadata",
      "blurHash": "e5SZ5{4@V@?bM|~UR*t6xZa{$dM{NHa$a#%MWAxtxajr?F%1IqIpRj",
      "dimensions": {
        "_type": "sanity.imageDimensions",
        "aspectRatio": 0.9524940617577197,
        "height": 842,
        "width": 802
      },
      "hasAlpha": true,
      "isOpaque": true,
      "lqip": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAYAAABG1c6oAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB8ElEQVR4nI2U2W6jQBBF+f9fy/toHiLNRI7Hu1l6qareblQN9jgJmCAd0V2Co1oamt46tIOFcR4hRMSUEONI0PWdjFIK1q5mmIQqtp5giWDciO7NhGep4jVp41TiPRwxPHG9z0EsSCmvZ0gs40v1LrCe4RQSkASwEmLlR8LeCs4949QRjh3hcPWVcy/oXELvM3qf0LkIzwl5pY3N1UTsWsH2MvJ+5sq+jTgNpXIcMo59QO90aAXqnEOvxklG5xPaezYjAxUYntA1ZXjJVZjyPDkXNBwyBi3JJzgp4AhwLOCEz2hsQhJmCSrUvlxtxMUmWC6giAp/gUKpGfqQIaksC51kXEys0v8ZfpFFwIcCx2kSPsnQScLFBLQ2wi8JVSYZlvSZXGPLJYsOIcJQAod5IT9kSOsZZgyU4DjXTL7LykPZ+sxKhk6HYsJYtot12v0Duq8xl+pp0AR06otCQxnbC+PP3uPvYeRtQmO3+NuRsLsGDH7MeFFoOWHfMjYnj/cb5xGN3eNnwqEL9YA/FXLQoQiultE5gfGhNl+nr2e0rm/7OuGVgy1RvxTBeXC4DA7GCzhmhFS+sSSSTyXXHhI2J4Nj5zD4UKe99vKicNdGvLwSfm2o/qKenbNVYSpo/rUJL6+M31vtXal/k7lyf0LMBR9S5GxTlOijeAAAAABJRU5ErkJggg==",
      "palette": {
        "_type": "sanity.imagePalette",
        "darkMuted": {
          "_type": "sanity.imagePaletteSwatch",
          "background": "#5c687c",
          "foreground": "#fff",
          "population": 0.01,
          "title": "#fff"
        },
        "darkVibrant": {
          "_type": "sanity.imagePaletteSwatch",
          "background": "#082e7c",
          "foreground": "#fff",
          "population": 0,
          "title": "#fff"
        },
        "dominant": {
          "_type": "sanity.imagePaletteSwatch",
          "background": "#b0c0d7",
          "foreground": "#000",
          "population": 0.24,
          "title": "#fff"
        },
        "lightMuted": {
          "_type": "sanity.imagePaletteSwatch",
          "background": "#b0c0d7",
          "foreground": "#000",
          "population": 0.24,
          "title": "#fff"
        },
        "lightVibrant": {
          "_type": "sanity.imagePaletteSwatch",
          "background": "#70c0f8",
          "foreground": "#000",
          "population": 0,
          "title": "#fff"
        },
        "muted": {
          "_type": "sanity.imagePaletteSwatch",
          "background": "#6f8399",
          "foreground": "#fff",
          "population": 0.05,
          "title": "#fff"
        },
        "vibrant": {
          "_type": "sanity.imagePaletteSwatch",
          "background": "#2c6df1",
          "foreground": "#fff",
          "population": 0.04,
          "title": "#fff"
        }
      }
    },
    "mimeType": "image/png",
    "originalFilename": "image.png",
    "path": "images/rafvlnhi/production/a87adc0d7aac4135ca7fb816aa3328db62dca654-802x842.png",
    "sha1hash": "a87adc0d7aac4135ca7fb816aa3328db62dca654",
    "size": 85726,
    "uploadId": "GocvXcgM2eCGaqTeV9ePhF5PTeipJ8Zl",
    "url": "https://cdn.sanity.io/images/rafvlnhi/production/a87adc0d7aac4135ca7fb816aa3328db62dca654-802x842.png"
  },
  "caption": "New scope search field",
  "link": {
    "_type": "link",
    "href": null,
    "openInNewTab": false
  },
  "markDefs": null
}
```

To start using it via the web application, browse to your repository Settings, and click Retention Rules. Use the `Limit with package filters` to set the scope for your rule.

### Useful Resources

- Learn more about [Package search syntax](https://docs.cloudsmith.com/artifact-management/search-filter-sort-packages) with some examples.
- Read the [Retention rules](https://docs.cloudsmith.com/artifact-management/retention-rules) documentation.
- Look at the examples in the [Cloudsmith Terraform provider](https://registry.terraform.io/providers/cloudsmith-io/cloudsmith/latest/docs/resources/repository_retention#retention_package_query_string-1) documentation.

If you have any questions, [contact us](/company/contact-us); we're here to help.
