Create a Job

Once you have credit in your account, a document uploaded, and an address list created, it's time to create the job that you want to execute. The job process consists of first creating a job and getting its ID, then submitting the job. Job creation is done with a POST to the /jobs endpoint.

Creating a job has 9 required parameters, and a large number of optional parameters that are beyond the scope of this tutorial.

Job Creation Required Parameters

ParameterDescription
documentClass The general type of the product
layout The specific type of the product
productionTime The desired production time
envelope If this is an enveloped product this determines the envelope in which the product is to be mailed; otherwise provide no value
color Print in color or black and white
paperType Sets the paper the mailing is to be printed on
printOption Sets simplex or duplex printing
documentId ID of the document to print
addressId ID of the address list for the job

The following Python code example creates a job using document 12345 and address list 78902 with a typical set of options:

# Load the HTTP requests module
import requests

# Define the endpoint to use
url = "https://stage-rest.click2mail.com/molpro/jobs"

# Define credentials
myusername = 'awesomeuser'
mypassword = 'gReAt/PaSsWoRd123'

headers = {'user-agent': 'my-app/0.0.1'}

# Build the dictionary of parameters to describe the job
values = {'documentClass' : 'Letter 8.5 x 11',
          'layout'        : 'Address on Separate Page',
          'productionTime': 'Next Day',
          'envelope'      : '#10 Double Window',
          'color'         : 'Black and White',
          'paperType'     : 'White 24#',
          'printOption'   : 'Printing One side',
          'documentId'    : 12345,
          'addressId'     : 78902}

# Make the POST call
r = requests.post(url, data=values, headers=headers, auth=(myusername, mypassword))

# Display the result - a success should return status_code 201
print(r.status_code)

# Display the full XML returned.
print(r.text)

A successful call should return an HTTP 201 status and the XML similar to the following:

201
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<job>
    <id>13331417</id>
    <status>0</status>
    <description>Created</description>
    <statusUrl>https://stage-rest.click2mail.com/molpro/jobs/13331417</statusUrl>
</job>

HTTP Return Codes And Possible Statuses

HTTP Response 200

Return CodeDescription
0Created
1DocumentId not found
1Job DocumentId not found
1Job Address list Id not found
3Address List ID not found
4Document Type cannot Mail Internationally
5Project does not exist
9Address list not valid for selected Product
9Quantity required for selected product
9Custom error related to quantity

HTTP Response 400

Return CodeDescription
9One of the required parameters is missing.
9Product not authorized for this customer
9Return address Name OR Return address Organization is required for selected product.
9Endorsements not valid for selected product
9Return Address not valid for selected product
9Minimum Quantity for selected product is
9Maximum Quantity for selected product is
9Custom error related to enclosures
9Future date greater than days
9Mailing date should be greater than current date.

HTTP Response 500
If a 500 error is returned, please contact Click2Mail support.

Return CodeDescription
9custom error message related to server error
9Could not parse date. Please add mailingDate parameter in form 'yyyymmdd'.