1. Update Asset

Update Asset

Update an asset using the the numeric ID of the asset.

https://mapi.storyblok.com/v1/spaces/:space_id/assets/:asset_id

Path Parameters

  • :space_id

    required number

    Numeric ID of a space

  • :asset_id

    required string

    Numeric id of an asset

Request Body Properties

  • asset

    The Asset Object

    A single asset object

    • asset_folder_id

      number

      Id of the folder containing this asset

    • alt

      string

      Alt text for the asset (default language)

    • copyright

      string

      Copyright text for the asset (default language)

    • title

      string

      Title of the asset (default language)

    • source

      string

      Source text of the asset (default language)

    • expire_at

      string

      Date when the asset should expire (Format: yyyy-MM-dd'T'HH:mm:ssZ)

    • focus

      string

      The focus point of the image (Only for image assets)

    • internal_tag_ids

      string[]

      List of ids of the tags assigned to the asset

    • publish_at

      string

      Date when the asset should be made public (Format: yyyy-MM-dd'T'HH:mm:ssZ)

    • is_private

      boolean

      Defines if the asset should be inaccessable to the public

    • meta_data

      object

      Includes custom metadata fields for an asset along with the default ones. It also contains the translations of the same if added in the format metafield__i18n__langcode . This field should be used for updating the metadata including the default ones. (alt, title, source, copyright)

Request
curl "https://mapi.storyblok.com/v1/spaces/123123/assets/656565" \ 
  -X PUT \
  -H "Authorization: YOUR_OAUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"asset_folder_id\": 123123,\"internal_tag_ids\": [1111],\"locked\": false,\"is_private\": true,\"publish_at\": \"2024-05-31T11:52:00.000Z\",\"meta_data\": {\"alt\": \"Asset ALT\",\"title\": \"Asset Title\",\"source\": \"Asset Source\",\"copyright\": \"Custom Text\"}}"
Request
// Using the Universal JavaScript Client:
// https://github.com/storyblok/storyblok-js-client
Storyblok.put('/spaces/123123/assets/656565', {
    "asset_folder_id": 123123,
    "internal_tag_ids": [1111],
    "locked": false,
    "is_private": true,
    "publish_at": "2024-05-31T11:52:00.000Z",
    "meta_data": {
        "alt": "Asset ALT",
        "title": "Asset Title",
        "source": "Asset Source",
        "copyright": "Custom Text"
    }
})
  .then(response => {
    console.log(response)
  }).catch(error => { 
    console.log(error)
  })
Request
$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');

$payload = [
    "asset_folder_id" =>  123123,
    "internal_tag_ids" =>  [1111],
    "locked" =>  false,
    "is_private" =>  true,
    "publish_at" =>  "2024-05-31T11 => 52 => 00.000Z",
    "meta_data" =>  [
        "alt" =>  "Asset ALT",
        "title" =>  "Asset Title",
        "source" =>  "Asset Source",
        "copyright" =>  "Custom Text"
    ]
];

$client->put('/spaces/123123/assets/656565', $payload)->getBody();
Request
require 'storyblok'
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')

payload = {
    "asset_folder_id" =>  123123,
    "internal_tag_ids" =>  [1111],
    "locked" =>  false,
    "is_private" =>  true,
    "publish_at" =>  "2024-05-31T11 => 52 => 00.000Z",
    "meta_data" =>  {
        "alt" =>  "Asset ALT",
        "title" =>  "Asset Title",
        "source" =>  "Asset Source",
        "copyright" =>  "Custom Text"
    }
}

client.put('/spaces/123123/assets/656565', payload)
Request
HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/123123/assets/656565")
  .header("Content-Type", "application/json")
  .header("Authorization", "YOUR_OAUTH_TOKEN")
  .body("{\"asset_folder_id\": 123123,\"internal_tag_ids\": [1111],\"locked\": false,\"is_private\": true,\"publish_at\": \"2024-05-31T11:52:00.000Z\",\"meta_data\": {\"alt\": \"Asset ALT\",\"title\": \"Asset Title\",\"source\": \"Asset Source\",\"copyright\": \"Custom Text\"}}")
  .asString();
Request
var client = new RestClient("https://mapi.storyblok.com/v1/spaces/123123/assets/656565");
var request = new RestRequest(Method.PUT);

request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");
request.AddParameter("application/json", "{\"asset_folder_id\": 123123,\"internal_tag_ids\": [1111],\"locked\": false,\"is_private\": true,\"publish_at\": \"2024-05-31T11:52:00.000Z\",\"meta_data\": {\"alt\": \"Asset ALT\",\"title\": \"Asset Title\",\"source\": \"Asset Source\",\"copyright\": \"Custom Text\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Request
import Foundation

let headers = [
  "Content-Type": "application/json",
  "Authorization": "YOUR_OAUTH_TOKEN"
]

let postData = NSData(data: "{\"asset_folder_id\": 123123,\"internal_tag_ids\": [1111],\"locked\": false,\"is_private\": true,\"publish_at\": \"2024-05-31T11:52:00.000Z\",\"meta_data\": {\"alt\": \"Asset ALT\",\"title\": \"Asset Title\",\"source\": \"Asset Source\",\"copyright\": \"Custom Text\"}}".data(using: String.Encoding.utf8)!)

let request = NSMutableURLRequest(url: NSURL(string: "https://mapi.storyblok.com/v1/spaces/123123/assets/656565")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)
request.method = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
Request
import requests

url = "https://mapi.storyblok.com/v1/spaces/123123/assets/656565"

querystring = {}

payload = "{\"asset_folder_id\": 123123,\"internal_tag_ids\": [1111],\"locked\": false,\"is_private\": true,\"publish_at\": \"2024-05-31T11:52:00.000Z\",\"meta_data\": {\"alt\": \"Asset ALT\",\"title\": \"Asset Title\",\"source\": \"Asset Source\",\"copyright\": \"Custom Text\"}}"
headers = {
  'Content-Type': "application/json",
  'Authorization': "YOUR_OAUTH_TOKEN"
}

response = requests.request("PUT", url, data=payload, headers=headers, params=querystring)

print(response.text)