Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-02T07:55:08.430Z
Answers.LastActivityDate: 2022-06-02T07:55:08.430Z
Answers.UserDisplayName: Oli
Body: <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>
  
Tags: <craft3><assets>
Title: How do you upload an asset via an API or GraphQL
ThreadText: # 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:
  
  ```graphql
  mutation MyMutation(
    $filename: String = "", 
    $url: String = "", 
    $title: String = ""
  ) {
    save_assets_Asset(
      _file: {filename: $filename, url: $url}
      title: $title
    ) {
      id
      title
    }
  }
  
  ```
  
  With the following variables:
  
  ```json
  {
    "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`).
  
  
  ---
  
  