AppSynergy REST API
The AppSynergy REST API allows you to make RESTful calls to your account from any application.
Note that you can call these API methods using AppSynergy's SQL/REST feature
(i.e. from triggers and stored procedures).
Actions for PDF document activities:
- HTML2PDF – Generate a PDF document from HTML.
- PDF_AUTOFILL – Fills out a template PDF with the provided info.
- PDF_MERGE – Combines two or more PDF documents into one PDF document.
Actions for SQL database activities:
- EXEC_QUERY – Execute an SQL Query (SELECT).
- EXEC_DML – Execute an SQL DML Statement (INSERT, UPDATE, DELETE).
YOUR_API_KEY and its assigned Security Role determine access rights (see Tools > API Keys...).
YOUR_API_KEY can be provided as a URL parameter (as shown below) or alternatively as an HTTP header
in Bearer Authentication format.
Note that all actions:
- Must complete in less than 60 seconds.
- Have a request/response size limit of ~16MB.
- Are rate limited by default to 500 connections per hour to prevent runaway systems.
This is configurable via the API user's MAX_CONNECTIONS_PER_HOUR resource option.
HTML2PDF – PDF Generation
Generates a PDF document from the provided HTML and stores it in your database storage bucket.
The response contains a reference to that document in AppSynergy Document Field format.
Request
POST https://www.appsynergy.com/api?action=HTML2PDF&apiKey=YOUR_API_KEY
{
"html": "<html><body><h1>Hello World</h1></body></html>"
"filename": "HelloWorld.pdf",
}
- The html property must be in XHTML format (i.e. all elements must be closed;
for example <br> is not valid but <br/> is valid).
Most of CSS 2.1 is supported.
See the PDF Generation documentation for further details
and an example of how to use this API call from within your AppSynergy code.
- The filename property provides the human readable filename for the generated PDF document.
Response
{
"status": "OK",
"errorMessage": "",
"errorCode": "",
"data": {
"documentField": "HelloWorld.pdf;1048;1598992707098;database/files/a655f610-febd-4f6a-b11d-6bcd696f5456.pdf"
}
}
- The data.documentField property is in AppSynergy Document Field format; it is a reference
to the PDF file created in your database storage bucket.
This value can be stored directly into any column in the database defined as a Document Field.
PDF_AUTOFILL – Programmatically Fill a PDF Document
Given a fillable PDF document and a list of field names and values, this method fills in the PDF fields
creating a new filled PDF document.
Request
POST https://www.appsynergy.com/api?action=PDF_AUTOFILL&apiKey=YOUR_API_KEY
{
"sourcePdf": "MyFillableTemplate.pdf;1048;1598992707098;database/files/a655f610-febd-4f6a-b11d-6bcd696f5456.pdf",
"dataFields": {
"field1":"value1",
"field2":"value2"
},
"outputFilename": "MyNewDoc.pdf",
"ignoreMissingFields": true,
"flattenFields": "NONE"
}
- The sourcePdf property must be in DocumentField format (as shown).
- The dataFields property is an object with any number of key-value pairs; the values must be strings.
- The outputFilename property provides the human readable filename for the generated PDF document.
- The ignoreMissingFields property (default true) determines if an error is generated if any of the
specified dataFields are missing in the sourcePdf.
- The flattenFields property (valid values: ALL | FILLED | NONE) flattens all fields or just filled fields.
Response
{
"status": "OK",
"errorMessage": "",
"errorCode": "",
"data": {
"filledPdf": "MyNewDoc.pdf;12048;1598992709098;database/files/a655f610-febd-4f6a-b11d-6bcd696f5466.pdf", // DocumentField format
"acroFieldNames": [
"FirstName",
"LastName"
]
}
}
- The data.filledPdf property is in DocumentField format; it is a reference to the filled PDF file
created in your database storage bucket.
This value can be stored in any database field of type DocumentField.
- The data.acroFieldNames property is an array containing the list of all AcroFields found in the sourcePdf.
This can be useful for diagnosing mismatached field names.
PDF_MERGE – Merge Multiple PDFs into A Single Document
Merges multiple PDFs into a single document.
Request
POST https://www.appsynergy.com/api?action=PDF_MERGE&apiKey=YOUR_API_KEY
{
"outputFilename": "MyNewDoc.pdf",
"sourcePdfs": [
"Doc1.pdf;10428;1598992706098;database/files/a655f610-febd-4f6a-b11d-6bcd696f5456.pdf",
"Doc2.pdf;21048;1598992507098;database/files/a655f610-febd-4f6a-b11d-6bcd696f6bcd.pdf",
"Doc3.pdf;90148;1598992737098;database/files/a655f610-febd-4f6a-b11d-6bcd696f4f6a.pdf"
]
}
- The outputFilename property provides the human readable filename for the generated PDF document.
- The sourcePdfs property is the array of DocumentField values to be merged.
Response
{
"status": "OK",
"errorMessage": "",
"errorCode": "",
"data": {
"mergedPdf": "MyMergedDoc.pdf;91048;1598992709098;database/files/a655f610-febd-4f6a-b11d-6bcd696f5466.pdf"
}
}
- The data.mergedPdf property is the resulting merged PDF document (in DocumentField format).
EXEC_QUERY – Execute an SQL Query
Executes an SQL query and returns the results in either JSON or CSV format. You can execute an SQL command
like SHOW TABLES to see which tables are available.
Request
POST https://www.appsynergy.com/api?action=EXEC_QUERY&apiKey=YOUR_API_KEY
{
"sqlCmd": "SELECT * FROM MyTable",
"responseFormat": "JSON"
}
- The sqlCmd property can be set to any valid SQL query. Since each API Key is assigned to a specific
Security Role, only the SQL commands allowed by that Security Role will be permitted.
- The responseFormat property must be set to either JSON or CSV.
Response
If responseFormat was CSV:
Customer_ID,Name
1000,"Company A"
1001,"Company B"
If responseFormat was JSON:
{
"status": "OK",
"errorMessage": "",
"errorCode": "",
"data": {
"columns": [
{
"tableName": "Customers",
"columnName": "Customer_ID",
"datatype": "BIGINT"
},
{
"tableName": "Customers",
"columnName": "Name",
"datatype": "VARCHAR"
}
],
"rows": [
{
"values": [
{
"value": "1000"
},
{
"value": "Company A"
}
]
},
{
"values": [
{
"value": "1001"
},
{
"value": "Company B"
}
]
}
]
}
}
- The data.rows property is an array of row objects.
Each row object has an array of value objects.
Each value object has a value property.
Therefore data.rows[0].values[0].value refers to the value in the first column of the first row.
EXEC_DML – Execute an SQL DML Statement
Executes an SQL DML statement (e.g. INSERT, UPDATE, DELETE) and returns the number of rows affected.
Request
POST https://www.appsynergy.com/api?action=EXEC_DML&apiKey=YOUR_API_KEY
{
"sqlCmd": "UPDATE MyTable SET MyCol = 123 WHERE ID = 100"
}
- The sqlCmd property can be set to any valid SQL DML statement. Since each API Key is assigned to a specific
Security Role, only the SQL commands allowed by that Security Role will be permitted.
Response
{
"status": "OK",
"errorMessage": "",
"errorCode": "",
"data": {
"rowsAffected": 1
}
}
- The data.rowsAffected property is an integer representing the number of rows affected by the SQL DML statement.