KRYSTAL DMS - Web Services API


KRYSTAL DMS - Premium Edition exposes a REST API which allows for remote execution of many of the system's capabilities. From creating documents to starting a workkflow case, to downloading a document, there are a large number of options which allow fine-grained control of a KRYSTAL DMS instance.

Web Services API URL


Once you have installed KRYSTAL DMS – Premium Edition Version 2022 or later, you will have access to the Web Services API.

Primeleaf team will provide you with the Web Services API URL needed to develop your custom built projects.

You will be able to access the WSDL file using following URL.

https://<Your_Server_IP>:<HTTP_Port>/rest/

 

For example : https://10.1.1.1:8080/rest/

Where

Your_Server_IP is the IP Address or Fully Qualified Domain Name (FQDN) of server where KRYSTAL DMS is installed.

HTTP_Port is the port number on which KRYSTAL DMS is configured to be running.

Web Services API Functionalities


The KRYSTAL DMS API supports a subset of the functionalities of the KRYSTAL DMS - Premium Edition user interface as outlined below.

# Request Type URL Response Content Type Description
1 POST /signon application/json Sign On
2 GET /signout application/json Sign Out
3 GET /documentclasses application/json Get Document Classes
4 GET /documentclasses/{classid}/documents application/json Get Documents of a Class
5 GET /documentclasses/{classid}/search application/json Search Documents of a Class
6 POST /documentclasses/{classid}/indexsearch application/json Search Documents by Document Indexes
7 PUT /documentclasses/{classid}/documents application/json Create Document
8 GET /documents/{documentid} application/json Get Document Details
9 GET /documents/{documentid}/{revisionid} application/json Get Document Revision Details
10 GET /documents/download/{documentid} application/json Download Document
11 GET /documents/download/{documentid}/{revisionid} application/json Download Document Revision
12 GET /documents/checkout/{documentid} application/json Checkout Document
13 POST /documents/checkin/{documentid} application/json Check In
14 GET /documents/cancelcheckout/{documentid} application/json Cancel Checkout
15 GET /documents/indexes/{documentid}/{revisionid} application/json Get Document Indexes
16 POST /documents/indexes/{documentid}/{revisionid} application/json Update Document Indexes
17 GET /documents/thumbnail/{documentid}/{revisionid} application/json Get Document Thumbnail
18 DELETE /documents/{documentid} application/json Delete Document
19 GET /documents/revisionhistory/{documentid} application/json Get Revision History
20 GET /documents/accesshistory/{documentid} application/json Get Access History

KRYSTAL DMS - Web Services API calls


1. Sign On


Parameters

Parameter Parameter Type Data Type
username formData string
password formData string

Curl

curl  -d username=username -d password=password https://localhost/rest/signon 

Request URL

https://localhost/rest/signon 

Response

{
	"errorCode":0,
	"errorMessage":"",
	"authToken":"8E6A0B55-5FFA-4A0F-B485-9FEC70D7CA87" //Auth Token
}

2. Sign Out


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/signout

Request URL

https://localhost/rest/signout 

Response

{
	"errorCode":0,
	"loggedOut":true
}

3. Get Document Classes


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documentclasses

Request URL

https://localhost/rest/documentclasses 

Response

{
	"errorCode":0,
	"availableClasses":[
		{
			"accessType":"P",
			"activeDocuments":14,
			"allowedExtensions":"",
			"classDescription":"Demo Document Types",
			"classId":15,
			"className":"DEMO",
			"created":"2020-05-27 13:32:41.784775",
			"dataTableName":"Z0000015",
			"documentIndexes":
				[
					{
						"id":15,
						"indexDescription":"Document Title",
						"indexName":"TITLE",
						"indexType":"S",
						"mandatory":false,
						"operator":0,
						"sequence":1,
						"unique":false
					},
					...
					...
				],
			"documentLimit":2147483647,
			"expiryNotificationPeriod":7,
			"expiryPeriod":0,
			"importLocation":"",
			"importType":"I",
			"indexCount":1,
			"indexId":15,
			"indexTableName":"I0000015",
			"maximumFileSize":26214400,
			"revisionControlEnabled":true,
			"storageLocation":"DEFAULT",
			"storageType":"RDBMS",
			"totalDocuments":15,
			"uniqueFileNamesOnly":false,
			"userName":"ADMINISTRATOR",
			"visible":true
		},
		...
		...
	]
}

4. Get Documents


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documentclasses/{classid}/documents

