<p>An Asset mutation looks like this:</p>
<pre class="lang-graphql prettyprint-override"><code>mutation MyMutation(
  $filename: String = &quot;&quot;, 
  $url: String = &quot;&quot;, 
  $title: String = &quot;&quot;
) {
  save_assets_Asset(
    _file: {filename: $filename, url: $url}
    title: $title
  ) {
    id
    title
  }
}
</code></pre>
<p>With the following variables:</p>
<pre class="lang-json prettyprint-override"><code>{
  &quot;filename&quot;: &quot;image.jpg&quot;,
  &quot;url&quot;: &quot;https://domain.com/image.jpg&quot;,
  &quot;title&quot;: &quot;Asset from GQL&quot;
}
</code></pre>
<p>You would need to change <code>save_assets_Asset</code> to match your own volume, of course (<code>save_assets_VolumeName</code>).</p>

CC BY-SA 4.0
2022-06-02T07:55:08.430Z
2022-06-02T07:55:08.430Z
Oli
<p>Is it possible to upload a new asset via some POST request to craft's API? Or maybe through a graphql mutation?</p>
<p>I noticed in the public schema there is the option for Creating assets within a volume.</p>
<p>Kind regards</p>

<craft3><assets>
How do you upload an asset via an API or GraphQL
# How do you upload an asset via an API or GraphQL

(Asked by: username_0 on 2022-06-02)

Is it possible to upload a new asset via some POST request to craft's API? Or maybe through a graphql mutation?

I noticed in the public schema there is the option for Creating assets within a volume.

Kind regards

**Tags:** craft3, assets


---

## 1 answers

### Answer by username_1 on 2022-06-02. Score: 1

An Asset mutation looks like this:
mutation MyMutation(
  $filename: String = "", 
  $url: String = "", 
  $title: String = ""
) {
  save_assets_Asset(
    _file: {filename: $filename, url: $url}
    title: $title
  ) {
    id
    title
  }
}

With the following variables:
{
  "filename": "image.jpg",
  "url": "https://domain.com/image.jpg",
  "title": "Asset from GQL"
}

You would need to change save_assets_Asset to match your own volume, of course (save_assets_VolumeName).


---

