Create Document

Purpose

Create a new document in Zoho Writer. Use this endpoint to launch a Writer editor session with customizable defaults, permissions, and save callbacks.

Quick Reference

PropertyValue
MethodPOST
Request URLhttps://{api.office-integrator_domain}/writer/officeapi/v1/documents
Content-Typemultipart/form-data

Parameters

Body Parameters

ParameterValueMandatory/OptionalDescription
apikey423s*****MandatoryUniquely identifies the web application in which the Writer editor is integrated.
callback_settings

{
 "save_format":"zdoc",
 "save_url":<Your Save URL>,
 "http_method_type": "post",
 "retries": <Integer>,
 "timeout": <Integer>,
 "save_url_params": {
                ....
         },

"save_url_headers": {
                <header_key1>: <value1>,
                <header_key2>: <value2>,
                 ….
        }
}

Optional

Using this param, you will be able to specify the following;

save_format -> Specify the output format in which the edited document needs to be saved.

save_url -> Provide your server location to which the latest content needs to be pushed back when the 'Save' is performed.

The below key values are optional;

http_method_type -> Specify the http method in which the save request has to be triggered.

retries -> Specify the number of retries required when the 'Save' fails.

timeout -> Specify the timeout for the given saveurl.

save_url_params -> To customize the output parameters in which the document details will be pushed from our end.

save_url_headers -> Specify the header key values that needs to be pushed back as request headers when the save is triggered.

document_defaults{
 "orientation":"portrait",
 "paper_size":"Letter",
 "font_name":"Lato",
 "font_size":14,
 "track_changes":"disabled",
 "track_changes_mode":"all_markup",
 "margin": {"left":"1.5in","right":"1.5in","top":"0.25in","bottom":"0.25in"},
 "language":"en-US",
 "date_format":"MM/DD/YY"
}
OptionalSet document defaults such as font name/size, paper size, orientation, track changes, margins, language, and date format.
editor_settings{
  "unit":"in", 
  "language":"en",
  "view":"webview"
}
OptionalSet editor preferences like unit (in/mm), interface language, and view mode (pageview/webview).
permissions{
 "document.export":true,
 "document.print":true,
 "document.edit":true,
 "review.changes.resolve":false,
 "review.comment":true,
 "collab.chat":true,
"document.pausecollaboration":false,
"document.fill":true
}
OptionalDefine document permissions for users (export, print, edit, comment, resolve changes, chat, collaboration, fill).
document_info{
 "document_name":"New",
 "document_id":"1349"
}
OptionalSet a unique document ID and specify the display name of the new document.
user_info{
  "user_id":"9173",
  "display_name":"Ken"
}
OptionalIdentify the user in the document with a user ID and display name.
ui_options{
  "save_button":"show",
  "chat_panel":"show",
  "dark_mode":"show",
  "file_menu":"show"
}
OptionalSpecify whether the Save button, Chat panel, File menu, and Dark mode option are shown or hidden.

callback_settings

Parameter/KeysTypeMandatory/OptionalPossible ValuesDefault Value
save_formatStringMandatoryzdoc / doc / docx / odt / html / pdf and morezdoc
save_urlStringMandatoryURL (max length: 65535)
save_url_paramsJSONOptional
  • Max 10 keys.
  • Allowed characters for <additional_user_key> - Alphabets, Numbers, Hyphen, Underscore and Dot. Maximum Length - 100 characters
  • Maximum length of <value> - 2500 characters
save_url_headersJSONOptional
  • Maximum key count - 10
  • Allowed characters for <additional_header_key> - Alphabets, Numbers, Hyphen, Underscore and Dot. Maximum Length - 100 characters
  • Maximum length of <value> - 500 characters
http_method_typeStringOptionalpost / putpost
retriesIntegerOptional0 to 30
timeoutIntegerOptional1 to 120000 (ms)120000

save_url Usage

Zoho Office Integrator allows partners and businesses to save the document content back to their specified storage server through the save_url method.

A save_url is a publicly accessible web URL/Service to which Zoho will push the updated document content from Writer editor to the partner's server.

Requirements:

  • Partner's remote servers need to expose one of their ports — port 443 (HTTPS) or port 80 (HTTP) — for Zoho Writer to push the data back.
  • The save_url value specified in the request should be a proper domain name and publicly accessible over the web. Example: https://yourdomain.com/save.php

save_url_params Usage

By default, when 'Save' is performed, the following key names are pushed back:

Key NameTypeDescription
contentFileDocument content will be pushed back in the form of bytes.
filenameStringDocument name
formatStringSpecifies the format in which the document has been exported.

To customize the above key names, use the save_url_params key inside the callback_settings parameter. Once configured, only the key values defined inside will be pushed back to your server. The default key names (like filename and format) will not be included unless you define your own keys using the system variables $format, $filename, and $session_id.

Syntax:

"save_url_params": {
      <custom_content_key>: $content,
      <custom_format_key>: $format,
      <custom_filename_key>: $filename,
      <custom_sessionId_key>: $session_id,
      <additional_user_key>: <value>,
      <additional_user_key>: <value>,
      ....
      <additional_user_key>: <value>
      },

Example:

"save_url_params": {
      file: $content,
      extension: $format,
      document_name: $filename,
      session_id: $session_id,
      <additional_user_key>: <value>,
      <additional_user_key>: <value>
      },

In the above example, the document bytes will be pushed back in the multipart name file, document format in the key name extension, document filename in the key name document_name, and document session id in the key name session_id.

