# Change a package from public to private in the depot

**URL:** <https://discourse.chef.io/t/change-a-package-from-public-to-private-in-the-depot/18115>\
**Category:** Habitat Wiki\
**Created:** [June 25, 2018, 2:39pm UTC](https://discourse.chef.io/t/change-a-package-from-public-to-private-in-the-depot/18115 "2018-06-25T14:39:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliott-davis](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/elliott-davis/32/2146_2.png) [@elliott-davis](https://discourse.chef.io/u/elliott-davis)\
**Post date:** [June 25, 2018, 2:39pm UTC](https://discourse.chef.io/t/change-a-package-from-public-to-private-in-the-depot/18115/1 "2018-06-25T14:39:52Z")

</div>

```auto
curl -v \
-X PATCH \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $HAB_AUTH_TOKEN" \
https://bldr.habitat.sh/v1/depot/pkgs/<origin>/<package_name>/<version>/<timestamp>/private

```

---

<div class="post-metadata">

**Author:** ![joshb](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshb/32/2380_2.png) [@joshb](https://discourse.chef.io/u/joshb)\
**Post date:** [July 5, 2018, 5:19pm UTC](https://discourse.chef.io/t/change-a-package-from-public-to-private-in-the-depot/18115/2 "2018-07-05T17:19:16Z")

</div>

Related to this, if you have many releases of a package that you need to make private at once, you can use a script like this:

```auto
#!/bin/bash
# fetch and delete all releases of a version of a package

ORIGIN='chef-server'
PACKAGE='automate-nginx'
VERSION='1.7.0-dev'

RELEASES=$(curl -s https://bldr.habitat.sh/v1/depot/pkgs/${ORIGIN}/${PACKAGE}/${VERSION}?range=0 | jq -r '.data | .[] | .["release"]')

for release in $RELEASES; do
  echo "privating: https://bldr.habitat.sh/v1/depot/pkgs/${ORIGIN}/${PACKAGE}/${VERSION}/${release}/private"
  curl -s \
  -X PATCH \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $HAB_AUTH_TOKEN" \
  "https://bldr.habitat.sh/v1/depot/pkgs/${ORIGIN}/${PACKAGE}/${VERSION}/${release}/private"
done

```

Thanks to @irvingpop for sharing this info!
