# How can i set a Pin expiration?

**URL:** <https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583>\
**Category:** Uncategorized\
**Tags:** go-ipfs\
**Created:** [December 8, 2020, 4:28am UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583 "2020-12-08T04:28:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![cc5566](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cc5566](https://discuss.ipfs.tech/u/cc5566)\
**Post date:** [December 8, 2020, 4:28am UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/1 "2020-12-08T04:28:17Z")

</div>

Hi all, i would like to set a Pin expiration. how could i code this? and how to i test the expiration?

Appreciate if there is any solution given.

Thanks.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [December 8, 2020, 9:01am UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/2 "2020-12-08T09:01:08Z")

</div>

[https://cluster.ipfs.io](https://cluster.ipfs.io) has support for pin expiration. See `--expire-in` in `ipfs-cluster-ctl pin add help`.

You can play around following [https://cluster.ipfs.io/documentation/quickstart/](https://cluster.ipfs.io/documentation/quickstart/).

---

<div class="post-metadata">

**Author:** ![cc5566](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cc5566](https://discuss.ipfs.tech/u/cc5566)\
**Post date:** [December 9, 2020, 7:26am UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/3 "2020-12-09T07:26:39Z")

</div>

@hector  
after pin expire-in is over. i will saw the following status. if i do a ipfs cat , i still can download the content. how i can restrict from download after the expiry?

```
> xxx : UNPINNED | 2020-12-09T07:24:12.956162387Z
> xxx : UNPINNED | 2020-12-09T07:24:12.956162387Z
```

---

<div class="post-metadata">

**Author:** ![cc5566](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cc5566](https://discuss.ipfs.tech/u/cc5566)\
**Post date:** [December 9, 2020, 11:08am UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/4 "2020-12-09T11:08:23Z")

</div>

@hector  
is it i need to perform garbage collections? with this ipfs repo gc command? i noticed it only clear the cache, the file still can retrieve by ipfs cat? if there anyway to permanent remove file when unpinned or expiry?

Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [December 9, 2020, 12:55pm UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/5 "2020-12-09T12:55:11Z")

</div>

It has to do with garbage collection and with not having any other copy anywhere in the network of that file, otherwise it will be transparently retrieved. There are many threads where the “how to permanently delete data” question has been answered.

---

<div class="post-metadata">

**Author:** ![cc5566](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cc5566](https://discuss.ipfs.tech/u/cc5566)\
**Post date:** [December 9, 2020, 1:51pm UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/6 "2020-12-09T13:51:55Z")

</div>

@hector

Thanks for the quick reply. is there any go-ipfs-api shell can perform garbage collection because i’m working with go lang? By the way, after pin expire-in is over, it wont automatically remove until we perform garbage collection? please correct if i’m wrong.

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [December 9, 2020, 2:23pm UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/7 "2020-12-09T14:23:15Z")

</div>

> [@cc5566](#):
>
> it wont automatically remove until we perform garbage collection? please correct if i’m wrong.

correct. Pin expiration only unpins.

You have [HTTP APIs for IPFS | IPFS Docs](https://docs.ipfs.io/reference/http/api/#api-v0-repo-gc) and the cluster api also has an `ipfs/gc` method [REST API - Pinset orchestration for IPFS](https://cluster.ipfs.io/documentation/reference/api/).

---

<div class="post-metadata">

**Author:** ![cc5566](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cc5566](https://discuss.ipfs.tech/u/cc5566)\
**Post date:** [December 9, 2020, 2:32pm UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/8 "2020-12-09T14:32:48Z")

</div>

is that mean i shall have a cron job to execute ipfs repo gc everyday in order to remove all unpins files? btw, is there any go repo gc library because i’m trigger all ipfs function using shell “[github.com/ipfs/go-ipfs-api](http://github.com/ipfs/go-ipfs-api)”

![image](https://us1.discourse-cdn.com/flex020/uploads/ipfs1/original/2X/1/175c16b06554c81e882eecd4fc024e4261d18f8d.png)

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [December 9, 2020, 2:42pm UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/9 "2020-12-09T14:42:57Z")

</div>

> [@cc5566](#):
>
> is that mean i shall have a cron job to execute ipfs repo gc everyday in order to remove all unpins files?

Probably.

> is there any go repo gc library because i’m trigger all ipfs function using shell “

While that library does not have an specific method to call RepoGC(), you can use Request() to call any API path manually. [shell package - github.com/ipfs/go-ipfs-api - Go Packages](https://godoc.org/github.com/ipfs/go-ipfs-api#Shell.Request)

---

<div class="post-metadata">

**Author:** ![cc5566](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cc5566](https://discuss.ipfs.tech/u/cc5566)\
**Post date:** [December 9, 2020, 2:58pm UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/10 "2020-12-09T14:58:27Z")

</div>

Thanks sharing. i really learn a lot from you.

---

<div class="post-metadata">

**Author:** ![cc5566](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cc5566](https://discuss.ipfs.tech/u/cc5566)\
**Post date:** [January 19, 2021, 8:16am UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/11 "2021-01-19T08:16:45Z")

</div>

@hector, in general if the pinned file is expired, we cant retrieve the content back am i correct?

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [January 19, 2021, 1:54pm UTC](https://discuss.ipfs.tech/t/how-can-i-set-a-pin-expiration/9583/12 "2021-01-19T13:54:49Z")

</div>

Cluster will unpin expired pins. As long as they have not been GC’ed or the content can be provided by someone in the network, the content is available, just unpinned.