If save_url_params is passed as an empty JSON or the system variable $content is not configured, the document bytes will be pushed back with the multipart name content by default.

document_defaults

Parameter/KeysTypeMandatory/OptionalPossible ValuesDefault Value
font_nameStringOptionale.g., TrebuchetArial
font_sizeIntegerOptional9 / 10 / 11 / 13 / 16 / 18 (px)12 (px)
orientationStringOptionalportrait / landscapeportrait
paper_sizeStringOptionalLetter / A4 / Legal / ExecutiveLetter
track_changesStringOptionalenabled / disableddisabled
track_changes_modeStringOptionalall_markup / no_markup / originalall_markup
marginJSONOptionalin / mm (e.g., {"left":"1.5in","right":"1.5in","top":"0.25in","bottom":"0.25in"})1in
languageStringOptionalen-US / af / bn / ca / cs / et and moreen-US
date_formatStringOptionale.g., EEEE, MMMM DD, YYYY at HH:mmBased on document language

editor_settings

Parameter/KeysTypeMandatory/OptionalPossible ValuesDefault Value
unitStringOptionalin / mmin
languageStringOptionalen / de / es / fr / ja / nl and moreen
viewStringOptionalwebview / pageviewpageview

permissions

Parameter/KeysTypeMandatory/OptionalPossible ValuesDefault Value
document.exportBooleanOptionaltrue / falsetrue
document.printBooleanOptionaltrue / falsetrue
document.editBooleanOptionaltrue / falsefalse
review.commentBooleanOptionaltrue / falsefalse
review.changes.resolveBooleanOptionaltrue / falsefalse
collab.chatBooleanOptionaltrue / falsetrue
document.pausecollaborationBooleanOptionaltrue / falsefalse
document.fillBooleanOptionaltrue / falsetrue

document_info

Parameter/KeysTypeMandatory/OptionalPossible ValuesDefault Value
document_idStringOptionale.g., 24eru24960v
document_nameStringOptionale.g., SampleUntitled

user_info

Parameter/KeysTypeMandatory/OptionalPossible ValuesDefault Value
user_idStringOptionale.g., 03588563264
display_nameStringOptionale.g., Ken / James / AdamGuest

ui_options

Parameter/KeysTypeMandatory/OptionalPossible ValuesDefault Value
save_buttonStringOptionalshow / hideshow
chat_panelStringOptionalshow / hideshow
dark_modeStringOptionalshow / hideshow
file_menuStringOptionalshow / hideshow

Notes and Limits

  • Editor customization parameters and their values are case-sensitive.
  • Custom margin is applicable to new documents only.
  • The view parameter under editor_settings is applicable only for new documents.
  • Document language affects spelling/grammar suggestions and currency/number formats.
  • For possible error codes, refer to: Error Codes
  • For other server-side SDK sample code, refer to: Server-Side SDKs

Sample Request

Copied  curl -X POST \
  'https://api.office-integrator.com/writer/officeapi/v1/documents' \
  -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
  -F 'apikey=423s*****' \
  -F 'document_defaults={"font_size":"12","font_name":"Roboto","orientation":"portrait","paper_size":"A4","track_changes":"disabled","language":"en-US","margin": {"left":"1.5in","right":"1.5in","top":"0.25in","bottom":"0.25in"},"date_format":"MM/DD/YY"}' \
  -F 'editor_settings={"unit":"in","language":"en","view":"webview"}' \
 -F 'permissions={'\''document.export'\'':true,'\''document.print'\'':true,'\''document.edit'\'':true,'\''review.changes.resolve'\'':false,'\''review.comment'\'':true,'\''collab.chat'\'':true,'\''document.pausecollaboration'\'':false,'\''document.fill'\'':true }' \  
  -F 'callback_settings={"save_format":"zdoc","save_url":"https://domain.com/save.php"}' \
  -F 'document_info={"document_name":"New","document_id":1349}' \
  -F 'user_info={"user_id":"9173","display_name":"Ken"}' \
  -F 'ui_options={"save_button":"show","chat_panel":"show","dark_mode":"hide","file_menu":"show"}'
Copiedimport * as SDK from "@zoho-corp/office-integrator-sdk";

class CreateDocument {

