Update the scene structure and content of an existing video template. This endpoint allows you to modify the template’s scene array, which defines the video’s structure, content, and visual elements.
Template Modification: Updating a template affects all future videos created from it. Existing videos created from this template will not be affected.
You need a valid API key to use this endpoint. Get your API key from the API Access page in your Pictory dashboard.
Array of scene objects that define the template structure. Each scene represents a segment in the video template with its own content, visuals, and timing.
Show scene object structure
The exact structure of scene objects should match the scene format used in Pictory projects. Common fields include:
Test Before Production: Always test template updates with non-production templates first to ensure the scene structure is valid and produces the expected results.
Scene Structure: The scenes array should match the structure used in Pictory projects. Refer to the Update Project endpoint documentation for scene object examples.
Version Control: Consider keeping backup copies of template configurations before making updates, especially for templates actively used in production.
import requestsdef validate_scenes(scenes): """ Validate scene structure before updating """ if not isinstance(scenes, list): return False, "Scenes must be an array" if len(scenes) == 0: return False, "Scenes array cannot be empty" for i, scene in enumerate(scenes): if not isinstance(scene, dict): return False, f"Scene {i} must be an object" # Add more validation as needed if 'text' in scene and not isinstance(scene['text'], str): return False, f"Scene {i} text must be a string" if 'duration' in scene and not isinstance(scene['duration'], (int, float)): return False, f"Scene {i} duration must be a number" return True, "Validation passed"def safe_update_template(template_id, scenes, api_key): """ Update template with validation """ # Validate scenes is_valid, message = validate_scenes(scenes) if not is_valid: print(f"Validation error: {message}") return False # Update template url = f"https://api.pictory.ai/pictoryapis/v1/templates/{template_id}" headers = { "Authorization": api_key, "Content-Type": "application/json" } try: response = requests.put( url, headers=headers, json={"scenes": scenes} ) result = response.json() if result.get('success'): print("Template updated successfully") return True else: print(f"Update failed: {result.get('message')}") return False except Exception as e: print(f"Error: {e}") return False# Example usagescenes = [ {"text": "Validated scene 1", "duration": 5}, {"text": "Validated scene 2", "duration": 8}]safe_update_template("YOUR_TEMPLATE_ID", scenes, "YOUR_API_KEY")