🎉  Build a workflow powerhouse. Learn more about our new Airtable integration.   ðŸŽ‰

Close

Developer Resources

Easily integrate document generation into any application using our open REST API.

Get Started

Developers hero graphic

Data Routes

Data Routes provide the ability to send data to multiple Documents (based on pre-defined conditions) via a single HTTP POST.

Merge a Data Route

POST https://www.webmerge.me/route/<ID>/<KEY>

To use a Data Route, you will need to HTTP POST data to the route's unique Merge URL. This can be generated by using the ID and Key from each route. This does not require API Authentication.

Options:

  • Test Mode - You can merge in test mode using "test=1" in the Merge URL
    • https://www.webmerge.me/route/1/abcde?test=1
  • Download - The document can be returned in the response by using "download=1" in the Merge URL
    • https://www.webmerge.me/route/1/abcde?download=1
  • Custom Fields - Fields not found in the route documents can be sent (in POST data) and used for deliveries

Request Parameters

Parameter
Description
Example Values
<ID> The Data Route ID 129578
<KEY> The Data Route Key l3kjs
test
(optional)
Merges the data route in "test mode" 1
download
(optional)
Will return the merged document in response 1
<MERGE DATA> The data to be merged in name/value pairs or JSON

Example Request:

Name/Value Pairs

    curl -X POST https://www.webmerge.me/route/129578/l3kjs \
    -d "FirstName=John" \
    -d "LastName=Smith" \
    -d "Email=john.smith@example.com"

JSON

    curl -X POST https://www.webmerge.me/route/129578/l3kjs \
    -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 and 1 merged document

%PDF-1.7
...........
...........(the contents of the document - save to file)

With Download=1 and 2+ merged documents

{
    "success":1,
    "files": [
        {"name":"Invoice.pdf", "file_contents": base64_encoded()},
        {"name":"Thank You.pdf", "file_contents": base64_encoded()}
    ]
}

 

Create a Data Route

POST /routes

This method is used to create a new data route. Please see the full list of parameters below.

Request Parameters

Parameter
Description
Example Values
name Data route name "New Employee Kit"
rules Array of data route rules
Parameter
Description
Example Values
document_id Document ID 12345678
file
(required if document_id is empty)
Remote file URL or merge field {$file_url}
sort
(optional)
Ordering of rule 1
combine
(optional)
Include rule in combined PDF 1 or 0
loop_field
(optional)
Repeat rule using this field/array {$products}
conditions
(optional)
Array of conditions for rule
array(
    'field' => '{$State}',
    'exp' => '==',
    'value' => 'California',
)
Other exp: !=, <, <=, >, >=, 'contains', or '!contains'
output_name
(optional)
A customized filename for the combined PDF document "New Employee - {$FirstName}"
folder
(optional)
The name of the folder to save the data route in. If folder doesn't exist, one will be created  

Example Request:

Name/Value Pairs

    curl -X POST https://www.webmerge.me/api/routes \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \
    -d "name=New Employee Kit" \
    -d "rules[0][document_id]=1234567" \
    -d "rules[0][combine]=1" \
    -d "rules[1][document_id]=98765432" \
    -d "rules[1][combine]=1"

JSON

    curl -X POST https://www.webmerge.me/api/routes \
    -H "Content-Type: application/json" \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \
    -d '{"name":"New Employee Kit", "rules":[{"document_id":"1234567",
        "combine":1}, {"document_id":"98765432", "combine":1}]}'


Example Response:

{
    "id":"234543",
    "key":"abcdef",
    "name":"New Employee Kit",
    "active":"1",
    "url":"https://www.webmerge.me/route/234543/abcdef",
    "rules":[
    	{"id":"12345", "document_id":"1234567", "combine":1},
        {"id":"12346", "document_id":"98765432", "combine":1}
    ]
}

 

Update a Data Route

PUT /routes/<ID>

This method is used to update a data route. Please see the full list of parameters below.

Request Parameters

Parameter
Description
Example Values
<ID> The data route ID  
name Data route name "New Employee Kit"
rules Array of data route rules
Parameter
Description
Example Values
id Rule ID 54345
document_id Document ID 12345678
file
(required if document_id is empty)
Remote file URL or merge field {$file_url}
sort
(optional)
Ordering of rule 1
combine
(optional)
Include rule in combined PDF 1 or 0
combine_docx
(optional)
Include rule in combined DOCX 1 or 0
loop_field
(optional)
Repeat rule using this field/array {$products}
conditions
(optional)
Array of conditions for rule
array(
    'field' => '{$State}',
    'exp' => '==',
    'value' => 'California',
)
Other exp: !=, <, <=, >, >=, 'contains', or '!contains'
output_name
(optional)
A customized filename for the combined PDF document "New Employee - {$FirstName}"
folder
(optional)
The name of the folder to save the data route in. If folder doesn't exist, one will be created  