Request URL

https://localhost/rest/documentclasses/{classid}/documents 

Response

{
	"errorCode":0,
	"documents":[
		{
			"accessCount":0,
			"classId":15,
			"created":"2020-06-11 17:33:05.422958",
			"createdBy":"ADMINISTRATOR",
			"documentId":204,
			"documentType":"PDF",
			"extension":"PDF",
			"fileName":"Payment_Vouchers_114_1_0.PDF",
			"hasNote":0,
			"indexes":[
				{
					"id":0,
					"indexDescription":"Document Title",
					"indexName":"TITLE",
					"indexType":"S",
					"mandatory":false,
					"operator":0,
					"sequence":0,
					"unique":false,
					"value1":"PDF Document"
				},
				...
				...
			],
			"lastAccessed":"2020-06-11 17:33:05.31",
			"length":930181,
			"modified":"2020-06-11 17:33:05.31",
			"modifiedBy":"ADMINISTRATOR",
			"revisionId":"1.0",
			"score":0.0,
			"status":"I"
		},
		...
		...
	]
}

Parameters

Parameter Parameter Type Data Type
searchText queryString string

Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documentclasses/{classid}/search?searchText=KRYSTAL

Request URL

https://localhost/documentclasses/{classid}/search?searchText=[searchText]

Response

{
	"errorCode":0,
	"documents":[
		{
			"accessCount":0,
			"classId":15,
			"created":"04-Jun-2020 11:59",
			"createdBy":"ADMINISTRATOR",
			"documentId":191,
			"documentType":"",
			"expiry":"",
			"extension":"",
			"fileName":"VeryBigImage.jpg",
			"hasNote":0,
			"indexes":[
				{
					"id":0,
					"indexDescription":"Document Title",
					"indexName":"TITLE",
					"indexType":"S",
					"mandatory":false,
					"operator":0,
					"sequence":0,
					"unique":false,
					"value1":"DEMO for KRYSTAL DMS"
				},
				...
				...
			],
			"lastAccessed":"04-Jun-2020 11:59",
			"length":0,
			"modified":"04-Jun-2020 11:59",
			"modifiedBy":"ADMINISTRATOR",
			"revisionId":"1.0",
			"score":2.5261518955230713,
			"status":""
		},
		...
		...
	]
}

Parameters

Parameter Value Parameter Type Data Type
documentIndexes
[
	{
		"indexName":"INDEXNAME",
		"value1":"Search Text"
		"operator" : 1
	},
	...
	...
]
					
Operator Values:
1 - Is
2 - Is Not
3 - Like
4 - Not Like
5 - Is Greater Than
6 - Is Lesser Than
7 - Between
8 - Is Empty
9 - Is Not Empty
body application/json

Curl

curl -H "Authorization:Auth Token" -X "POST" -H "Content-Type: application/json" -d " {\"documentIndexes\" : [ { \"indexName\":\"INDEXNAME\", \"value1\":\"SEARCHTEXT\" , \"operator\":1 }, {...} ] } " https://localhost/rest/documentclasses/15/indexsearch

Request URL

https://localhost/rest/documentclasses/{classid}/indexsearch 

Response

{
	"errorCode":0,
	"documents":[
		{
			"accessCount":0,
			"classId":15,
			"created":"2020-06-04 11:59:11.689377",
			"createdBy":"ADMINISTRATOR",
			"documentId":191,
			"documentType":"JPG",
			"extension":"JPG",
			"fileName":"VeryBigImage.jpg",
			"hasNote":0,
			"indexes":[
				{
					"id":0,
					"indexDescription":"Document Title",
					"indexName":"TITLE",
					"indexType":"S",
					"mandatory":false,
					"operator":0,
					"sequence":0,
					"unique":false,
					"value1":"DEMO for KRYSTAL DMS"
				}
			],
			"lastAccessed":"2020-06-25 11:23:11.618",
			"length":3906836,
			"modified":"2020-06-25 11:23:11.618",
			"modifiedBy":"ADMINISTRATOR",
			"revisionId":"1.0",
			"score":0.0,
			"status":"I"
		},
		...
		...
	]
}

7. Create Document


Parameters

