Create videos with Editor SDK

This documentation shows an example of creating a single video using Shakr Editor SDK. To see each steps at a glance, take a look at Editor SDK flow.


Create an empty RenderSession#

You can create a video by creating a RenderSession object. Each RenderSession represents single video, and after you create an empty RenderSession, you get RenderSession ID that can be used to load up the Shakr Editor.

Let's make a RenderSession based on TemplateStyleVersion ID that we have obtained from previous steps.

curl '' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer SERVER_ACCESS_TOKEN' \
--data-raw '{
"title": "My New Video",
"mapping": {
"template_style_version_id": "TEMPLATE_STYLE_VERSION_ID"
"edit_token": true
"render_session": {
"id": "string" // RenderSession ID
"edit_token": "string" // Scoped access token that can only access this RenderSession


When a RenderSession is successfully created, RenderSession ID and Edit Token are returned.

  • RenderSession ID: Unique ID of the created RenderSession. As Shakr API does not create and manage users, you can save this ID to your database and tie it to your users.
  • Edit Token: Edit Token is a scoped access token that can only access this RenderSession. This token is used to call Editor SDK.

While it is possible to use server access token to access Editor SDK, it should be avoided as it can allow accessing other user's videos or abnormally increase API usage and cost. Use edit_token on Editor SDK whenever possible as it only has limited access to the current RenderSession. Please refer to Authentication documentation to learn more.

Adding sdk.js to Web Application#

You can install and use SDK in various ways. While in this sample we're directly injecting <script> tag for a quick test, you can also use it by installing the npm package, which supports ES module syntax and TypeScript type annotations. For more information, please refer to Installation documentation.

To add Shakr SDK to your page, insert <script> tag of the SDK above the <script> tag that includes your application's code.

<script src="" defer></script>
<!-- Your application js codes -->

For security, Editor SDK requires HTTPS connections via Content Security Policy (CSP) headers. If you load Editor SDK under HTTP connection, browser will prevent SDK from loading. You can use HTTPS server with self-signed SSL certificate on your local testing environment.

Create a ShakrEditor instance#

The sample code below shows how to create a ShakrEditor instance. Replace ACCESS_TOKEN with edit_token, and RENDER_SESSION_ID with an empty RenderSession ID that you have created.

access_token: 'ACCESS_TOKEN',
render_session_id: 'RENDER_SESSION_ID'
}).then(function(editor) {
// editor instance is created

Handle events#

ShakrEditor instance emits many events, and you need to handle few events that are necessary for Editor SDK usage. More information around events can be found on Handling Events documentation.

For example, if you want to handle an event named EVENT_NAME, you can use this code to add event listener to handle events.

editor.on('EVENT_NAME', (...) => {

Launch an editor#

You can launch an editor by using .launch() function on ShakrEditor instance. After loading the Editor, load event will be called.

// Optional: Event handling when the Shakr Editor is open
editor.on('load', () => { ... });
// Launch the Shakr Editor

Close editor manually#

While the editor closes automatically when the video editing is finished, you can close the editor manually with .close() function.

After calling .close() function, confirm_close event will be emitted when there are unsaved changes. After confirming with the user, you can use .close(true) function to close the Editor.

// Close the Editor (confirm_close event may be called)
// Sample handling on confirm_close event logic
if (window.confirm('Any progress that has not been saved will be deleted. Would you like to continue?')) {

Knowing when video is ready#

There are two ways to know when video is ready. You can select the method based on your use case.

1. Use wait_rendering option#

  • No additional server-side code needed.
  • Render progress is displayed inside the editor.

2. Use webhook#

  • User does not have to keep the browser open until the render finishes.
  • Use when you want to limit downloads, as the video URL is not exposed to the client.

In this guide, we'll use wait_rendering method as it doesn't require additional server-side code. Please refer to Get notified with webhooks to learn more about using webhooks.

Add wait_rendering: true option when creating a ShakrEditor instance. When finish event is emitted, it will contain a URL for video download.

const editor = await createShakrEditor({
wait_rendering: true
.on('finish', ({ video_download_url }) => {
// Handle video url
// i.e. Integrating video player for playback, or download video

Sample code#

Using all the essential features above, you can write the code like below to integrate Editor SDK.

const editor = await createShakrEditor({
access_token: 'ACCESS_TOKEN',
render_session_id: 'RENDER_SESSION_ID',
api_url: '',
wait_rendering: true
.on('load', () => {
// The Editor is loaded successfully, and RenderSession information is loaded.
// User can make the video from inside the Editor.
console.log('User can start editing render session ' + editor.render_session_id);
.on('confirm_close', () => {
if (window.confirm('Any progress that has not been saved will be deleted. Would you like to continue?')){
.on('finish', ({ video_download_url }) => {
// wait_rendering is true, which means finish event will be called after the render is complete.
console.log('User has finished editing render session ' + editor.render_session_id);
console.log('Video url: ' + video_download_url);

Congratulations, you have successfully integrated Editor SDK to your web application! 🎉

More features of Editor SDK#

There are more features and options you can use to customize Editor SDK experience. Use these extra features to show custom media library to users,make it on-brand, and more.


Refer to Handling Errors documentation to learn more about errors you may encounter.