<p>Currently, there’s no direct way of doing this. You can pass an existing folder ID but you can’t create folders on the fly.</p>
<p>However, you can create folders via an asset field (with dynamic path) attached to an entry type so there is an option that could work if you really need this done.</p>
<p>Create a section/entry type that has two fields, an Asset field with a dynamic path set to <code>{folderPath}</code> and a plain text one called <code>folderPath</code>.</p>
<p>It would then happen in three steps:</p>
<ol>
<li>Mutate the Asset and get its <code>ID</code> back</li>
<li>Mutate an entry in your new entry type where you set the Asset field to your (just uploaded) asset <code>ID</code> and set <code>folderPath</code> to whatever path you need, save and get its <code>id</code> back. This would create a folder and move your asset to it.</li>
<li>Delete the entry you’ve just created via a mutation using its <code>id</code>.</li>
</ol>
<p>I know it’s not straight forward but if you really need to make it work, this would do the trick.</p>

CC BY-SA 4.0
2020-12-18T07:05:45.253Z
2020-12-18T07:05:45.253Z
Oli
<p>Is it possible to create a subfolder within an asset volume via GraphQL? If yes, can you point me in the right direction?</p>
<p>I just found mutations for file uploading, but nothing for folder creation.</p>
<p>Thanks!</p>

CC BY-SA 4.0
2020-11-23T16:56:12.467Z
Do you want to create a subfolder on file upload or _just_ create a subfolder on a volume?
Oli
CC BY-SA 4.0
2020-11-23T19:02:47.353Z
Both ways are fine, though I would prefer to have the creation separate from uploading. And also how to read available folders. Thanks
Matthias Redl-Mann
CC BY-SA 4.0
2020-12-16T07:54:34.830Z
@Oli can you still help me with this?
Matthias Redl-Mann
<assets><graphql><subfolder>
Create folder in asset volume via GraphQL
# Create folder in asset volume via GraphQL

(Asked by: username_0 on 2020-11-23)

Is it possible to create a subfolder within an asset volume via GraphQL? If yes, can you point me in the right direction?

I just found mutations for file uploading, but nothing for folder creation.

Thanks!

**Tags:** assets, graphql, subfolder
> **Comments:**
> **username_1**: Do you want to create a subfolder on file upload or _just_ create a subfolder on a volume?  
> **username_0**: Both ways are fine, though I would prefer to have the creation separate from uploading. And also how to read available folders. Thanks  
> **username_0**: @Oli can you still help me with this?  

---

## 1 answers

### Answer by username_1 on 2020-12-18. Score: 3 | Accepted answer

Currently, there’s no direct way of doing this. You can pass an existing folder ID but you can’t create folders on the fly.

However, you can create folders via an asset field (with dynamic path) attached to an entry type so there is an option that could work if you really need this done.

Create a section/entry type that has two fields, an Asset field with a dynamic path set to `{folderPath}` and a plain text one called `folderPath`.

It would then happen in three steps:

1. Mutate the Asset and get its `ID` back
2. Mutate an entry in your new entry type where you set the Asset field to your (just uploaded) asset `ID` and set `folderPath` to whatever path you need, save and get its `id` back. This would create a folder and move your asset to it.
3. Delete the entry you’ve just created via a mutation using its `id`.

I know it’s not straight forward but if you really need to make it work, this would do the trick.


---