    static async execute() {
        
        //Initializing SDK once is enough. Calling here since the code sample will be tested standalone. 
        //You can place SDK initializer code in you application and call once while your application start-up. 
        await this.initializeSdk();

        try {
            var sdkOperations = new SDK.V1.V1Operations();
            var createDocumentParameters = new SDK.V1.CreateDocumentParameters();

            var documentInfo = new SDK.V1.DocumentInfo();

            //Time value used to generate unique document everytime. You can replace based on your application.
            documentInfo.setDocumentId("" + new Date().getTime());
            documentInfo.setDocumentName("New Document");

            createDocumentParameters.setDocumentInfo(documentInfo);

            var userInfo = new SDK.V1.UserInfo();

            userInfo.setUserId("1000");
            userInfo.setDisplayName("Amelia");

            createDocumentParameters.setUserInfo(userInfo);

            var margin = new SDK.V1.Margin();

            margin.setTop("2in");
            margin.setBottom("2in");
            margin.setLeft("2in");
            margin.setRight("2in");

            var documentDefaults = new SDK.V1.DocumentDefaults();

            documentDefaults.setFontSize(12);
            documentDefaults.setPaperSize("A4");
            documentDefaults.setFontName("Arial");
            documentDefaults.setTrackChanges("enabled");
            documentDefaults.setOrientation("landscape");

            documentDefaults.setMargin(margin);
            documentDefaults.setLanguage("ta");

            createDocumentParameters.setDocumentDefaults(documentDefaults);

            var editorSettings = new SDK.V1.EditorSettings();

            editorSettings.setUnit("in");
            editorSettings.setLanguage("en");
            editorSettings.setView("pageview");

            createDocumentParameters.setEditorSettings(editorSettings);

            var uiOptions = new SDK.V1.UiOptions();

            uiOptions.setDarkMode("show");
            uiOptions.setFileMenu("show");
            uiOptions.setSaveButton("show");
            uiOptions.setChatPanel("show");

            createDocumentParameters.setUiOptions(uiOptions);

            var permissions = new Map();

            permissions.set("document.export", true);
            permissions.set("document.print", false);
            permissions.set("document.edit", true);
            permissions.set("review.comment", false);
            permissions.set("review.changes.resolve", false);
            permissions.set("collab.chat", false);
            permissions.set("document.pausecollaboration", false);
            permissions.set("document.fill", false);

            createDocumentParameters.setPermissions(permissions);

            var callbackSettings = new SDK.V1.CallbackSettings();
            var saveUrlParams = new Map();

            saveUrlParams.set("auth_token", "1234");
            saveUrlParams.set("id", "123131");

            var saveUrlHeaders = new Map();

            saveUrlHeaders.set("header1", "value1");
            saveUrlHeaders.set("header2", "value2");

            callbackSettings.setSaveUrlParams(saveUrlParams);
            callbackSettings.setSaveUrlHeaders(saveUrlHeaders);
            callbackSettings.setRetries(1);
            callbackSettings.setSaveFormat("zdoc");
            callbackSettings.setHttpMethodType("post");
            callbackSettings.setTimeout(100000);
            callbackSettings.setSaveUrl("https://bc59556ab64f536be787aeca1dd36571.m.pipedream.net");

            createDocumentParameters.setCallbackSettings(callbackSettings);

            var responseObject = await sdkOperations.createDocument(createDocumentParameters);

            if(responseObject != null) {
                //Get the status code from response
                console.log("\nStatus Code: " + responseObject.statusCode);
    
                //Get the api response object from responseObject
                let writerResponseObject = responseObject.object;
    
                if(writerResponseObject != null){
    
                    //Check if expected CreateDocumentResponse instance is received
                    if(writerResponseObject instanceof SDK.V1.CreateDocumentResponse){
                        console.log("\nDocument ID - " + writerResponseObject.getDocumentId());
                        console.log("\nDocument session ID - " + writerResponseObject.getSessionId());
                        console.log("\nDocument session URL - " + writerResponseObject.getDocumentUrl());
                        console.log("\nDocument save URL - " + writerResponseObject.getSaveUrl());
                        console.log("\nDocument delete URL - " + writerResponseObject.getDocumentDeleteUrl());
                        console.log("\nDocument session delete URL - " + writerResponseObject.getSessionDeleteUrl());
                    } else if (writerResponseObject instanceof SDK.V1.InvalidConfigurationException) {
                        console.log("\nInvalid configuration exception. Exception json - ", writerResponseObject);
                    } else {
                        console.log("\nRequest not completed successfullly");
                    }
                }
            }
        } catch (error) {
            console.log("\nException while running sample code", error);
        }
    }

    //Include office-integrator-sdk package in your package json and the execute this code.

    static async initializeSdk() {

        // Refer this help page for api end point domain details -  https://www.zoho.com/officeintegrator/api/v1/getting-started.html
        let environment = await new SDK.DataCenter.Production("https://api.office-integrator.com");

        let auth = new SDK.AuthBuilder()
                        .addParam("apikey", "2ae438cf8644*********") //Update this apikey with your own apikey signed up in office integrator service
                        .authenticationSchema(await new SDK.V1.Authentication().getTokenFlow())
                        .build();

        let tokens = [ auth ];

        //Sdk application log configuration
        let logger = new SDK.LogBuilder()
            .level(SDK.Levels.INFO)
            //.filePath("<file absolute path where logs would be written>") //No I18N
            .build();

        let initialize = await new SDK.InitializeBuilder();

        await initialize.environment(environment).tokens(tokens).logger(logger).initialize();

        console.log("SDK initialized successfully.");
    }

}

CreateDocument.execute();
Copied//Reference on how to run below sample code: http://zco.to/run-java

package com.zoho.officeintegrator.v1.examples.writer;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

import com.zoho.Initializer;
import com.zoho.UserSignature;
import com.zoho.api.authenticator.APIKey;
import com.zoho.api.logger.Logger;
import com.zoho.api.logger.Logger.Levels;
import com.zoho.dc.ZOIEnvironment;
import com.zoho.officeintegrator.v1.CallbackSettings;
import com.zoho.officeintegrator.v1.CreateDocumentParameters;
import com.zoho.officeintegrator.v1.CreateDocumentResponse;
import com.zoho.officeintegrator.v1.DocumentDefaults;
import com.zoho.officeintegrator.v1.DocumentInfo;
import com.zoho.officeintegrator.v1.EditorSettings;
import com.zoho.officeintegrator.v1.InvaildConfigurationException;
import com.zoho.officeintegrator.v1.Margin;
import com.zoho.officeintegrator.v1.UiOptions;
import com.zoho.officeintegrator.v1.UserInfo;
import com.zoho.officeintegrator.v1.V1Operations;
import com.zoho.officeintegrator.v1.WriterResponseHandler;
import com.zoho.util.APIResponse;

public class CreateDocument {

