Straatos Adapter Service API
This articles describes Straatos Adapter Service API
The Adapter Service is an extension of the Straatos Workflow, designed to enhance script service APIs and Interact APIs by providing built-in functionalities. This eliminates the need for developers to implement certain features manually, allowing for a more efficient development process.
Key Features:
Enhances API capabilities without additional development effort.
Provides pre-built methods that can be used in Interact APIs and Script APIs.
Simplifies workflow integration by handling complex operations within Straatos.
How It Works:
Developers can access adapter service methods within their script APIs or interact API.
These methods can be used for data transformation, external system communication, and automation.
The adapter service helps streamline workflow automation and integration with minimal coding.
Methods
Below is a list of functionalities provided by Straatos platform.
Retrieves the information about the document or task.
This method incorporates an ImageMagick wrapper into the straatos data architecture. ImageMagick allows you to generate, edit, compose and convert digital photos. To learn more about the services that ImageMagick can provide, refer to https://imagemagick.org/.
Use this method to add a comment to the specific document identified by the documentId. DocumentId is the unique identifier for a document. The current Document ID is used as the default value.
Determine the presence of the Swiss flag and human faces on images/identity cards.
Add additional files to an existing document.
Add additional files to an existing document from a specified path.
Remove additional data from a document.
Detect barcodes on specific document page identified by the documentId.
Detect barcodes in a document, using a newer and faster engine (optionally specified by documentId)
Retrieves account information for specific account id.
Retrieves all account information in an organisation.
Retrieves information about all accounts managed by a specific manager.
Determines whether an image contains a face, which can be useful when processing passports or identification cards.
Divide a single document into two separate documents.
Combine two documents into a single document.
Deletes a page from a document permanently. Once deleted, there is no method to recover a document!
Converts an HTML input to a PDF file. It is possible to generate an Audit Report and attach it to a document.
It generates a zip archive.
Unzips a zipped document associated with a task and adds the zip file's contents as additional data.
Convert a PDF document to a multipage TIFF or a collection of JPG images and add as additional data. This function returns a URL that points to the first image.
Create a searchable pdf file containing the results of a JSON file. This provided URL is:
Local URL:
It only contains the filename and retrieved from the CumuluPpro storage.
Full URL:
It contains the entire URL, beginning with HTTP.
Create a PDF document from a collection of PDF files and/or images. Provides a URL to the generated PDF.
Configure a Straatos Error. Once configured, the Straatos Task generates an Error Event and displays the Error Message in the Monitor.
Access to a document stored within Straatos is granted using one of two methods:
Time-based restriction.
Access count restriction.
Create a new user account.
Retrieve information about an existing account.
Update a user's account information.
Delete a user account.
Start a new task in a workflow.
Retrieves a file either as a string or as a Base64 file based on a provided URL to the file.
List all of the roles and functions of the current organisation.
Get Document Info
Input Parameters
DocumentId
Optional
DocumentId is the unique identifier for a document. The current Document ID is used as the default value.
Sample Request Body
Response Parameters
id
The unique identifier to obtain information about a document.
region
The S3 region is used for storage.
originalURL
When available, the original URL of the uploaded document will be displayed.
documentPages
A list of documentPages. This list contains the following fields:
lastModifiedDateTime
DateTime when the document was last updated.
Comments
A list of comments. This list contains the following fields:
timestamp
When the comment was entered.
comment
The actual comment.
additionalData
A list of all the additional data. This list contains the following fields:
width
The width of the original document. Set the value of GetDimensions to true.
height
The height of the original document. Set the value of GetDimensions to true.
Magick
Input Parameters
DocumentId
documentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
Command
The imageMagick command to execute; by default, convert is used.
InputAdditionalDataKey
If not null then the input file will be the additional file identified by the data key to use. If empty, then use the original URL (or if empty, preview URL) on a page level.
OutputAdditionalDataKey
Do not return the output URL but store the output as additional data. If this additional data key already exists, the new version will overwrite it.
OutputFormat
If the information is true, the result will contain the redirected output of the command rather than the URL of the output image. Another possible value is JSON, which results in the return of a JSON document containing all processed parameters.
ReturnOutput
if true and OutputFormat is not info, then '-' is appended.
OutputExtension
PageIndex
Indicates the page number to be used (zero-based).
Parameters
Parameters to pass to the imageMagick call.
Sample Code
Sample Response
The following response is snippet of the actual result. It can either be JSON with output of imageMagick, or URL of resulting image.
Add Document Comment
Input Parameters
DocumentId
DocumentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
Comment
The text of the comment.
CommentTimestamp
The (optional) timestamp should be stored with the comment. If the date/time field is left blank, the current date/time will be used.
AuthAccountId
The id of the CumulusPro account.
LoginName
This information will be stored in the Comment table, with the LoginName displayed during Web validation.
Name
This information will be stored in the Comment table, with the row name displayed during Web validation.
Sample Code
Sample Response
Upon success, response body contains an empty string (“”).
Image Detect
Input Parameters
DocumentId
DocumentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
InputAdditionalDataKey
When set, use an additionalData file as input, otherwise use OriginalUrl (or, if empty, the preview URL on page level)
PageIndex
0-based pageIndex of the page to use.
EnableFaceDetection
When returning the execution result, this parameter specifies whether or not face detection should be considered
EnableLandmarkDetection
Specifies whether face landmark detection should be performed to determine whether the face is forward/upright and to validate the result of the face detection.
MinimumMatchingScore
This value specifies the minimum matching score that should be used when identifying the flag pattern.
Output Status
-1
If there is an error while parsing command line arguments or any file fails to load/save
0
If there is a global negative match
1
If there is a global positive match
Sample Output JSON
FaceDetectionEnabled
Indicates whether face detection was enabled.
LandmarkDetectionEnabled
Indicates whether landmark detection was enabled.
FaceFound
Indicates whether a face was discovered in the document's image.
FlagFound
Indicates whether or not the flag pattern was correctly identified.
FlagScore
The resulting score for identifying flag patterns.
Doc...
- 4 point coordinate for the document boundaries on the input image.
Face...
- 4 point coordinate for the face boundaries on the input image.
Flag...
- 4 point coordinate for the flag pattern boundaries on the input image.
Sample Code
Sample Response
Add Additional Data
Input Parameters
DocumentId
DocumentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
FormData
The actual content of the data file.
Extension
The extension (=filetype) of the file to store.
Key
AdditionalData is stored under this key.
Sample Code
Result
Upon success, response body contains an empty string (“”).
Add Additional Data with URL
This method is preferred over AddAdditionalData, because it does not load the whole file in memory.
Sample Code
Result
On success, the response body contains an empty string (“”).
Remove Additional Data
Sample Code
Detect Barcodes
This is an older version of the Detect Barcodes. It is still recommend that you use Detect Barcodes V2.
In most cases, no additional parameters are needed. If no parameters are defined, the engine will try to detect all Barcodes on the Original Document of the current Document.
Input Parameters
DocumentId
DocumentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
Faster
When enabled, an algorithm makes additional attempts to locate a disable barcode. This is an optional value.
Formats
[Optional] The barcode format to look for. Possible values are: 2D Barcodes:
QR.
MicroQR.
DATA_MATRIX.
PDF417.
1D Barcodes.
CODABAR.
CODE_39.
EAN8.
EAN_13.
ITF.
UPC_A.
UPC_E.
PdfMatchPattern
[Optional] Regular expression to match. Only works if the original document is a PDF. This is an optional value.
PageIndexes
The 0-based pageIndex(es) of the pdf document to which barcodes should be detected. To specify multiple pages, use a comma to separate indexes (,). This is an optional value.
The earlier version of barcode engine (pre July 2021) is still available and can be used with the following function straatos.adapter.detectBarcodes
Sample Code
Sample Response
Detect Barcodes V2
Input Parameters
DocumentId
DocumentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
PageIndexes
An array of the page(s) that should be scanned. The pages should be defined as 0-based index numbers.
Formats
An array of barcode format(s) to look for. Possible values are:
QR.
MicroQR.
DATA_MATRIX.
PDF417.
CODABAR.
CODE_39.
EAN_8.
EAN_13.
ITF.
UPC_A.
UPC_E.
GdPicture options:
Industrial2of5.
Inverted2of5.
Inverted2of5.
Interleaved2of5.
Iata2of5.
Matrix2of5.
Code39.
Codeabar.
BcdMatrix.
DataLogic2of5.
Code128.
CODE93.
EAN13.
UPCA.
EAN8.
UPCE.
ADD5.
ADD2.
Sample Code
Get Account
Input Parameters
id
The id of the account (AuthAccount)
Response Parameters
The response body contains an object with the following properties:
Id
The id of the account
ManagerAuthAccountId
The (optional) id of the user's manager as configured in Admin Panel
LoginName
The login name (email address)
Name
The (optional) name as configured in Admin Panel
UserIdentifier
The (optional) user identifier as configured in Admin Panel
Roles
A array of roles, each with its own Id, Name, and Functions (array of functions containing Id, Name)
Sample Code
Sample Response
List Accounts For Organization
Sample Code
Sample Response
Response body contains an array of objects with properties as detailed under Get Account section.
List Accounts For Manager
Input Parameters
managerId
The id of the manager's account
Sample Code
Sample Response
Response body contains an array of objects with properties as detailed under Get Account.
Face Detection
This method detects whether image contains face, for example, processing of passports and identification cards. Also able to rotate image to an upright posture in relation to the image and crop the document if the background is white.
The FaceDetection module requires a jpg as an input image.
Input Parameters
DocumentId
DocumentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
InputAdditionalDataKey
When set, an additionalData file is used as input; otherwise, OriginalUrl is used (or, if empty, the preview URL on page level)
CroppingMargin
Specifies the margin which is to be left for cropping
Threshold
Threshold value
EdgeRatio
Ratio of the edges
NoiseRatio
Noise Ratio
Sample Code
Sample Response
The result is a processed image (turned upright and cropped) as well as JSON containing whether face was found, document was detected, coordinates where document was detected, coordinates where face was detected as well as score of the face:
Split Document
Split a document into two documents. Original documents will contain first pages, newly created second document will contain all documents have pageIndex >= specified PageIndex. After document is split, MessageWorkflow call to newly created document should be done to allow further processing of document by the Straatos engine.
Input Parameters
WorkflowInstanceId
The effective workflowInstanceId belonging to the documentId
PageIndex
0-based index on where to split the document. All pages >= PageIndex will be part of the new documentId
CopyFieldValues
When true, the new document will have variable values of the original document.
Upon success, a JSON with the following fields is returned:
DocumentId
The DocumentId belonging to the newly created document.
Sample Code
Sample Response
Merge Documents
Input Parameters
DocumentId1
The documentId of the first document
DocumentId2
The documentId of the second document
WorkflowInstanceId2
The WorkflowInstanceId was known by the straatos engine of the second documentId
Sample Code
Result
If successful, response body will contain “ok”, and “error” when not successful.
Delete Document Page
DocumentId
DocumentId is the unique identifier for a document. This is an optional parameter. (default: _documentId)
PageIndex
0-based index of the page to delete.
Sample Code
Result
If successful, the response body contains an empty string (“”).
Html To Pdf
Input Parameters
DocumentId
The unique identifier of the document for which the PDF should be created.
PageSize
The PDF page size (for example A4).
OutputAdditionalDataKey
The Additional Data Key in which the document can be found. For example 'pdf-audit'.
PrependPDFUrl
You can specify either PrependPDFUrl or PrependPDFAdditionalData (key). This field must point to an existing PDF file. The PDF will be prepended with the new HTML-generated PDF. Intended for use in creating cover pages for pre-existing documents.
PrependPDFAdditionalData
You can specify either PrependPDFUrl or PrependPDFAdditionalData (key). This field must point to an existing PDF file. The PDF will be prepended with the new HTML-generated PDF. Intended for use in creating cover pages for pre-existing documents.
AppendPDFUrl
You can specify either AppendPDFUrl or AppendPDFAdditionalData (key). This field must point to an existing PDF file. The PDF will be appended to the new HTML-based PDF. Ideal for creating audit trails and exporting documents that are attached to an existing document.
AppendPDFAdditionalData
You can specify either AppendPDFUrl or AppendPDFAdditionalData (key). This field must point to an existing PDF file. The PDF will be appended to the new HTML-based PDF. Ideal for creating audit trails and exporting documents that are attached to an existing document.
AppendPDFAdditionalData
You can specify either AppendPDFUrl or AppendPDFAdditionalData (key). This field must point to an existing PDF file. The PDF will be appended to the new HTML-based PDF. Ideal for creating audit trails and exporting documents that are attached to an existing document.
Landscape
Boolean, If the value is not set or is false, the value is Portrait.
HTML
The HTML code of the file.
Margin
If empty, the default value is 36.
The Example code below fetches users who have participated in User Task (for example, Approval). It then generates HTML code that includes a table with the date, username, and process step information. Finally, HTMLtoPDF function produces PDF and adds extra Data to Task. The code returns the document’s URL.
Output PDF looks like this:

