- Overview
- How it works?
- Getting Started
- Developer reference
- Zoho Writer
- Zoho PDF Editor
- Zoho Sheet
- Zoho Show
- GETPlan details
- Errors
- Manage Office Integrator
- Pricing
- How-to Guides
Document Sessions
Purpose
To get the list of active sessions for a particular document.
HTTP Request URL
https://{api.office-integrator_domain}/writer/officeapi/v1/documents/<document_id>/sessions?apikey=<apikey>
Request Parameters
Parameter | Data Type | Description |
Mandatory Parameters | ||
apikey | String | Uniquely identifies the web application in which the Writer editor is integrated. |
document_id | String | Unique id of the document. |
Sample Request
Copiedhttps://api.office-integrator.com/writer/officeapi/v1/documents/1349/sessions?apikey=423s*****
Copiedimport * as SDK from "@zoho-corp/office-integrator-sdk";
class GetAllSessions {
static async execute() {
//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.
await this.initializeSdk();
try {
var sdkOperations = new SDK.V1.V1Operations();
var createDocumentParameters = new SDK.V1.CreateDocumentParameters();
var createResponse = await sdkOperations.createDocument(createDocumentParameters);
var documentId = createResponse.object.getDocumentId();
console.log("\nCreated a new document to demonstrate get all session details api. Created document ID - " + documentId);
var responseObject = await sdkOperations.getAllSessions(documentId);
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){
//TODO: Need to fix object type issue
if(writerResponseObject instanceof SDK.V1.AllSessionsResponse ){
console.log("\nDocument ID - " + writerResponseObject.getDocumentId());
console.log("\nDocument Name - " + writerResponseObject.getDocumentName());
console.log("\nDocument Type - " + writerResponseObject.getDocumentType());
console.log("\nDocument Created Time - " + writerResponseObject.getCreatedTime());
console.log("\nDocument Created Timestamp - " + writerResponseObject.getCreatedTimeMs());
console.log("\nDocument Expiry Time - " + writerResponseObject.getExpiresOn());
console.log("\nDocument Expiry Timestamp - " + writerResponseObject.getExpiresOnMs());
var sessions = writerResponseObject.getSessions() || [];
for (let index = 0; index < sessions.length; index++) {
const session = sessions[index];
if (session instanceof SDK.V1.SessionMeta) {
console.log("\nSession Status - " + session.getStatus());
console.log("\nSession URL - " + session.getInfo().getSessionUrl());
console.log("\nSession User ID - " + session.getUserInfo().getUserId());
console.log("\nSession Display Name - " + session.getUserInfo().getDisplayName());
}
}
} 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", "2ae438cf864488657cc975********") //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.");
}
}
GetAllSessions.execute();
Show full
Show less
Sample Response
Copied{
"document_id" : "1349",
"active_sessions_count" : "2" ,
"document_name" : "New",
"document_type" : "document/merge_template/fillable_template",
"created_time": "2022-08-04T07:30:00Z",
"created_time_ms": "1659578400000",
"expires_on": "2022-08-04T13:34:00Z",
"expires_on_ms": "1659600270000",
"sessions":[
{
"status" : "active/inactive"
"user_info": {
"display_name":"Amelia",
"user_id":"123"
}
"info": {
"document_id": "1349",
"created_time_ms": "1659578400000",
"created_time": "2022-08-04T07:30:00Z",
"expires_on_ms": "1659600270000",
"expires_on": "2022-08-04T13:34:00Z",
"session_url": "https://api.office-integrator.com/writer/officeapi/v1/documents/<session_id>/edit",
"session_delete_url":"https://api.office-integrator.com/writer/officeapi/v1/sessions/<session_id>"
}
}
{
.......
}
]
}
Show full
Show less
© 2025, Zoho Corporation Pvt. Ltd. All Rights Reserved.