Create With Content

Purpose

To create document with content parameter. The document will be created along with the content that you provided in the request body.

Quick Reference

PropertyValue
MethodPOST
Request URLhttps://{zohoapis_domain}/writer/api/v1/documents
ScopesZohoWriter.documentEditor.ALL, ZohoPC.files.ALL, WorkDrive.files.ALL, WorkDrive.organization.ALL, WorkDrive.workspace.ALL
Rate LimitSee Writer API throttle limits

Parameters

Body Parameters

ParameterData TypeMandatory/OptionalDescription
contentFileMandatoryProvide the required content in your API request body.
filenameStringOptionalSpecify a unique name for the document
passwordStringOptionalIf the provide input content is password protected, then you can specify that password via this parameter.
folder_idStringOptionalSpecify a folder name, if you would like the document to be created in a particular folder or location.
resource_typeStringOptionalSpecify the type of document which needs to be created.
Possible values: fillable/merge/sign

Notes

  • PDF file format is not supported during import.
  • You can also create document with content parameter using this deluge task.
  • For possible errors, refer to error codes.

Curl

Sample Request

Copiedcurl -X POST "https://www.zohoapis.com/writer/api/v1/documents" \
  -H "Authorization: Zoho-oauthtoken <ACCESS_TOKEN>" \
  -F "content=@/path/to/file.docx" \
  -F "filename=imported" \
  -F "resource_type=fillable"

Deluge

Snippet 1: With HTML text

Copiedhtmltext = "<html><body>";
htmltext = htmltext + "<b>First Name:</b> " + "Amelia" + "<br>";
htmltext = htmltext + "<b>Message:</b> " + "Hello World" + "<br>";
htmltext = htmltext + "<b>Address:</b> " + "Chennai,India" + "<br>";
htmltext = htmltext + "<b>Email:</b> " + "amelia@zylker.com" + "<br>";
htmltext = htmltext + "<b>Phone:</b> " + "0987654329" + "<br>";
htmltext = htmltext + "</body></html>";
file1 = htmltext.toFile("demo.html");
paramList = list();
paramMap1 = {"paramName":"content","content":file1};
paramList.add(paramMap1);
writer_response = invokeurl
[
url :"https://zohoapis.com/writer/api/v1/documents"
type :POST
files:paramList
connection:"<connection_name>"
];
info writer_response;
return "";

Snippet 2: With file

Copiedfile = invokeurl
[
url: "https://homepages.inf.ed.ac.uk/neilb/TestWordDoc.doc"
type: GET
];
file_name = "New document";
paramsList = List();
paramsList.add({"paramName":"content", "content":file});
paramsList.add({"paramName":"filename", "content":file_name, "stringPart": "true"});
response = invokeurl [
    url : "https://zohoapis.com/writer/api/v1/documents"
    type :POST
    files: paramsList
    connection: "<connection_name>"
];

Sample Response

Copied{
  "created_time": "2018-05-08T14:04:31Z",
  "role": "OWNER",
  "owner_id": "4579020",
  "parent_folder_id": "ponaz1ba3eac63b1242848a24c7561c5ed9fe",
  "open_url": "https://writer.zoho.com/writer/open/ponazaad72ae3cb0143aca0763ecd5acb87e1",
  "is_favourite": false,
  "document_id": "ponazaad72ae3cb0143aca0763ecd5acb87e1",
  "created_by": “Amelia”,
  "version": "1.0",
  "document_name": "one",
  "modified_time": "2018-05-08T14:04:32Z",
  "preview_url": "https://writer.zoho.com/writer/preview/ponazaad72ae3cb0143aca0763ecd5acb87e1",
  "creator_id": "4579020",
  "download_url": "https://writer.zoho.com/api/v1/download/ponazaad72ae3cb0143aca0763ecd5acb87e1",
  "document_properties": "https://writer.zoho.com/api/v1/documents/ponazaad72ae3cb0143aca0763ecd5acb87e1",
  "lastmodified_by": [
    {
      "email_id": “Amelia@zylker.com”,
      "profile_photo": "https://contacts.zoho.com/file?t=user&ID=4579020&fs=thumb",
      "user_id": "4579020",
      "display_name": “Amelia”
    }
  ]
}