Sample Code
Result
PDF is attached as additional Data and URL to PDF.
Set Document Restriction
Input Parameters
Url
The URL to the document to grant access to.
MinutesFromNow
The duration of access to the document in minutes. The number of minutes that have passed since the script was run (not from the creation of the task).
AccessCount
You can specify either PrependPDFUrl or PrependPDFAdditionalData (key). This field must point to an existing PDF file. The PDF file will be prepended with the new HTML-based PDF. Intended for use in creating cover pages for pre-existing documents.
Sample Code
The following code shows how to test access toa document. In the first part, the URL for additionalData file 'test-xml' is retrieved. Then, script tries to access documents without granting access, resulting in 'Fail. Script then allows access to document once and then tests access again, indicating that access is now granted.
Zip
Input Parameters
AdditionalDataKey
The additionalData is placed under this key (not the URL)
Files
A File array. Each object in the array should be a JSON object containing 2 (out of possible 3) keys:
Filename - The name of the file that should be included in the zip.
SourceURL - The URL to the document to be added.
UTF8Content.
DocumentId
Optional, if not specified the current document will be used.
TimeOutMs
Optional timeout in Milliseconds, If no timeout value is specified, the default value of 90 seconds is used.
Sample Code
The following code adds file from additional Data to ZIP file named 'zip'
Unzip
Input Parameters
AdditionalDataPrefix
Prefix for each additional data entry created from the zip file
AdditionalDataKey
The Key of the additionalData where the ZIP file is stored
DocumentId
Optional, if not specified the current document will be used.
IgnoreDirectoryInfo
Ignore the directory information in the ZIP file as an option. If it is true, all entries in the additional data key will be extracted without path information. The default value is false.
IncludeHiddenFiles
Optional option to include files that have a name string with '.'. The default value is false.
TimeoutMs
Optional timeout in Milliseconds, if no timeout value is specified, the default value of 90 seconds is used.
Sample Code
The following code extracts data from zip file and adds data as additional data with prefix 'Unzip-'.
Pdf To Image
Input Parameters
EndpageNumber
End (1 based) page number. The default value is 0, which includes all pages. This is an optional parameter.
JPGQuality
An optional value between 0-100. Default is 40.
DocumentId
If not specified, the current document will be used. This is an optional parameter.
OutputAdditionalDataKeyPrefix
Optional prefix for the generated additional data keys (default is 'page' and will be suffixed by e.g. '-0001.jpg')
OutputTiff
If true, a multipage TIFF file will be generated, default is false (JPG).
PDFURL
URL pointing to the PDF file.
ResolutionDPI
Optional value in DPI, default is 150.
StartPageNumber
Optional, start (1 based) page number. The default value is 0, which includes all pages.
TimeoutMs
Optional timeout in Milliseconds, if no timeout value is specified, the default value of 90 seconds is used.
UserPassword
Optional, password to access password-protected PDF files.
Sample Code
The following code creates TIF file from PDF in 300dpi:
Create Merge PDF
Input Parameters
CompressionLevel
Optional, compression level, default is 'normal'. Available options are:
AboveNormal.
BelowNormal.
Best.
BestSpeed.
NoCompression.
Normal.
Orientation
Optional page orientation. Available options are:
Portrait.
Landscape.
DocumentId
Optional, if not specified the current document will be used.
OutputAdditionalDataKey
Optional additional data key, default is 'merge.pdf'.
PageSize
Optional page size. Available options are:
Letter.
Note.
Legal.
A0.
A10.
B0.
B5.
ArchA.
ArchE.
Fisa.
HalfLetter.
Letter11x7.
Ledger.
Files
An array of file descriptions, one entry for each PDF file or image to append. Each entry is formatted as follows: {RL:'https://...', StartIndex: 0, Length: 99, Password: '...'}. Only the URL is required and point to a PDF or image file.
TimeoutMs
Optional timeout in Milliseconds, if no timeout value is specified, the default value of 90 seconds is used.
Password
Optional, password to access password-protected PDF files.
Sample Code
The following code merges two PDF files.
Create Searchable Pdf
Input Variables
Sample Code
You can get InputImageFile and InputJsonFile from a call to GetDocumentInfo, or you can store the value that is returned when you add additional data with call to AddAdditionalData().
Set Error
Straatos.setError is used to set an error to a task when a task has an error.
Sample Code
Create Account
Input Parameters
LoginName
Login credentials.
Email Address
Login email address.
Name
Name of the person/account.
UserIdentifier
Similar to Login Name.
Password
Optional, password to create new user.
Roles
Defining the roles to be added to the account.
Sample Code
The following code creates a new user.
Get Account
Input Parameters
Id
Account ID is associated with account for which information is required.
Sample Code
The following code fetches user account information.
Sample Response
Below is output from Get Account.
Update Account
Input Parameters
LoginName
Login credentials.
Email Address
Login email address.
Name
Name of the person/account.
UserIdentifier
Similar to Login Name.
Password
Optional, password to update user.
Roles
Defining the access to the roles for the account.
Sample Code
The following code updates user account information.
Sample Response
Below is output from updateAccount.
Delete Account
Input Parameters
ID
ID of account that needs to be deleted.
Sample Code
The following code deletes the user's account.
Start Workflow
Input Parameters
workflowid
Workflow ID of workflow where new task should be started. If it is the same workflow, can be passed with straatos.workflowId.
startActivityId
Start activity ID of start event which should start the workflow.
Data
indexfielddata to be passed.
workflowconfiguration
Numeric (short) workflow ID which is also visible in Admin Panel. Alternative to specify workflowid.
webservice Key
(Optional, not needed to start a workflow in your own organisation). If you want to start a workflow in another organisation, enter that workflows webServiceKey here.
filetype
If original document is provided, provide filetype (pdf, tif, jpg).
documenturls
URL(s) to documents that need to be added as original document.
Sample Code for Interact API
Sample Code for Script Task
Get File As String / Get File As Base64 / Get File As ByteArray
Input Parameters
DocumentId
Straatos documentId of task from where to get file content. Required from interact API or when it is from different task.
FileUrl
URL to document to retrieve content from.
WebServiceKey
Only required if file is retrieve from workflow outside current workflow or if called from interact API.
Sample Code
List Roles for Organisation
Input Parameters
credentials
Login credentials
ID
ID of account holder
Functions
Function/role of account holder.
Sample Code
The following code fetches a list of roles available in organisation.
Sample Response
Following code output from ListRolesFromOrganisation.
Last updated