Developer Resources
Easily integrate document generation into any application using our open REST API.
Documents
Documents are the "templates" that are used at the base of all merges that occur. A document can be one of three different types: HTML, Fillable PDF, Word (DOCX), Excel Spreadsheet, or PowerPoint Presentation. With the API, you can create/edit/delete documents, grab a list of documents in a person's account, and merge documents.
Merge a Document
POST https://www.webmerge.me/merge/<ID>/<KEY>
To send data to a document, you will need to HTTP POST data to the document's unique Merge URL. This can be generated by using the ID and Key from each document. This does not require API Authentication.
Options:
- Test Mode - You can merge a document in test mode using "test=1" in the Merge URL
- https://www.webmerge.me/merge/1/abcde?test=1
- Download - The document can be returned to the output buffer using "download=1" in the Merge URL
- https://www.webmerge.me/merge/1/abcde?download=1
- Custom Fields - Fields not found in the document can be sent (in POST data) and used for deliveries
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The Document ID | 436346 |
<KEY> | The Document Key | firm3 |
test |
Merges the document in "test mode" | 1 |
download |
Will return the merged document in response | 1 |
<MERGE DATA> | The data to be merged in name/value pairs or nested JSON |
Example Request:
Name/Value Pairs
curl -X POST https://www.webmerge.me/merge/436346/firm3?download=1 \ -d "FirstName=John" \ -d "LastName=Smith" \ -d "Email=john.smith@example.com"
JSON
curl -X POST https://www.webmerge.me/merge/436346/firm3?download=1 \ -H "Content-Type: application/json" \ -d '{"FirstName":"John", "LastName":"Smith", "Email":"john.smith@example.com", "children":[ {"Name":"Sara", "Age":"10"}, {"Name":"Ben", "Age":"7"}]}'
Example Response:
Without Download=1
{ "success":1 }
With Download=1
%PDF-1.7 ........... ...........(the contents of the document - save to file)
Create a Document
POST /documents
This method is used to create a new document. Depending on the type of document you are creating, different parameters are required. Please see the full list of parameters below.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
name | Document name | "Purchase Invoice" |
type | The type of document | "html", "pdf", "docx", "xlsx", or "pptx" |
output | The type of document to produce from merge | "pdf", "docx", "xlsx", "pptx", or "email" |
output_name |
A customized filename for the merged document | "From {$FirstName}" |
folder |
The name of the folder to save the document in. If folder doesn't exist, one will be created | |
If type = "html" | ||
html | The HTML of the document | |
size_width |
The width of the document (inches) | 8.5 |
size_height |
The height of the document (inches) | 11 |
If type = "pdf", "docx", "xlsx", or "pptx" | ||
file_contents |
The (base64 encoded) contents of the file | |
file_url |
Public URL to the file (if not using "file_contents") | |
Email Notification | ||
notification |
The default email notificationarray( 'to' => '{$Email}', 'from' => 'test@example.com', 'subject' => 'Document from {$Name}', 'html' => 'This is the HTML content of the email...' 'security' => 'low', 'medium', or 'high', 'password' => 'abc123' (only used if security = medium or high) ) |
Example Request:
Name/Value Pairs
curl -X POST https://www.webmerge.me/api/documents \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \ -d "name=1040 EZ" \ -d "type=html" \ -d "output=pdf" \ -d "html=<h1>1040 EZ</h1> {$FirstName}....."
JSON
curl -X POST https://www.webmerge.me/api/documents \ -H "Content-Type: application/json" \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \ -d '{"name":"1040 EZ", "type":"html", "output":"pdf", "html":"<h1>1040 EZ</h1> {$FirstName}....."}'
Example Response:
{ "id":"234543", "key":"firm3", "type":"html", "name":"1040 EZ", "output":"pdf", "size":"", "size_width":"8.5", "size_height":"11", "active":"1", "url":"https://www.webmerge.me/merge/234543/firm3", "fields":[ {"key":"aflekjf409t3j4mg30m409m", "name":"FirstName"}, {"key":"3to3igj3g3gt94j9304jfqw", "name":"LastName"}, {"key":"t43j0grjaslkfje304vj9we", "name":"Email"} ] }
Update a Document
This method is used to update a document. You cannot change the type of document, but you can change many of the other settings as well as change the contents of the document. Only parameters that are sent in the request will be updated (you don't need to send settings that you don't want changed).
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID | |
name | Document name | |
output | The type of document to produce from merge | "pdf", "docx", "xlsx", "pptx", or "email" |
output_name |
A customized filename for the merged document | "From {$FirstName}" |
folder |
The name of the folder to save the document in. If folder doesn't exist, one will be created | |
If type = "html" | ||
html | The HTML of the document | |
size_width |
The width of the document (inches) | 8.5 |
size_height |
The height of the document (inches) | 11 |
If type = "pdf", "docx", "xlsx", or "pptx" | ||
file_contents |
The (base64 encoded) contents of the file | |
file_url |
Public URL to the file (if not using "file_contents") |
Example Request:
Name/Value Pairs
curl -X PUT https://www.webmerge.me/api/documents/234543 \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \ -d "name=1040 EZier" \ -d "output=pdf" \ -d "output_name=1040 EZ for {$FirstName}" -d "html=<h1>1040 EZ</h1> {$FirstName}....."
JSON
curl -X PUT https://www.webmerge.me/api/documents/234543 \ -H "Content-Type: application/json" \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \ -d '{"name":"1040 EZier", "output":"pdf", "output_name":"1040 EZ for {$FirstName}", "html":"<h1>1040 EZ</h1> {$FirstName}....."}'
Example Response:
{ "id":"234543", "key":"firm3", "type":"html", "name":"1040 EZier", "output":"pdf", "size":"", "size_width":"8.5", "size_height":"11", "active":"1", "url":"https://www.webmerge.me/merge/234543/firm3", "fields":[ {"key":"aflekjf409t3j4mg30m409m", "name":"FirstName"}, {"key":"3to3igj3g3gt94j9304jfqw", "name":"LastName"}, {"key":"t43j0grjaslkfje304vj9we", "name":"Email"}, {"key":"3jg34gj0gj3gjq0gj0r9gje", "name":"Phone"} ] }
Get a List of Documents
GET /documents
This method is used to retrieve a list of all the documents in the user's account.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
search |
Return a list of documents matching this search term | Contract |
folder |
Return a list of documents in this folder (name) | Client Agreements |
Example Request:
curl https://www.webmerge.me/api/documents \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R
Example Response:
[ { "id":"436346", "key":"firm3", "type":"pdf", "name":"1040 EZ", "output":"pdf", "size":"", "size_width":"8.5", "size_height":"11", "active":"1", "url":"https://www.webmerge.me/merge/2436346/firm3" },{ "id":"436347", "key":"7icxf", "type":"pdf", "name":"1040 EZ - COPY", "output":"pdf", "size":"", "size_width":"8.5", "size_height":"16", "active":"1", "url":"https://www.webmerge.me/merge/436347/7icxf" } ]
Get a Document
GET /documents/<ID>
This method is used to retrieve the details of a specific document.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID |
Example Request:
curl https://www.webmerge.me/api/documents/436346 \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R
Example Response:
{ "id":"436346", "key":"firm3", "type":"pdf", "name":"1040 EZ", "output":"pdf", "size":"", "size_width":"8.5", "size_height":"11", "active":"1", "url":"https://www.webmerge.me/merge/436346/firm3", "html":"HTML code for the document (if type = html)" }
Get the Fields for a Document
GET /documents/<ID>/fields
This method is used to retrieve a list of fields for a specific document.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID | |
attributes |
Include all field attributes | 1 |
Example Request:
curl https://www.webmerge.me/api/documents/436346/fields \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R
Example Response:
[ {"key":"aflekjf409t3j4mg30m409m", "name":"FirstName"}, {"key":"3to3igj3g3gt94j9304jfqw", "name":"LastName"}, {"key":"t43j0grjaslkfje304vj9we", "name":"Email"}, {"key":"3jg34gj0gj3gjq0gj0r9gje", "name":"Phone"} ]
Get the File for a Document
GET /documents/<ID>/file
This method is used to retrieve the file that was uploaded for this document (pdf, docx, xlsx, or pptx).
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID |
Example Request:
curl https://www.webmerge.me/api/documents/436346/file \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R
Example Response:
{ "type":"pdf", "last_update":"2015-03-24 16:34:20", "contents":"base64 encoded file data" }
Get the Deliveries for a Document
GET /documents/<ID>/deliveries
This method is used to retrieve a list of deliveries for a specific document.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID |
Example Request:
curl https://www.webmerge.me/api/documents/436346/deliveries \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R
Example Response:
[ { "id":"261", "type":"email", "settings":{ "to":"{$email}", "from":"test@example.com", "subject":"Your Contract", "html": "Hello {$first_name},<br><br>See attachment!" } } ]
Create a Delivery for a Document
POST /documents/<ID>/deliveries
This method is used to create a delivery for a specific document.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID | |
type | The type of delivery | email, webhook, etc |
settings | The settings |
array( 'to' => '{$Email}', 'from' => 'test@example.com', 'subject' => 'Document from {$Name}', 'html' => 'This is the HTML content of the email...' ) |
Example Request:
curl https://www.webmerge.me/api/documents/436346/deliveries \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \ -d "type=html" \ -d "settings[to]={$Email}" \ -d "settings[from]=test@example.com" \ -d "settings[subject]=Document from {$Name}" \ -d "settings[html]=This is the HTML content of the email..."
Example Response:
{ "id":"2344", "type":"email", "settings":{ "to":"{$Email}", "from":"test@example.com", "subject":"Your Contract", "html": "Hello {$first_name},<br><br>See attachment!" }, "success": 1 }
Copy a Document
POST /documents/<ID>/copy
This method is used to create a copy of a document.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID | |
name | The name of the new document |
Example Request:
curl -X POST https://www.webmerge.me/api/documents/436346/copy \ -H "Content-Type: application/json" \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \ -d '{"name":"1040 EZier - CA"}
Example Response:
{ "id":"789789", "key":"asdl4k", "type":"html", "name":"1040 EZier - CA", "output":"pdf", "size":"", "size_width":"8.5", "size_height":"11", "active":"1", "url":"https://www.webmerge.me/merge/789789/asdl4k", "fields":[ {"key":"aflekjf409t3j4mg30m409m", "name":"FirstName"}, {"key":"3to3igj3g3gt94j9304jfqw", "name":"LastName"}, {"key":"t43j0grjaslkfje304vj9we", "name":"Email"}, {"key":"3jg34gj0gj3gjq0gj0r9gje", "name":"Phone"} ] }
Delete a Document
DELETE /documents/<ID>
This method is used to delete a document.
Request Parameters
Parameter |
Description |
Example Values |
---|---|---|
<ID> | The document ID |
Example Request:
curl -X DELETE https://www.webmerge.me/api/documents/436346 \ -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R
Example Response:
{ "success" : "1" }