	private static final java.util.logging.Logger LOGGER = java.util.logging.Logger.getLogger(CreateDocument.class.getName());

	public static void main(String args[]) {
		
		try {
			//Initializing SDK once is enough. Calling here since code sample will be tested standalone. 
	        //You can place SDK initializer code in you application and call once while your application start-up. 
			initializeSdk();

			V1Operations sdkOperations = new V1Operations();
			CreateDocumentParameters createDocumentParams = new CreateDocumentParameters();
			
			DocumentInfo documentInfo = new DocumentInfo();
			
			documentInfo.setDocumentName("Untilted Document");
			//System time value used to generate unique document everytime. You can replace based on your application.
			documentInfo.setDocumentId("" + System.currentTimeMillis());
			
			createDocumentParams.setDocumentInfo(documentInfo);
			
			UserInfo userInfo = new UserInfo();
			
			userInfo.setUserId("1000");
			userInfo.setDisplayName("John");
			
			createDocumentParams.setUserInfo(userInfo);

			Margin margin = new Margin();
			
			margin.setTop("2in");
			margin.setBottom("2in");
			margin.setLeft("2in");
			margin.setRight("2in");

			DocumentDefaults documentDefault = new DocumentDefaults();
			
			documentDefault.setFontSize(14);
			documentDefault.setFontName("Arial");
			documentDefault.setPaperSize("Letter");
			documentDefault.setOrientation("portrait");
			documentDefault.setTrackChanges("disabled");
			
			documentDefault.setMargin(margin);
			createDocumentParams.setDocumentDefaults(documentDefault);
			
			EditorSettings editorSettings = new EditorSettings();
			
			editorSettings.setUnit("in");
			editorSettings.setLanguage("en");
			editorSettings.setView("pageview");
			
			createDocumentParams.setEditorSettings(editorSettings);
			
			UiOptions uiOptions = new UiOptions();
			
			uiOptions.setChatPanel("show");
			uiOptions.setDarkMode("show");
			uiOptions.setFileMenu("show");
			uiOptions.setSaveButton("show");
			
			createDocumentParams.setUiOptions(uiOptions);
			
			Map<String, Object> permissions = new HashMap<String, Object>();
			
			permissions.put("collab.chat", false);
                       permissions.put("document.edit", true);
                       permissions.put("review.comment", false);
                       permissions.put("document.export", true);
			permissions.put("document.print", false);
			permissions.put("document.fill", false);
                       permissions.put("review.changes.resolve", false);
                       permissions.put("document.pausecollaboration", false);
            
			createDocumentParams.setPermissions(permissions);
			
			Map<String, Object> saveUrlParams = new HashMap<String, Object>();
			
			saveUrlParams.put("id", 123456789);
			saveUrlParams.put("auth_token", "oswedf32ru”);
			
			
			CallbackSettings callbackSettings = new CallbackSettings();
			
			callbackSettings.setRetries(2);
			callbackSettings.setTimeout(10000);
			callbackSettings.setSaveFormat("docx");
			callbackSettings.setHttpMethodType("post");
			callbackSettings.setSaveUrlParams(saveUrlParams);
			callbackSettings.setSaveUrl("https://domain.com/save.php");  // Enter your server location
			
			createDocumentParams.setCallbackSettings(callbackSettings);
			
			APIResponse<WriterResponseHandler> response =  sdkOperations.createDocument(createDocumentParams);
			int responseStatusCode = response.getStatusCode();
			
			if ( responseStatusCode >= 200 && responseStatusCode <= 299 ) {
				CreateDocumentResponse documentResponse = (CreateDocumentResponse) response.getObject();

				LOGGER.log(Level.INFO, "Document id - {0}", new Object[] { documentResponse.getDocumentId() }); //No I18N
				LOGGER.log(Level.INFO, "Document session id - {0}", new Object[] { documentResponse.getSessionId() }); //No I18N
				LOGGER.log(Level.INFO, "Document session url - {0}", new Object[] { documentResponse.getDocumentUrl() }); //No I18N
			} else {
				InvaildConfigurationException invalidConfiguration = (InvaildConfigurationException) response.getObject();
				String errorMessage = invalidConfiguration.getMessage();
				
				/*Long errorCode = invalidConfiguration.getCode();
				String errorKeyName = invalidConfiguration.getKeyName();
				String errorParameterName = invalidConfiguration.getParameterName();*/
				
				LOGGER.log(Level.INFO, "Document configuration error - {0}", new Object[] { errorMessage }); //No I18N
			}
			
		} catch (Exception e) {
			LOGGER.log(Level.INFO, "Exception in creating document session url - ", e); //No I18N
		}
	}
	
	public static boolean initializeSdk() {
		boolean status = false;

		try {
			APIKey apikey = new APIKey("2ae438cf864488657cc9******);
	        UserSignature user = new UserSignature("john@zylker.com"); //No I18N
	        Logger logger = new Logger.Builder()
						        .level(Levels.INFO)
						        //.filePath("<file absolute path where logs would be written>") //No I18N
						        .build();

	        ZOIEnvironment.setProductionUrl("https://api.office-integrator.com/");

			new Initializer.Builder()
				.user(user)
				.environment(ZOIEnvironment.PRODUCTION)
				.token(apikey)
				.logger(logger)
				.initialize();
			
			status = true;
		} catch (Exception e) {
			LOGGER.log(Level.INFO, "Exception in creating document session url - ", e); //No I18N
		}
		return status;
	}
}
Copied#Reference on how to run below sample code: http://zco.to/run-php

<?php
namespace com\zoho\officeintegrator\v1\writer;

require_once dirname(__FILE__) . '/../vendor/autoload.php';

use com\zoho\api\authenticator\APIKey;
use com\zoho\api\logger\Levels;
use com\zoho\api\logger\LogBuilder;
use com\zoho\dc\DataCenter;
use com\zoho\InitializeBuilder;
use com\zoho\officeintegrator\v1\CallbackSettings;
use com\zoho\officeintegrator\v1\CreateDocumentResponse;
use com\zoho\officeintegrator\v1\InvalidConfigurationException;
use com\zoho\UserSignature;
use com\zoho\util\Constants;
use com\zoho\officeintegrator\v1\CreateDocumentParameters;
use com\zoho\officeintegrator\v1\DocumentDefaults;
use com\zoho\officeintegrator\v1\DocumentInfo;
use com\zoho\officeintegrator\v1\EditorSettings;
use com\zoho\officeintegrator\v1\Margin;
use com\zoho\officeintegrator\v1\UiOptions;
use com\zoho\officeintegrator\v1\UserInfo;
use com\zoho\officeintegrator\v1\V1Operations;
use Exception;

class CreateDocument {

    // Refer API documentation - https://www.zoho.com/officeintegrator/api/v1/zoho-writer-create-document.html
    public static function execute() {
        // Initializing SDK once is enough. Calling here since the code sample will be tested standalone. 
        // You can place SDK initializer code in your application and call it once while your application starts up.
        self::initializeSdk();

        try {
            $sdkOperations = new V1Operations();
            $createDocumentParameters = new CreateDocumentParameters();

            # Optional Configuration - Add document meta in request to identify the file in Zoho Server
            $documentInfo = new DocumentInfo();

            // Time value used to generate a unique document every time. You can replace it based on your application.
            $documentInfo->setDocumentId(strval(time()));
            $documentInfo->setDocumentName("New Document");

            $createDocumentParameters->setDocumentInfo($documentInfo);

            # Optional Configuration - Add User meta in request to identify the user in document session
            $userInfo = new UserInfo();

            $userInfo->setUserId("1000");
            $userInfo->setDisplayName(“John”);

            $createDocumentParameters->setUserInfo($userInfo);

            # Optional Configuration 
            $margin = new Margin();

            $margin->setTop("2in");
            $margin->setBottom("2in");
            $margin->setLeft("2in");
            $margin->setRight("2in");

            # Optional Configuration 
            $documentDefaults = new DocumentDefaults();

            $documentDefaults->setFontSize(12);
            $documentDefaults->setPaperSize("A4");
            $documentDefaults->setFontName("Arial");
            $documentDefaults->setTrackChanges("enabled");
            $documentDefaults->setOrientation("landscape");

            $documentDefaults->setMargin($margin);
            $documentDefaults->setLanguage("ta");

            $createDocumentParameters->setDocumentDefaults($documentDefaults);

            # Optional Configuration 
            $editorSettings = new EditorSettings();

            $editorSettings->setUnit("in");
            $editorSettings->setLanguage("en");
            $editorSettings->setView("pageview");

            $createDocumentParameters->setEditorSettings($editorSettings);

            # Optional Configuration 
            $uiOptions = new UiOptions();

            $uiOptions->setDarkMode("show");
            $uiOptions->setFileMenu("show");
            $uiOptions->setSaveButton("show");
            $uiOptions->setChatPanel("show");

            $createDocumentParameters->setUiOptions($uiOptions);

            # Optional Configuration 
            $permissions = array();

            $permissions["document.export"] = true;
            $permissions["document.print"] = false;
            $permissions["document.edit"] = true;
            $permissions["review.comment"] = false;
            $permissions["review.changes.resolve"] = false;
            $permissions["collab.chat"] = false;
            $permissions["document.pausecollaboration"] = false;
            $permissions["document.fill"] = false;

            $createDocumentParameters->setPermissions($permissions);

            # Optional Configuration - Add callback settings to configure.
            # how file needs to be received while saving the document
            $callbackSettings = new CallbackSettings();

            # Optional Configuration - configure additional parameters
            # which can be received along with document while save callback
            $saveUrlParams = array();

            $saveUrlParams["param1"] = "value1";
            $saveUrlParams["param2"] = "value2";

            $callbackSettings->setSaveUrlParams($saveUrlParams);
            
            # Optional Configuration - configure additional headers
            # which could be received in callback request headers while saving document
            $saveUrlHeaders = array();

            $saveUrlHeaders["header1"] = "value1";
            $saveUrlHeaders["header2"] = "value2";

            $callbackSettings->setSaveUrlHeaders($saveUrlHeaders);

            $callbackSettings->setRetries(1);
            $callbackSettings->setSaveFormat("zdoc");
            $callbackSettings->setHttpMethodType("post");
            $callbackSettings->setTimeout(100000);
            $callbackSettings->setSaveUrl("https://domain.com/save.php"); 
// To implement your save callback url, refer here: https://github.com/iampraba/zoi-php-sdk-examples/tree/eeb5994f70125d264aa98091c1efdd547219b615/save_callback_implementation

            $createDocumentParameters->setCallbackSettings($callbackSettings);

            $responseObject = $sdkOperations->createDocument($createDocumentParameters);

            if ($responseObject != null) {
                // Get the status code from response
                echo "\nStatus Code: " . $responseObject->getStatusCode() . "\n";

                // Get the api response object from responseObject
                $writerResponseObject = $responseObject->getObject();

                if ($writerResponseObject != null) {
                    // Check if the expected CreateDocumentResponse instance is received
                    if ($writerResponseObject instanceof CreateDocumentResponse) {
                        echo "\nDocument ID - " . $writerResponseObject->getDocumentId() . "\n";
                        echo "\nDocument session ID - " . $writerResponseObject->getSessionId() . "\n";
                        echo "\nDocument session URL - " . $writerResponseObject->getDocumentUrl() . "\n";
                        echo "\nDocument save URL - " . $writerResponseObject->getSaveUrl() . "\n";
                        echo "\nDocument delete URL - " . $writerResponseObject->getDocumentDeleteUrl() . "\n";
                        echo "\nDocument session delete URL - " . $writerResponseObject->getSessionDeleteUrl() . "\n";
                    } elseif ($writerResponseObject instanceof InvalidConfigurationException) {
                        echo "\nInvalid configuration exception." . "\n";
                        echo "\nError Code - " . $writerResponseObject->getCode() . "\n";
                        echo "\nError Message - " . $writerResponseObject->getMessage() . "\n";
                        if ( $writerResponseObject->getKeyName() ) {
                            echo "\nError Key Name - " . $writerResponseObject->getKeyName() . "\n";
                        }
                        if ( $writerResponseObject->getParameterName() ) {
                            echo "\nError Parameter Name - " . $writerResponseObject->getParameterName() . "\n";
                        }
                    } else {
                        echo "\nRequest not completed successfully\n";
                    }
                }
            }
        } catch (Exception $error) {
            echo "\nException while running sample code: " . $error . "\n";
        }
    }

    public static function initializeSdk() {
        // Replace email address associated with your apikey below
        $user = new UserSignature("john@zylker.com");
        # Update the api domain based on in which data center user register your apikey
        # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html
        $environment = DataCenter::setEnvironment("https://api.office-integrator.com", null, null, null);
        # User your apikey that you have in office integrator dashboard
        $apikey = new APIKey("2ae438cf864488657cc9******”, Constants::PARAMS);
        # Configure a proper file path to write the sdk logs
        $logger = (new LogBuilder())
            ->level(Levels::INFO)
            ->filePath("./app.log")
            ->build();
        
        (new InitializeBuilder())
            ->user($user)
            ->environment($environment)
            ->token($apikey)
            ->logger($logger)
            ->initialize();

        echo "SDK initialized successfully.\n";
    }
}

CreateDocument::execute();
?>
Copied//Reference on how to run below sample code: http://zco.to/run-csharp

using System;
using Com.Zoho.Util;
using Com.Zoho.Officeintegrator.V1;
using Com.Zoho;
using Com.Zoho.Dc;
using Com.Zoho.API.Authenticator;
using Com.Zoho.API.Logger;
using static Com.Zoho.API.Logger.Logger;
using System.Collections.Generic;

namespace Documents
{
    class CreateDocument
    {
        static void Main(String[] args)
        {
            try
            {
                // Initializing SDK once is enough. Calling here since code sample will be tested standalone. 
                // You can place SDK initializer code in your application and call once while your application start-up.
                initializeSdk();

                V1Operations sdkOperations = new V1Operations();
                CreateDocumentParameters createDocumentParams = new CreateDocumentParameters();

                DocumentInfo documentInfo = new DocumentInfo();

                documentInfo.DocumentName = "Untilted Document";
                // System time value used to generate unique document every time. You can replace based on your application.
                documentInfo.DocumentId = $"{DateTimeOffset.Now.ToUnixTimeMilliseconds()}";

                createDocumentParams.DocumentInfo = documentInfo;

                UserInfo userInfo = new UserInfo();

                userInfo.UserId = "1000";
                userInfo.DisplayName = "John";

                createDocumentParams.UserInfo = userInfo;

                Margin margin = new Margin();

                margin.Top = "2in";
                margin.Bottom = "2in";
                margin.Left = "2in";
                margin.Right = "2in";

                DocumentDefaults documentDefault = new DocumentDefaults();

                documentDefault.FontSize = 14;
                documentDefault.FontName = "Arial";
                documentDefault.PaperSize = "Letter";
                documentDefault.Orientation = "portrait";
                documentDefault.TrackChanges = "disabled";

                documentDefault.Margin = margin;
                createDocumentParams.DocumentDefaults = documentDefault;

                EditorSettings editorSettings = new EditorSettings();

                editorSettings.Unit = "in";
                editorSettings.Language = "en";
                editorSettings.View = "pageview";
                createDocumentParams.EditorSettings = editorSettings;

                UiOptions uiOptions = new UiOptions();

                uiOptions.ChatPanel = "show";
                uiOptions.DarkMode = "show";
                uiOptions.FileMenu = "show";
                uiOptions.SaveButton = "show";

                createDocumentParams.UiOptions = uiOptions;

                Dictionary<string, object> permissions = new Dictionary<string, object>();

                permissions.Add("collab.chat", false);
                permissions.Add("document.edit", true);
                permissions.Add("review.comment", false);
                permissions.Add("document.export", true);
                permissions.Add("document.print", false);
                permissions.Add("document.fill", false);
                permissions.Add("review.changes.resolve", false);
                permissions.Add("document.pausecollaboration", false);

                createDocumentParams.Permissions = permissions;

                Dictionary<string, object> saveUrlParams = new Dictionary<string, object>();

                saveUrlParams.Add("id", 123456789);
                saveUrlParams.Add("auth_token", "oswedf32rk");

                Dictionary<string, object> saveUrlHeaders = new Dictionary<string, object>();

                saveUrlHeaders.Add("header1", "value1");
                saveUrlHeaders.Add("header2", "value2");

                CallbackSettings callbackSettings = new CallbackSettings();

                callbackSettings.Retries = 2;
                callbackSettings.Timeout = 10000;
                callbackSettings.SaveFormat = "docx";
                callbackSettings.HttpMethodType = "post";
                callbackSettings.SaveUrlParams = saveUrlParams;
                callbackSettings.SaveUrlHeaders = saveUrlHeaders;
                callbackSettings.SaveUrl = "https://domain.com/save.php"); 
// To implement your save callback url, refer here: https://github.com/iampraba/zoi-csharp-sdk-examples/blob/f71b0e1fe3b45052ad1365ec32c3e09a22113aa6/SaveCallbackHandler.cs

                createDocumentParams.CallbackSettings = callbackSettings;

                APIResponse<WriterResponseHandler> response = sdkOperations.CreateDocument(createDocumentParams);
                int responseStatusCode = response.StatusCode;

                if (responseStatusCode >= 200 && responseStatusCode <= 299)
                {
                    CreateDocumentResponse documentResponse = (CreateDocumentResponse)response.Object;

                    Console.WriteLine("Document id - {0}", documentResponse.DocumentId);
                    Console.WriteLine("Document session id - {0}", documentResponse.SessionId);
                    Console.WriteLine("Document session url - {0}", documentResponse.DocumentUrl);
                }
                else
                {
                    InvalidConfigurationException invalidConfiguration = (InvalidConfigurationException)response.Object;
                    string errorMessage = invalidConfiguration.Message;

                    /*long errorCode = invalidConfiguration.Code;
                    string errorKeyName = invalidConfiguration.KeyName;
                    string errorParameterName = invalidConfiguration.ParameterName;*/

                    Console.WriteLine("configuration error - {0}", errorMessage);
                }
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Exception in creating document session url - ", e);
            }
        }

        static Boolean initializeSdk()
        {
            Boolean status = false;

            try
            {
                Apikey apikey = new Apikey("2ae438cf864488657cc975*****”*, Com.Zoho.Util.Constants.PARAMS);
                UserSignature user = new UserSignature("john@zylker.com"); //No I18N
                Logger logger = new Logger.Builder()
                                    .Level(Levels.INFO)
                                    .FilePath("./log.txt") //No I18N
                                    .Build();

                Com.Zoho.Dc.DataCenter.Environment environment = new DataCenter.Environment("", "https://api.office-integrator.com", "", "");

                new Initializer.Builder()
                    .User(user)
                    .Environment(environment)
                    .Token(apikey)
                    .Logger(logger)
                    .Initialize();
                status = true;
            }
            catch (System.Exception e)
            {
                Console.WriteLine("Exception in Init SDK", e);
            }
            return status;
        }
    }
}
Copied#Reference on how to run below sample code: http://zco.to/run-python

from zohosdk.src.com.zoho.exception.sdk_exception import SDKException
from zohosdk.src.com.zoho.user_signature import UserSignature
from zohosdk.src.com.zoho.dc.data_center import DataCenter
from zohosdk.src.com.zoho.api.authenticator.api_key import APIKey
from zohosdk.src.com.zoho.util.constants import Constants
from zohosdk.src.com.zoho.api.logger import Logger
from zohosdk.src.com.zoho import Initializer

from zohosdk.src.com.zoho.officeintegrator.v1 import DocumentInfo, UserInfo, Margin, DocumentDefaults, EditorSettings, \
    UiOptions, CallbackSettings, InvalidConfigurationException
from zohosdk.src.com.zoho.officeintegrator.v1.create_document_parameters import CreateDocumentParameters
from zohosdk.src.com.zoho.officeintegrator.v1.create_document_response import CreateDocumentResponse
from zohosdk.src.com.zoho.officeintegrator.v1.v1_operations import V1Operations

import time


class CreateDocument:

    # Refer API documentation - https://www.zoho.com/officeintegrator/api/v1/zoho-writer-create-document.html
    @staticmethod
    def execute():
        CreateDocument.init_sdk()
        createDocumentParams = CreateDocumentParameters()

        # Optional Configuration - Add document meta in request to identify the file in Zoho Server
        documentInfo = DocumentInfo()
        documentInfo.set_document_name("New Document")
        documentInfo.set_document_id((round(time.time() * 1000)).__str__())

        createDocumentParams.set_document_info(documentInfo)

        # Optional Configuration - Add User meta in request to identify the user in document session
        userInfo = UserInfo()
        userInfo.set_user_id("1000")
        userInfo.set_display_name(“John)

        createDocumentParams.set_user_info(userInfo)

        # Optional Configuration - Add callback settings to configure.
        # how file needs to be received while saving the document
        callbackSettings = CallbackSettings()

        # Optional Configuration - configure additional parameters
        # which can be received along with document while save callback
        saveUrlParams = {}

        saveUrlParams['id'] = '123131'
        saveUrlParams['auth_token'] = '1234'
        # Following $<> values will be replaced by actual value in callback request
        # To know more - https://www.zoho.com/officeintegrator/api/v1/zoho-writer-create-document.html#saveurl_params
        saveUrlParams['extension'] = '$format'
        saveUrlParams['document_name'] = '$filename'
        saveUrlParams['session_id'] = '$session_id'

        callbackSettings.set_save_url_params(saveUrlParams)

        # Optional Configuration - configure additional headers
        # which could be received in callback request headers while saving document
        saveUrlHeaders = {}

        saveUrlHeaders['access_token'] = '12dweds32r42wwds24'
        saveUrlHeaders['client_id'] = '12313111'

        callbackSettings.set_save_url_headers(saveUrlHeaders)

        callbackSettings.set_retries(1)
        callbackSettings.set_timeout(10000)
        callbackSettings.set_save_format("zdoc")
        callbackSettings.set_http_method_type("post")
        callbackSettings.set_save_url(
            "https://domain.com/save.php”)
// To implement your save callback url, refer here: https://github.com/iampraba/zoi-python-sdk-examples/tree/b74e1f5f08ca6841dc5bbf31f2049b66bf2a7d72/save-callback-implementation/Flask

        createDocumentParams.set_callback_settings(callbackSettings)

        # Optional Configuration - Set margin while creating document itself.
        # It's applicable only for new documents.
        margin = Margin()

        margin.set_top("1in")
        margin.set_bottom("1in")
        margin.set_left("1in")
        margin.set_right("1in")

        # Optional Configuration - Set default settings for document while creating document itself.
        # It's applicable only for new documents.
        documentDefaults = DocumentDefaults()

        documentDefaults.set_font_size(12)
        documentDefaults.set_paper_size("A4")
        documentDefaults.set_font_name("Arial")
        documentDefaults.set_track_changes("enabled")
        documentDefaults.set_orientation("landscape")

        documentDefaults.set_margin(margin)
        documentDefaults.set_language("ta")

        createDocumentParams.set_document_defaults(documentDefaults)

        # Optional Configuration
        editorSettings = EditorSettings()

        editorSettings.set_unit("in")
        editorSettings.set_language("en")
        editorSettings.set_view("pageview")

        createDocumentParams.set_editor_settings(editorSettings)

        # Optional Configuration
        uiOptions = UiOptions()

        uiOptions.set_dark_mode("show")
        uiOptions.set_file_menu("show")
        uiOptions.set_save_button("show")
        uiOptions.set_chat_panel("show")

        createDocumentParams.set_ui_options(uiOptions)

        # Optional Configuration - Configure permission values for session
        # based of you application requirement
        permissions = {}

        permissions["document.export"] = True
        permissions["document.print"] = True
        permissions["document.edit"] = True
        permissions["review.comment"] = True
        permissions["review.changes.resolve"] = True
        permissions["document.pausecollaboration"] = True
        permissions["document.fill"] = False

        createDocumentParams.set_permissions(permissions)

        v1Operations = V1Operations()
        response = v1Operations.create_document(createDocumentParams)

        if response is not None:
            print('Status Code: ' + str(response.get_status_code()))
            responseObject = response.get_object()

            if responseObject is not None:
                if isinstance(responseObject, CreateDocumentResponse):
                    print('Document Id : ' + str(responseObject.get_document_id()))
                    print('Document Session ID : ' + str(responseObject.get_session_id()))
                    print('Document Session URL : ' + str(responseObject.get_document_url()))
                    print('Document Session Delete URL : ' + str(responseObject.get_session_delete_url()))
                    print('Document Delete URL : ' + str(responseObject.get_document_delete_url()))
                elif isinstance(responseObject, InvalidConfigurationException):
                    print('Invalid configuration exception.')
                    print('Error Code  : ' + str(responseObject.get_code()))
                    print("Error Message : " + str(responseObject.get_message()))
                    if responseObject.get_parameter_name() is not None:
                        print("Error Parameter Name : " + str(responseObject.get_parameter_name()))
                    if responseObject.get_key_name() is not None:
                        print("Error Key Name : " + str(responseObject.get_key_name()))
                else:
                    print('Document Creation Request Failed')

    @staticmethod
    def init_sdk():
        try:
            # Replace email address associated with your apikey below
            user = UserSignature("john@zylker.com")
            # Update the api domain based on in which data center user register your apikey
            # To know more - https://www.zoho.com/officeintegrator/api/v1/getting-started.html
            environment = DataCenter.Environment("https://api.office-integrator.com", None, None, None)
            # User your apikey that you have in office integrator dashboard
            apikey = APIKey("2ae438cf864488657cc9754a*****”, Constants.PARAMS)
            # Configure a proper file path to write the sdk logs
            logger = Logger.get_instance(Logger.Levels.INFO, "./logs.txt")

            Initializer.initialize(user, environment, apikey, None, None, logger, None)

        except SDKException as ex:
            print(ex.code)


CreateDocument.execute()

Sample Response

Copied{ 
"document_url": "https://api.office-integrator.com/writer/officeapi/v1/documents/d26aa7b8029bf4f8d34c7dd0013939234a6e15dac88646f02a69582375b8da130efffac249d086aae4667dcbcfb7ac1d/edit",
"document_id": "1349", 
"save_url": "https://api.office-integrator.com/writer/officeapi/v1/documents/d26aa7b8029bf4f8d34c7dd0013939234a6e15dac88646f02a69582375b8da130efffac249d086aae4667dcbcfb7ac1d/save", 
"session_id": "d26aa7b8029bf4f8d34c7dd0013939234a6e15dac88646f02a69582375b8da130efffac249d086aae4667dcbcfb7ac1d", 
"session_delete_url": "https://api.office-integrator.com/writer/officeapi/v1/sessions/d26aa7b8029bf4f8d34c7dd0013939234a6e15dac88646f02a69582375b8da130efffac249d086aae4667dcbcfb7ac1d", 
"document_delete_url": "https://api.office-integrator.com/writer/officeapi/v1/documents/1349",
 }