Create Letter
Create a letter. Note that you can supply one of the following:
- HTML content for the letter
- A template ID for the letter
- A URL or file for a PDF for the letter
- Upload the aforementioned PDF file via a multipart form upload request
Body ParametersJSONExpand Collapse
body: object { from, html, to, 14 more } or object { template } or object { from, pdf, to, 14 more }
LetterCreateWithHTML = object { from, html, to, 14 more }
from: ContactCreateWithFirstName { addressLine1, countryCode, firstName, 13 more } or ContactCreateWithCompanyName { addressLine1, companyName, countryCode, 13 more } or stringThe contact information of the sender. You can pass contact information inline here just like you can for the to.
The contact information of the sender. You can pass contact information inline here just like you can for the to.
ContactCreateWithFirstName = object { addressLine1, countryCode, firstName, 13 more }
ContactCreateWithCompanyName = object { addressLine1, companyName, countryCode, 13 more }
to: ContactCreateWithFirstName { addressLine1, countryCode, firstName, 13 more } or ContactCreateWithCompanyName { addressLine1, companyName, countryCode, 13 more } or stringThe recipient of this order. You can either supply the contact information inline here or provide a contact ID. PostGrid will automatically deduplicate contacts regardless of whether you provide the information inline here or call the contact creation endpoint.
The recipient of this order. You can either supply the contact information inline here or provide a contact ID. PostGrid will automatically deduplicate contacts regardless of whether you provide the information inline here or call the contact creation endpoint.
ContactCreateWithFirstName = object { addressLine1, countryCode, firstName, 13 more }
ContactCreateWithCompanyName = object { addressLine1, companyName, countryCode, 13 more }
An optional string describing this resource. Will be visible in the API and the dashboard.
The envelope (ID) for the letter. You can either specify a custom envelope ID or use the default standard envelope.
mailingClass: optional "first_class" or "standard_class" or "express" or 23 moreThe mailing class of this order. If not provided, automatically set to first_class.
The mailing class of this order. If not provided, automatically set to first_class.
These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template exactly as they are case-sensitive. Note that these do not apply to PDFs uploaded with the order.
If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.
Model representing a plastic card.
Model representing a plastic card.
doubleSided: optional object { backHTML, backTemplate, frontHTML, 2 more } Model representing a double-sided plastic card.
Model representing a double-sided plastic card.
singleSided: optional object { html, pdf, template } Model representing a single-sided plastic card.
Model representing a single-sided plastic card.
This order will transition from ready to printing on the day after this date. You can use this parameter to schedule orders for a future date.
LetterCreateWithPdf = object { from, pdf, to, 14 more }
from: ContactCreateWithFirstName { addressLine1, countryCode, firstName, 13 more } or ContactCreateWithCompanyName { addressLine1, companyName, countryCode, 13 more } or stringThe contact information of the sender. You can pass contact information inline here just like you can for the to.
The contact information of the sender. You can pass contact information inline here just like you can for the to.
ContactCreateWithFirstName = object { addressLine1, countryCode, firstName, 13 more }
ContactCreateWithCompanyName = object { addressLine1, companyName, countryCode, 13 more }
to: ContactCreateWithFirstName { addressLine1, countryCode, firstName, 13 more } or ContactCreateWithCompanyName { addressLine1, companyName, countryCode, 13 more } or stringThe recipient of this order. You can either supply the contact information inline here or provide a contact ID. PostGrid will automatically deduplicate contacts regardless of whether you provide the information inline here or call the contact creation endpoint.
The recipient of this order. You can either supply the contact information inline here or provide a contact ID. PostGrid will automatically deduplicate contacts regardless of whether you provide the information inline here or call the contact creation endpoint.
ContactCreateWithFirstName = object { addressLine1, countryCode, firstName, 13 more }
ContactCreateWithCompanyName = object { addressLine1, companyName, countryCode, 13 more }
An optional string describing this resource. Will be visible in the API and the dashboard.
The envelope (ID) for the letter. You can either specify a custom envelope ID or use the default standard envelope.
mailingClass: optional "first_class" or "standard_class" or "express" or 23 moreThe mailing class of this order. If not provided, automatically set to first_class.
The mailing class of this order. If not provided, automatically set to first_class.
These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template exactly as they are case-sensitive. Note that these do not apply to PDFs uploaded with the order.
If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.
Model representing a plastic card.
Model representing a plastic card.
doubleSided: optional object { backHTML, backTemplate, frontHTML, 2 more } Model representing a double-sided plastic card.
Model representing a double-sided plastic card.
singleSided: optional object { html, pdf, template } Model representing a single-sided plastic card.
Model representing a single-sided plastic card.
This order will transition from ready to printing on the day after this date. You can use this parameter to schedule orders for a future date.
ReturnsExpand Collapse
Letter = object { id, addressPlacement, color, 29 more }
The contact information of the sender.
The contact information of the sender.
A series of human-readable errors/warnings that were raised when running the provided address through our address verification.
An optional string describing this resource. Will be visible in the API and the dashboard.
mailingClass: "first_class" or "standard_class" or "express" or 23 moreThe mailing class of this order. This determines the speed and cost of delivery. See OrderMailingClass for more details.
The mailing class of this order. This determines the speed and cost of delivery. See OrderMailingClass for more details.
This order will transition from ready to printing on the day after this date. For example, if this is a date on Tuesday, the order will transition to printing on Wednesday at midnight eastern time.
status: "ready" or "printing" or "processed_for_delivery" or 2 moreSee OrderStatus for more details on the status of this order.
See OrderStatus for more details on the status of this order.
The recipient of this order. This will be provided even if you delete the underlying contact.
The recipient of this order. This will be provided even if you delete the underlying contact.
A series of human-readable errors/warnings that were raised when running the provided address through our address verification.
An optional string describing this resource. Will be visible in the API and the dashboard.
cancellation: optional object { reason, cancelledByUser, note } The cancellation details of this order. Populated if the order has been cancelled.
The cancellation details of this order. Populated if the order has been cancelled.
An optional string describing this resource. Will be visible in the API and the dashboard.
The HTML content for the letter. You can supply either this or template but not both.
The last date that the IMB status was updated. See imbStatus for more details.
imbStatus: optional "entered_mail_stream" or "out_for_delivery" or "returned_to_sender"The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.
The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.
The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an imbStatus is present.
These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template exactly as they are case-sensitive. Note that these do not apply to PDFs uploaded with the order.
If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.
Model representing a plastic card.
Model representing a plastic card.
doubleSided: optional object { backHTML, backTemplate, frontHTML, 2 more } Model representing a double-sided plastic card.
Model representing a double-sided plastic card.
singleSided: optional object { html, pdf, template } Model representing a single-sided plastic card.
Model representing a single-sided plastic card.
The template ID used for the letter. You can supply either this or html but not both.
The tracking number of this order. Populated after an express/certified order has been processed for delivery.
If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.
PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all GET endpoints which produce this order.
This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the GET endpoint again.
Create Letter
curl https://api.postgrid.com/print-mail/v1/letters \
-H 'Content-Type: application/json' \
-H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY" \
-d '{
"from": {
"addressLine1": "addressLine1",
"countryCode": "countryCode",
"firstName": "firstName"
},
"html": "html",
"to": {
"addressLine1": "addressLine1",
"countryCode": "countryCode",
"firstName": "firstName"
}
}'{
"id": "letter_123456",
"object": "letter",
"status": "ready",
"live": false,
"to": {
"id": "contact_pxd7wnnD1xY6H6etKNvjb4",
"object": "contact",
"live": false,
"companyName": "PostGrid",
"addressLine1": "90 CANAL ST STE 600",
"city": "BOSTON",
"provinceOrState": "MA",
"postalOrZip": "90210-1234",
"countryCode": "US",
"skipVerification": false,
"forceVerifiedStatus": false,
"addressStatus": "verified",
"createdAt": "2022-02-16T15:08:41.052Z",
"updatedAt": "2022-02-16T15:08:41.052Z"
},
"from": {
"id": "contact_pxd7wnnD1xY6H6etKNvjb4",
"object": "contact",
"live": false,
"companyName": "PostGrid",
"addressLine1": "90 CANAL ST STE 600",
"city": "BOSTON",
"provinceOrState": "MA",
"postalOrZip": "90210-1234",
"countryCode": "US",
"skipVerification": false,
"forceVerifiedStatus": false,
"addressStatus": "verified",
"createdAt": "2022-02-16T15:08:41.052Z",
"updatedAt": "2022-02-16T15:08:41.052Z"
},
"size": "us_letter",
"doubleSided": true,
"color": false,
"sendDate": "2020-11-12T23:23:47.974Z",
"createdAt": "2020-11-12T23:23:47.974Z",
"updatedAt": "2020-11-12T23:23:47.974Z",
"mailingClass": "first_class",
"envelope": "standard",
"addressPlacement": "top_first_page",
"html": "<html>Content</html>"
}Returns Examples
{
"id": "letter_123456",
"object": "letter",
"status": "ready",
"live": false,
"to": {
"id": "contact_pxd7wnnD1xY6H6etKNvjb4",
"object": "contact",
"live": false,
"companyName": "PostGrid",
"addressLine1": "90 CANAL ST STE 600",
"city": "BOSTON",
"provinceOrState": "MA",
"postalOrZip": "90210-1234",
"countryCode": "US",
"skipVerification": false,
"forceVerifiedStatus": false,
"addressStatus": "verified",
"createdAt": "2022-02-16T15:08:41.052Z",
"updatedAt": "2022-02-16T15:08:41.052Z"
},
"from": {
"id": "contact_pxd7wnnD1xY6H6etKNvjb4",
"object": "contact",
"live": false,
"companyName": "PostGrid",
"addressLine1": "90 CANAL ST STE 600",
"city": "BOSTON",
"provinceOrState": "MA",
"postalOrZip": "90210-1234",
"countryCode": "US",
"skipVerification": false,
"forceVerifiedStatus": false,
"addressStatus": "verified",
"createdAt": "2022-02-16T15:08:41.052Z",
"updatedAt": "2022-02-16T15:08:41.052Z"
},
"size": "us_letter",
"doubleSided": true,
"color": false,
"sendDate": "2020-11-12T23:23:47.974Z",
"createdAt": "2020-11-12T23:23:47.974Z",
"updatedAt": "2020-11-12T23:23:47.974Z",
"mailingClass": "first_class",
"envelope": "standard",
"addressPlacement": "top_first_page",
"html": "<html>Content</html>"
}