Parameter Value Parameter Type Data Type
createDocumentRequest
{					
	"documentIndexes" :[
		{
			"indexName":"INDEXNAME",
			"value1":"Search Text"
			
		},
		...
		...
	],
	"fileName" : "actual file name",
	"fileBytes" : "BASE64EncodedFileContent",
	"expiryDate" : "31-Dec-2099",
	"comments" : "comments",
	"attachments" : [
		{
			"fileName" : "attachement file name",
			"fileBytes" : "BASE64EncodedFileContent",
			"title" : "attachment title",
			"keywords" : "attachment keywords"
		},
		...
		...
	]
}
					
body application/json

Curl

curl -H "Authorization:Auth Token" -X "PUT" -H "Content-Type: application/json" -d " {\"documentIndexes\" : [ { \"indexName\":\"INDEXNAME\", \"value1\":\"INDEX VALUE\"  },{...}], \"fileName\" : \"sample.txt\" , \"fileBytes\" : "VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IGZpbGU=",\"expiryDate\" : \"31-Dec-2020\", \"comments\" : \"Document Create Comments\" } " https://localhost/rest/documentclasses/15/documents

Request URL

https://localhost/rest/documentclasses/{classid}/documents 

Response

{
	"errorCode":0,
	"documentId":NNNNNN,
	"documentCreated":true
}

8. Get Document Details


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/{documentid}

Request URL

https://localhost/rest/documents/{documentid} 

Response

{
	"errorCode":0,
	"documentDetails":{
		"accessCount":2,
		"classId":15,
		"created":"2020-06-04 11:59:11.689377",
		"createdBy":"ADMINISTRATOR",
		"documentId":191,
		"documentType":"IMAGE",
		"expiry":"",
		"extension":"JPG",
		"fileName":"VeryBigImage.jpg",
		"hasNote":0,
		"indexes":[
			{
				"id":15,
				"indexDescription":"Document Title",
				"indexName":"TITLE",
				"indexType":"S",
				"mandatory":false,
				"operator":0,
				"sequence":0,
				"unique":false,
				"value1":"DEMO for KRYSTAL DMS"
			},
			...
			...
		],
		"lastAccessed":"2020-06-23 14:33:23.89",
		"length":3906836,
		"modified":"2020-06-04 11:59:11.689",
		"modifiedBy":"ADMINISTRATOR",
		"revisionId":"1.0",
		"score":0.0,
		"status":"I"
	}
}

9. Get Document Revision


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/{documentid}/{revisionid}

Request URL

https://localhost/rest/documents/{documentid}/{revisionid}

Response

{
	"errorCode":0,
	"documentDetails":{
		"accessCount":2,
		"classId":15,
		"created":"2020-06-04 11:59:11.689377",
		"createdBy":"ADMINISTRATOR",
		"documentId":191,
		"documentType":"IMAGE",
		"expiry":"",
		"extension":"JPG",
		"fileName":"VeryBigImage.jpg",
		"hasNote":0,
		"indexes":[
			{
				"id":15,
				"indexDescription":"Document Title",
				"indexName":"TITLE",
				"indexType":"S",
				"mandatory":false,
				"operator":0,
				"sequence":0,
				"unique":false,
				"value1":"DEMO for KRYSTAL DMS"
			},
			...
			...
		],
		"lastAccessed":"2020-06-23 14:33:23.89",
		"length":3906836,
		"modified":"2020-06-04 11:59:11.689",
		"modifiedBy":"ADMINISTRATOR",
		"revisionId":"1.0",
		"score":0.0,
		"status":"I"
	}
}

10. Download Document


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/download/{documentid}

Request URL

https://localhost/rest/documents/download/{documentid} 

Response

{
	"errorCode":0,
	"documentFile": BASE64EncodedFileContent
} 	 	

11. Download Document Revision


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/download/{documentid}/{revisionid}

Request URL

https://localhost/rest/documents/download/{documentid}/{revisionid}

Response

{
	"errorCode":0,
	"documentFile":BASE64EncodedFileContent
} 	 	

12. Checkout Document


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/checkout/{documentid}

Request URL

https://localhost/rest/documents/checkout/{documentid} 

Response

{
	"errorCode":0,
	"documentFile": BASE64EncodedFileContent
} 	 	

13. Check In Document


Parameters

Parameter Value Parameter Type Data Type
checkInDocumentRequest
{					
	"documentIndexes" :[
		{
			"indexName":"INDEXNAME",
			"value1":"INDEX VALUE"
			
		},
		...
		...
	],
	"fileName" : "actual file name",
	"fileBytes" : "BASE64EncodedFileContent",
	"expiryDate" : "31-Dec-2099",
	"comments" : "comments",
	"majorVersion" : true
	
}
					
