# Ability to create DICOM archive for more than one study

**URL:** https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599
**Category:** General
**Tags:** rest-api
**Created:** [June 8, 2023, 2:54pm UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599 "2023-06-08T14:54:24Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![BNOEAFK](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/bnoeafk/32/1605_2.png) [@BNOEAFK](https://discourse.orthanc-server.org/u/BNOEAFK)
#### Post date: [June 8, 2023, 2:54pm UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599/1 "2023-06-08T14:54:24Z")

</div>

I understand that (as [per the docs](https://api.orthanc-server.com/#tag/Studies/paths/~1studies~1%7Bid%7D~1archive/post)) an archive can be generated by using a POST to /studies/{id}/archive. This would include the DICOMDIR of course.

I appreciate that performing the same archive on the /patients/{id}/archive but then that would (I assume) include _all_ studies and I have the requirement to only zip up select studies.

Is it possible to create one archive of select studies? If so, what does the URL look like?

---

<div class="post-metadata">

### Author: ![BNOEAFK](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/bnoeafk/32/1605_2.png) [@BNOEAFK](https://discourse.orthanc-server.org/u/BNOEAFK)
#### Post date: [June 8, 2023, 3:31pm UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599/2 "2023-06-08T15:31:26Z")

</div>

Ah ha! `/tools/create-media` with a list of resources looks like exactly what I’m after, I believe?

---

<div class="post-metadata">

### Author: ![BNOEAFK](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/bnoeafk/32/1605_2.png) [@BNOEAFK](https://discourse.orthanc-server.org/u/BNOEAFK)
#### Post date: [June 8, 2023, 4:06pm UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599/3 "2023-06-08T16:06:29Z")

</div>

Ok - thanks for bearing with me everyone! Last question (which I don’t think I can answer myself)…

When creating either an archive or media, I see that it can be downloaded using the `job/{id}/archive > download.zip` format … but after downloading, I would like to then reclaim the disk space used, but I don’t see in the API the ability to DELETE the archive after a download.

I would imagine that I could use something like  
`curl --request DELETE --url http://localhost:8042/jobs/{id}/archive` but that’s not listed in the API documentation online. I tried it and it _appears_ to have been accepted - I immediately tried downloading it (and that worked) but I also understand that there’s a configuration parameter that delays “delete” functionality so things aren’t removed immediately.

Am I going down the correct line here?

---

<div class="post-metadata">

### Author: ![alainmazy](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/alainmazy/32/1576_2.png) [@alainmazy](https://discourse.orthanc-server.org/u/alainmazy)
#### Post date: [June 9, 2023, 8:07am UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599/4 "2023-06-09T08:07:01Z")

</div>

Hi Dave,

No there is no such DELETE request.

Right now, the deletion of archive is driven only by this configuration:

```auto
  // Maximum number of ZIP/media archives that are maintained by
  // Orthanc, as a response to the asynchronous creation of archives.
  // The least recently used archives get deleted as new archives are
  // generated. This option was introduced in Orthanc 1.5.0, and has
  // no effect on the synchronous generation of archives.
  "MediaArchiveSize" : 1,

```

HTH,

Alain

---

<div class="post-metadata">

### Author: ![BNOEAFK](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/bnoeafk/32/1605_2.png) [@BNOEAFK](https://discourse.orthanc-server.org/u/BNOEAFK)
#### Post date: [June 9, 2023, 3:37pm UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599/5 "2023-06-09T15:37:46Z")

</div>

Alain,  
Thanks - yes this certainly helps.

However, could I put a request in to have DELETE added to the API, please? I appreciate that the MediaArchiveSize certainly helps, but I can easily see instances where more than one archive should be kept on the server. Being able to programmatically remove one (upon a successful download for example) would be ultimately very beneficial.

Dave

---

<div class="post-metadata">

### Author: ![alainmazy](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/alainmazy/32/1576_2.png) [@alainmazy](https://discourse.orthanc-server.org/u/alainmazy)
#### Post date: [June 12, 2023, 4:45pm UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599/6 "2023-06-12T16:45:57Z")

</div>

Hi Dave,

I was hesitating to implement before you asked so [here it is](https://hg.orthanc-server.com/orthanc/rev/b5c502bcaf99).

It will be available in the next release.

Best regards,

Alain.

---

<div class="post-metadata">

### Author: ![BNOEAFK](https://discourse.orthanc-server.org/user_avatar/discourse.orthanc-server.org/bnoeafk/32/1605_2.png) [@BNOEAFK](https://discourse.orthanc-server.org/u/BNOEAFK)
#### Post date: [June 12, 2023, 6:05pm UTC](https://discourse.orthanc-server.org/t/ability-to-create-dicom-archive-for-more-than-one-study/3599/7 "2023-06-12T18:05:34Z")

</div>

Awesome! Thanks Alain!