Example Request:

Name/Value Pairs

    curl -X PUT https://www.webmerge.me/api/routes/234543 \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \
    -d "name=New Employee Kit" \
    -d "rules[0][id]=12345" \
    -d "rules[0][document_id]=1234567" \
    -d "rules[0][combine]=0" \
    -d "rules[1][id]=12346" \
    -d "rules[1][document_id]=123789" \
    -d "rules[1][combine]=0"
    -d "rules[2][file]={$file_url}"

JSON

    curl -X POST https://www.webmerge.me/api/routes \
    -H "Content-Type: application/json" \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R \
    -d '{"name":"New Employee Kit", "rules":[{"id":"12345",
        "document_id":"1234567", "combine":0}, {"id":"12346",
        "document_id":"123789", "combine":0}, {"file":"{$file_url"}]}'


Example Response:

{
    "id":"234543",
    "key":"abcdef",
    "name":"New Employee Kit",
    "active":"1",
    "url":"https://www.webmerge.me/route/234543/abcdef",
    "rules":[
    	{"id":"12345", "document_id":"1234567", "combine":0},
        {"id":"12346", "document_id":"123789", "combine":0},
        {"id":"12347", "file":"{$file_url}", "combine":0}
    ]
}

 

Get a List of Data Routes

GET /routes

This method is used to retrieve a list of all the data routes in the user's account.

Request Parameters

Parameter
Description
Example Values
none

Example Request:

    curl https://www.webmerge.me/api/routes \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R

Example Response:

[
    {
        "id":"129578",
        "key":"l3kjs",
        "name":"Contract",
        "url":"https://www.webmerge.me/route/129578/13kjs"
    },{
        "id":"139482",
        "key":"lk43k",
        "name":"New Client Agreement",
        "url":"https://www.webmerge.me/route/139482/lk43k"
    }
]

 

Get a Data Route

GET /routes/<ID>

This method is used to retrieve the details of a specific route.

Request Parameters

Parameter
Description
Example Values
<ID> The data route ID

Example Request:

    curl https://www.webmerge.me/api/routes/129578 \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R

Example Response:

{
    "id":"129578",
    "key":"l3kjs",
    "name":"Contract",
    "url":"https://www.webmerge.me/route/129578/13kjs"
}

 

Get the Fields for a Data Route

GET /routes/<ID>/fields

This method is used to retrieve a list of fields for a specific data route (includes fields from all documents in routing rules).

Request Parameters

Parameter
Description
Example Values
<ID> The data route ID

Example Request:

    curl https://www.webmerge.me/api/routes/129578/fields \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R

Example Response:

[
    {"key":"aflekjf409t3j4mg30m409m", "name":"FirstName"},
    {"key":"3to3igj3g3gt94j9304jfqw", "name":"LastName"},
    {"key":"t43j0grjaslkfje304vj9we", "name":"Email"},
    {"key":"3jg34gj0gj3gjq0gj0r9gje", "name":"Phone"}
]

 

Get the Rules for a Data Route

GET /routes/<ID>/rules

This method is used to retrieve a list of rules for a specific data route.

Request Parameters

Parameter
Description
Example Values
<ID> The data route ID

Example Request:

    curl https://www.webmerge.me/api/routes/12345/rules \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R

Example Response:

[
    {"id":"12345", "document_id":"1234567", "combine":0},
    {"id":"12346", "document_id":"123789", "combine":0},
    {"id":"12347", "file":"{$file_url}", "combine":0}
]

 

Get the Deliveries for a Data Route

GET /routes/<ID>/deliveries

This method is used to retrieve a list of deliveries for a specific data route.

Request Parameters

Parameter
Description
Example Values
<ID> The data route ID

Example Request:

    curl https://www.webmerge.me/api/routes/12345/deliveries \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R

Example Response:

[
    {
        "id":"261",
        "type":"email",
        "settings":{
            "to":"{$email}",
            "from":"test@example.com",
            "subject":"Your Documents",
            "html": "Hello {$first_name},<br><br>See attachments!"
        }
    }
]

 

Create a Delivery for a Data Route

POST /routes/<ID>/deliveries

This method is used to create a delivery for a specific data route.

Request Parameters

Parameter
Description
Example Values
<ID> The data route 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/routes/12345/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!"
        }
    }
]

 

Delete a Data Route

DELETE /routes/<ID>

This method is used to delete a data route.

Request Parameters

Parameter
Description
Example Values
<ID> The data route ID

Example Request:

    curl -X DELETE https://www.webmerge.me/api/routes/129578 \
    -u 3K83KMN1AL6M1MXMVVCKR66BP9NA:I51BBZ5R

Example Response:

{
    "success" : "1"
}