body application/json

Curl

curl -H "Authorization:Auth Token" -X "POST" -H "Content-Type: application/json" -d " {\"documentIndexes\" : [ { \"indexName\":\"INDEXNAME\", \"value1\":\"INDEX VALUE\"  }], \"fileName\" : \"sample.txt\" , \"fileBytes\" : "VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IGZpbGU=",\"expiryDate\" : \"31-Dec-2022\", \"comments\" : \"Check In Comments \", \"majorVersion\": false } https://localhost/rest/documents/checkin/{documentid}

Request URL

https://localhost/rest/documents/checkin/{documentid} 

Response

{
	"errorCode":0,
	"checkIn":true
}

14. Cancel Document Checkout


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/cancelcheckout/{documentid}

Request URL

https://localhost/rest/documents/cancelcheckout/{documentid}

Response

{
	"errorCode":0,
	"cancelCheckout":true
}

15. Get Document Indexes


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/indexes/{documentid}/{revisionid}

Request URL

https://localhost/rest/documents/indexes/{documentid}/{revisionid}

Response

{
	"errorCode":0,
	"indexes":[
		{
			"id":15,
			"indexDescription":"Document Title",
			"indexName":"TITLE",
			"indexType":"S",
			"mandatory":false,
			"operator":0,
			"sequence":0,
			"unique":false,
			"value1":"DEMO for KRYSTAL DMS"
		},
		...
		...
	]
}

16. Update Document Indexes


Parameters

Parameter Value Parameter Type Data Type
documentIndexes
[
	{
		"indexName":"INDEXNAME",
		"value1":"New Value"
	},
	...
	...
]
					
body application/json

Curl

curl -H "Authorization:Auth Token" -X POST -H "Content-Type: application/json" -d " {\"documentIndexes\" : [ { \"indexName\":\"INDEXNAME\", \"value1\":\"New Value\" },{...} ] } " https://localhost/rest/documents/indexes/{documentid}/{revisionid}

Request URL

https://localhost/rest/documents/indexes/{documentid}/{revisionid}

Response

{
	"errorCode":0,
	"indexUpdated":true
}

17. Get Document Thumbnail


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/thumbnail/{documentid}/{revisionid}

Request URL

https://localhost/rest/documents/thumbnail/{documentid}/{revisionid}

Response

{
	"errorCode":0,
	"documentThumbNailFile":[-119,80,78,71,13,10,26,10,0,0,0,13,73,72,68,8, ... , ...]
}

18. Delete Document


Curl

curl -H "Authorization:Auth Token" -X "DELETE: https://localhost/rest/documents/{documentid}

Request URL

https://localhost/rest/documents/{documentid} 

Response

{
	"errorCode":0,
	"documentDeleted":true
}

19. Document Revision History


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/revisionhistory/{documentid}

Request URL

https://localhost/rest/documents/revisionhistory/{documentid}

Response

{
	"errorCode":0,
	"documentRevisionHistory":[
		{
			"comments":"Document checked-in successfully.",
			"dateTime":"2020-06-15 17:10:27.42569",
			"documentId":184,
			"revisionId":"2.0",
			"userAction":"CHECKED IN",
			"userName":"ADMINISTRATOR"
		},
		{
			"comments":"Document checked out",
			"dateTime":"2020-06-15 17:09:42.517597",
			"documentId":184,
			"revisionId":"1.0",
			"userAction":"CHECKED OUT",
			"userName":"ADMINISTRATOR"
		},
		...
		...
	]
}

20. Document Access History


Curl

curl -H "Authorization:Auth Token" https://localhost/rest/documents/accesshistory/{documentid}

Request URL

https://localhost/rest/documents/accesshistory/{documentid}

Response

{
	"errorCode":0,
	"documentAccessHistory":[
		{
			"action":"Deleted",
			"actionDate":"2020-06-24 17:07:51.245084",
			"comments":"REST WS API",
			"ipAddress":"127.0.0.1",
			"objectId":191,
			"objectType":"D",
			"parameters":"Document ID  191 deleted",
			"userName":"ADMINISTRATOR"
		},
		{
			"action":"Accessed",
			"actionDate":"2020-06-09 12:04:41.887051",
			"comments":"Document : VeryBigImage.jpg accessed",
			"ipAddress":"127.0.0.1",
			"objectId":191,
			"objectType":"D",
			"parameters":"",
			"userName":"ADMINISTRATOR"
		},
		...
		...
		...
	]
}