Update a Component
https://mapi.storyblok.com/v1/spaces/:space_id/components/:component_idUpdate the values of a component.
Path parameters
Section titled “Path parameters”- :space_id required number
Numeric ID of a space
- :component_id required number
Numeric ID of a component
Request body properties
Section titled “Request body properties”- component The Component Object
The component object
Show child properties
- name string
Technical name of a component. Visible in the content editor if the
display_nameisnull. - display_name string
Name displayed in the content editor
- schema object
Key value pairs of the component fields
- image string | null
URL of the component preview image (if uploaded)
- preview_field string
The component preview field in the UI
- is_root boolean
trueif a component can be used as a content type block - preview_tmpl string
The component preview template. Learn how to create a preview template.
- is_nestable boolean
trueif a component is a Nestable block - component_group_id string
The component folder ID
- icon string
Icon of the component
- color string
Color of the icon
- internal_tag_ids string[]
List of IDs of the internal tags assigned to a component
- content_type_asset_preview string
Asset preview field of a content type block
-
Response properties
Section titled “Response properties”- component The Component Object
The component object
Examples
Section titled “Examples”curl "https://mapi.storyblok.com/v1/spaces/656/components/4123" \ -X PUT \ -H "Authorization: YOUR_OAUTH_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"component\":{\"display_name\":null,\"id\":4123,\"is_nestable\":true,\"is_root\":false,\"name\":\"banner_section\",\"schema\":{\"headline\":{\"description\":\"Use this field for the title\",\"pos\":0,\"translatable\":true,\"type\":\"text\"}}}}"// Using the Universal JavaScript Client:// https://github.com/storyblok/storyblok-js-clientStoryblok.put('spaces/656/components/4123', { "component": { "display_name": null, "id": 4123, "is_nestable": true, "is_root": false, "name": "banner_section", "schema": { "headline": { "description": "Use this field for the title", "pos": 0, "translatable": true, "type": "text" } } }}) .then(response => { console.log(response) }).catch(error => { console.log(error) })$client = new \Storyblok\ManagementClient('YOUR_OAUTH_TOKEN');
$payload = ["component" => ["display_name" => null,"id" => 4123,"is_nestable" => true,"is_root" => false,"name" => "banner_section","schema" => ["headline" => ["description" => "Use this field for the title","pos" => 0,"translatable" => true,"type" => "text"]]]];
$client->put('spaces/656/components/4123', $payload)->getBody();HttpResponse<String> response = Unirest.put("https://mapi.storyblok.com/v1/spaces/656/components/4123") .header("Content-Type", "application/json") .header("Authorization", "YOUR_OAUTH_TOKEN") .body({"component":{"display_name":null,"id":4123,"is_nestable":true,"is_root":false,"name":"banner_section","schema":{"headline":{"description":"Use this field for the title","pos":0,"translatable":true,"type":"text"}}}}) .asString();var client = new RestClient("https://mapi.storyblok.com/v1/spaces/656/components/4123");var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");request.AddHeader("Authorization", "YOUR_OAUTH_TOKEN");request.AddParameter("application/json", "{\"component\":{\"display_name\":null,\"id\":4123,\"is_nestable\":true,\"is_root\":false,\"name\":\"banner_section\",\"schema\":{\"headline\":{\"description\":\"Use this field for the title\",\"pos\":0,\"translatable\":true,\"type\":\"text\"}}}}", ParameterType.RequestBody);IRestResponse response = client.Execute(request);import requests
url = "https://mapi.storyblok.com/v1/spaces/656/components/4123"
querystring = {}
payload = {"component":{"display_name":null,"id":4123,"is_nestable":true,"is_root":false,"name":"banner_section","schema":{"headline":{"description":"Use this field for the title","pos":0,"translatable":true,"type":"text"}}}}headers = { 'Content-Type': "application/json", 'Authorization': "YOUR_OAUTH_TOKEN"}
response = requests.request("PUT", url, data=payload, headers=headers, params=querystring)
print(response.text)require 'storyblok'client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
payload = {"component" => {"display_name" => null,"id" => 4123,"is_nestable" => true,"is_root" => false,"name" => "banner_section","schema" => {"headline" => {"description" => "Use this field for the title","pos" => 0,"translatable" => true,"type" => "text"}}}}
client.put('spaces/656/components/4123', payload)import Foundation
let headers = [ "Content-Type": "application/json", "Authorization": "YOUR_OAUTH_TOKEN"]
let postData = NSData(data: {"component":{"display_name":null,"id":4123,"is_nestable":true,"is_root":false,"name":"banner_section","schema":{"headline":{"description":"Use this field for the title","pos":0,"translatable":true,"type":"text"}}}}.data(using: String.Encoding.utf8)!)
let request = NSMutableURLRequest(url: NSURL(string: "https://mapi.storyblok.com/v1/spaces/656/components/4123")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)request.method = "PUT"request.allHTTPHeaderFields = headersrequest.httpBody = postData as Data
let session = URLSession.sharedlet 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()Get in touch with the Storyblok community