Create Postcard Create Postcard
print_mail.postcards.create(PostcardCreateParams**kwargs) -> PostcardCreateResponse
POST/print-mail/v1/postcards
Create a postcard. Note that you can supply one of the following:
- HTML content for the front and back of the postcard
- A template ID for the front and back of the postcard
- A URL for a 2 page PDF where the first page is the front of the postcard and the second page is the back Create a postcard via a multipart/form-data request. Accepts the same
fields as the JSON create body (nested objects are bracket-encoded form
fields, e.g.
to[firstName]); use this content type to upload the PDF file directly.
Parameters
back_html: str
The HTML content for the back of the postcard. You can supply either this or backTemplate but not both.
front_html: str
The HTML content for the front of the postcard. You can supply either this or frontTemplate but not both.
description: Optional[str]
An optional string describing this resource. Will be visible in the API and the dashboard.
merge_variables: Optional[Dict[str, object]]
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.
Create Postcard Create Postcard
import os
from postgrid import PostGrid
client = PostGrid(
print_mail_api_key=os.environ.get("POSTGRID_PRINT_MAIL_API_KEY"), # This is the default and can be omitted
)
postcard = client.print_mail.postcards.create(
back_html="<html>Back</html>",
front_html="<html>Front</html>",
size="6x4",
to="contact_456",
from_="contact_123",
paper="standard",
)
print(postcard){
"id": "postcard_sqF12lZ1VlBb",
"createdAt": "2019-12-27T18:11:19.117Z",
"live": true,
"mailingClass": "first_class",
"object": "postcard",
"sendDate": "2019-12-27T18:11:19.117Z",
"size": "6x4",
"status": "ready",
"to": {
"id": "contact_sqF12lZ1VlBb",
"addressLine1": "addressLine1",
"addressStatus": "verified",
"countryCode": "countryCode",
"createdAt": "2019-12-27T18:11:19.117Z",
"live": true,
"object": "contact",
"updatedAt": "2019-12-27T18:11:19.117Z",
"addressErrors": "addressErrors",
"addressLine2": "addressLine2",
"city": "city",
"companyName": "companyName",
"description": "description",
"email": "email",
"firstName": "firstName",
"forceVerifiedStatus": true,
"jobTitle": "jobTitle",
"lastName": "lastName",
"metadata": {
"foo": "bar"
},
"phoneNumber": "phoneNumber",
"postalOrZip": "postalOrZip",
"provinceOrState": "provinceOrState",
"secret": true,
"skipVerification": true
},
"updatedAt": "2019-12-27T18:11:19.117Z",
"cancellation": {
"reason": "user_initiated",
"cancelledByUser": "cancelledByUser",
"note": "note"
},
"description": "description",
"from": {
"id": "contact_sqF12lZ1VlBb",
"addressLine1": "addressLine1",
"addressStatus": "verified",
"countryCode": "countryCode",
"createdAt": "2019-12-27T18:11:19.117Z",
"live": true,
"object": "contact",
"updatedAt": "2019-12-27T18:11:19.117Z",
"addressErrors": "addressErrors",
"addressLine2": "addressLine2",
"city": "city",
"companyName": "companyName",
"description": "description",
"email": "email",
"firstName": "firstName",
"forceVerifiedStatus": true,
"jobTitle": "jobTitle",
"lastName": "lastName",
"metadata": {
"foo": "bar"
},
"phoneNumber": "phoneNumber",
"postalOrZip": "postalOrZip",
"provinceOrState": "provinceOrState",
"secret": true,
"skipVerification": true
},
"imbDate": "2019-12-27T18:11:19.117Z",
"imbStatus": "entered_mail_stream",
"imbZIPCode": "imbZIPCode",
"mergeVariables": {
"foo": "bar"
},
"metadata": {
"foo": "bar"
},
"paper": "standard",
"trackingNumber": "trackingNumber",
"url": "https://example.com"
}Returns Examples
{
"id": "postcard_sqF12lZ1VlBb",
"createdAt": "2019-12-27T18:11:19.117Z",
"live": true,
"mailingClass": "first_class",
"object": "postcard",
"sendDate": "2019-12-27T18:11:19.117Z",
"size": "6x4",
"status": "ready",
"to": {
"id": "contact_sqF12lZ1VlBb",
"addressLine1": "addressLine1",
"addressStatus": "verified",
"countryCode": "countryCode",
"createdAt": "2019-12-27T18:11:19.117Z",
"live": true,
"object": "contact",
"updatedAt": "2019-12-27T18:11:19.117Z",
"addressErrors": "addressErrors",
"addressLine2": "addressLine2",
"city": "city",
"companyName": "companyName",
"description": "description",
"email": "email",
"firstName": "firstName",
"forceVerifiedStatus": true,
"jobTitle": "jobTitle",
"lastName": "lastName",
"metadata": {
"foo": "bar"
},
"phoneNumber": "phoneNumber",
"postalOrZip": "postalOrZip",
"provinceOrState": "provinceOrState",
"secret": true,
"skipVerification": true
},
"updatedAt": "2019-12-27T18:11:19.117Z",
"cancellation": {
"reason": "user_initiated",
"cancelledByUser": "cancelledByUser",
"note": "note"
},
"description": "description",
"from": {
"id": "contact_sqF12lZ1VlBb",
"addressLine1": "addressLine1",
"addressStatus": "verified",
"countryCode": "countryCode",
"createdAt": "2019-12-27T18:11:19.117Z",
"live": true,
"object": "contact",
"updatedAt": "2019-12-27T18:11:19.117Z",
"addressErrors": "addressErrors",
"addressLine2": "addressLine2",
"city": "city",
"companyName": "companyName",
"description": "description",
"email": "email",
"firstName": "firstName",
"forceVerifiedStatus": true,
"jobTitle": "jobTitle",
"lastName": "lastName",
"metadata": {
"foo": "bar"
},
"phoneNumber": "phoneNumber",
"postalOrZip": "postalOrZip",
"provinceOrState": "provinceOrState",
"secret": true,
"skipVerification": true
},
"imbDate": "2019-12-27T18:11:19.117Z",
"imbStatus": "entered_mail_stream",
"imbZIPCode": "imbZIPCode",
"mergeVariables": {
"foo": "bar"
},
"metadata": {
"foo": "bar"
},
"paper": "standard",
"trackingNumber": "trackingNumber",
"url": "https://example.com"
}