Create rich text styles. This interface is used to create rich text styles with specific formatting, including keyword highlighting, color settings, font size adjustments, etc. It is suitable for video subtitle beautification, text highlighting, content emphasis, and other scenarios.
More Documentation
π For more detailed documentation and tutorials, please visit: https://docs.jcaigc.cn
// Create text style functionconstaddTextStyle=async (draftUrl,textStyleList)=>{constresponse=awaitfetch('/openapi/capcut-mate/v1/add_text_style',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({draft_url:draftUrl,text_styles:textStyleList})});returnresponse.json();};// Usage example(async ()=>{constdraftUrl="https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/get_draft?draft_id=2025092811473036584258";consttextStyleList=[{element_id:"text_001",keyword:"important",style:{color:"#FF6B35",font_size:24,font_weight:"bold",background_color:"#FFE5CC",border_color:"#FF6B35",border_width:2,padding:8,border_radius:12},apply_to:"keyword"},{element_id:"text_002",style:{color:"#4ECDC4",font_size:18,font_family:"sans_serif",line_height:1.5,letter_spacing:1},apply_to:"all"}];constresult=awaitaddTextStyle(draftUrl,textStyleList);console.log('Text styles created successfully:',result);})();
Python Example
importrequestsdefadd_text_style(draft_url,text_style_list):"""Create rich text styles"""response=requests.post('https://api.assets.jcaigc.cn/openapi/capcut-mate/v1/add_text_style',headers={'Content-Type':'application/json'},json={"draft_url":draft_url,"text_styles":text_style_list})returnresponse.json()# Usage example
draft_url="https://capcut-mate.jcaigc.cn/openapi/capcut-mate/v1/get_draft?draft_id=2025092811473036584258"text_style_list=[{"element_id":"text_001","keyword":"important","style":{"color":"#FF6B35","font_size":24,"font_weight":"bold","background_color":"#FFE5CC","border_color":"#FF6B35","border_width":2,"padding":8,"border_radius":12},"apply_to":"keyword"},{"element_id":"text_002","style":{"color":"#4ECDC4","font_size":18,"font_family":"sans_serif","line_height":1.5,"letter_spacing":1},"apply_to":"all"}]result=add_text_style(draft_url,text_style_list)print(f"Text styles created successfully: {result['draft_url']}")
Error Code Description
Error Code
Error Message
Description
Solution
400
draft_url is required
Missing draft URL parameter
Provide a valid draft_url
400
text_styles parameter must be an array
text_styles parameter format error
Ensure text_styles is an array type
400
element_id cannot be empty
Element ID cannot be empty
Provide a valid element_id
400
Invalid color format
Color format error
Use valid hex color codes
400
Invalid font_size value
Font size is out of range
Font size should be between 8-72
400
Invalid font_weight value
Font weight error
Use preset font weight values
400
Invalid apply_to value
Application scope error
Use preset application scope values
404
Draft does not exist
Specified draft cannot be found
Confirm the draft URL is correct and exists
404
Text element does not exist
Specified text element cannot be found
Confirm the element_id is correct and exists
500
Text style creation failed
Internal service error
Contact technical support or try again later
503
Service unavailable
System under maintenance
Try again later
Notes
Element ID: Make sure the element_id exists and is unique, used to identify the target text element
Color Format: Use valid hex color codes (e.g., #FF6B35)
Font Size: Adjust font size appropriately to ensure text readability
Application Scope: Choose appropriate application scope to achieve precise style control
Keyword Matching: Keyword matching is case-sensitive, ensure accurate matching
Style Priority: When multiple styles conflict, the later created styles take precedence
Performance Optimization: Avoid creating too many text styles to prevent performance issues
Compatibility: Test style effects on different devices to ensure good compatibility
Top comments (0)