# Postcards ## Create Postcard `print_mail.postcards.create(PostcardCreateParams**kwargs) -> Postcard` **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 or file for a 2 page PDF where the first page is the front of the postcard and the second page is the back - Upload the aforementioned PDF file via a multipart form upload request ### 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. - `size: PostcardSize` Enum representing the supported postcard sizes. - `"6x4"` - `"9x6"` - `"11x6"` - `to: PostcardCreateWithHTMLTo` 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. - `class ContactCreateWithFirstName: …` - `address_line1: str` The first line of the contact's address. - `country_code: str` The ISO 3611-1 country code of the contact's address. - `first_name: str` - `address_line2: Optional[str]` Second line of the contact's address, if applicable. - `city: Optional[str]` The city of the contact's address. - `company_name: Optional[str]` Company name of the contact. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `email: Optional[str]` Email of the contact. - `force_verified_status: Optional[bool]` If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise. - `job_title: Optional[str]` Job title of the contact. - `last_name: Optional[str]` Last name of the contact. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `phone_number: Optional[str]` Phone number of the contact. - `postal_or_zip: Optional[str]` The postal or ZIP code of the contact's address. - `province_or_state: Optional[str]` Province or state of the contact's address. - `skip_verification: Optional[bool]` If `true`, PostGrid will skip running this contact's address through our address verification system. - `class ContactCreateWithCompanyName: …` - `address_line1: str` The first line of the contact's address. - `company_name: str` - `country_code: str` The ISO 3611-1 country code of the contact's address. - `address_line2: Optional[str]` Second line of the contact's address, if applicable. - `city: Optional[str]` The city of the contact's address. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `email: Optional[str]` Email of the contact. - `first_name: Optional[str]` First name of the contact. - `force_verified_status: Optional[bool]` If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise. - `job_title: Optional[str]` Job title of the contact. - `last_name: Optional[str]` Last name of the contact. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `phone_number: Optional[str]` Phone number of the contact. - `postal_or_zip: Optional[str]` The postal or ZIP code of the contact's address. - `province_or_state: Optional[str]` Province or state of the contact's address. - `skip_verification: Optional[bool]` If `true`, PostGrid will skip running this contact's address through our address verification system. - `str` - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `from_: Optional[PostcardCreateWithHTMLFrom]` The contact information of the sender. You can pass contact information inline here just like you can for the `to`. Unlike other order types, the sender address is optional for postcards. - `class ContactCreateWithFirstName: …` - `class ContactCreateWithCompanyName: …` - `str` - `mailing_class: Optional[Literal["first_class", "standard_class", "express", 23 more]]` The mailing class of this order. If not provided, automatically set to `first_class`. - `"first_class"` - `"standard_class"` - `"express"` - `"certified"` - `"certified_return_receipt"` - `"registered"` - `"usps_first_class"` - `"usps_standard_class"` - `"usps_eddm"` - `"usps_express_2_day"` - `"usps_express_3_day"` - `"usps_first_class_certified"` - `"usps_first_class_certified_return_receipt"` - `"usps_first_class_registered"` - `"usps_express_3_day_signature_confirmation"` - `"usps_express_3_day_certified"` - `"usps_express_3_day_certified_return_receipt"` - `"ca_post_lettermail"` - `"ca_post_personalized"` - `"ca_post_neighbourhood_mail"` - `"ups_express_overnight"` - `"ups_express_2_day"` - `"ups_express_3_day"` - `"royal_mail_first_class"` - `"royal_mail_second_class"` - `"au_post_second_class"` - `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. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `send_date: Optional[Union[str, datetime]]` 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. ### Returns - `class Postcard: …` - `id: str` A unique ID prefixed with postcard_ - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `mailing_class: Literal["first_class", "standard_class", "express", 23 more]` The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details. - `"first_class"` - `"standard_class"` - `"express"` - `"certified"` - `"certified_return_receipt"` - `"registered"` - `"usps_first_class"` - `"usps_standard_class"` - `"usps_eddm"` - `"usps_express_2_day"` - `"usps_express_3_day"` - `"usps_first_class_certified"` - `"usps_first_class_certified_return_receipt"` - `"usps_first_class_registered"` - `"usps_express_3_day_signature_confirmation"` - `"usps_express_3_day_certified"` - `"usps_express_3_day_certified_return_receipt"` - `"ca_post_lettermail"` - `"ca_post_personalized"` - `"ca_post_neighbourhood_mail"` - `"ups_express_overnight"` - `"ups_express_2_day"` - `"ups_express_3_day"` - `"royal_mail_first_class"` - `"royal_mail_second_class"` - `"au_post_second_class"` - `object: Literal["postcard"]` Always `postcard`. - `"postcard"` - `send_date: datetime` 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. - `size: PostcardSize` Enum representing the supported postcard sizes. - `"6x4"` - `"9x6"` - `"11x6"` - `status: Literal["ready", "printing", "processed_for_delivery", 2 more]` See `OrderStatus` for more details on the status of this order. - `"ready"` - `"printing"` - `"processed_for_delivery"` - `"completed"` - `"cancelled"` - `to: Contact` The recipient of this order. This will be provided even if you delete the underlying contact. - `id: str` A unique ID prefixed with contact_ - `address_line1: str` The first line of the contact's address. - `address_status: Literal["verified", "corrected", "failed"]` One of `verified`, `corrected`, or `failed`. - `"verified"` - `"corrected"` - `"failed"` - `country_code: str` The ISO 3611-1 country code of the contact's address. - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `object: Literal["contact"]` Always `contact`. - `"contact"` - `updated_at: datetime` The UTC time at which this resource was last updated. - `address_errors: Optional[str]` A series of human-readable errors/warnings that were raised when running the provided address through our address verification. - `address_line2: Optional[str]` Second line of the contact's address, if applicable. - `city: Optional[str]` The city of the contact's address. - `company_name: Optional[str]` Company name of the contact. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `email: Optional[str]` Email of the contact. - `first_name: Optional[str]` First name of the contact. - `force_verified_status: Optional[bool]` If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise. - `job_title: Optional[str]` Job title of the contact. - `last_name: Optional[str]` Last name of the contact. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `phone_number: Optional[str]` Phone number of the contact. - `postal_or_zip: Optional[str]` The postal or ZIP code of the contact's address. - `province_or_state: Optional[str]` Province or state of the contact's address. - `skip_verification: Optional[bool]` If `true`, PostGrid will skip running this contact's address through our address verification system. - `updated_at: datetime` The UTC time at which this resource was last updated. - `cancellation: Optional[Cancellation]` The cancellation details of this order. Populated if the order has been cancelled. - `reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"]` The reason for the cancellation. - `"user_initiated"` - `"invalid_content"` - `"invalid_order_mailing_class"` - `cancelled_by_user: Optional[str]` The user ID who cancelled the order. - `note: Optional[str]` An optional note provided by the user who cancelled the order. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `from_: Optional[Contact]` The contact information of the sender. - `imb_date: Optional[datetime]` The last date that the IMB status was updated. See `imbStatus` for more details. - `imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "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. - `"entered_mail_stream"` - `"out_for_delivery"` - `"returned_to_sender"` - `imb_zip_code: Optional[str]` The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present. - `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. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `tracking_number: Optional[str]` The tracking number of this order. Populated after an express/certified order has been processed for delivery. - `url: Optional[str]` 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. ### Example ```python 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="Back", front_html="Front", size="6x4", to="contact_456", from_="contact_123", ) print(postcard.id) ``` #### Response ```json { "id": "postcard_123456", "object": "postcard", "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": "6x4", "sendDate": "2020-11-12T23:23:47.974Z", "createdAt": "2020-11-12T23:23:47.974Z", "updatedAt": "2020-11-12T23:23:47.974Z", "mailingClass": "first_class" } ``` ## List Postcards `print_mail.postcards.list(PostcardListParams**kwargs) -> SyncSkipLimit[Postcard]` **get** `/print-mail/v1/postcards` Get a list of postcards. ### Parameters - `limit: Optional[int]` - `search: Optional[str]` You can supply any string to help narrow down the list of resources. For example, if you pass `"New York"` (quoted), it will return resources that have that string present somewhere in their response. Alternatively, you can supply a structured search query. See the documentation on `StructuredSearchQuery` for more details. - `skip: Optional[int]` ### Returns - `class Postcard: …` - `id: str` A unique ID prefixed with postcard_ - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `mailing_class: Literal["first_class", "standard_class", "express", 23 more]` The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details. - `"first_class"` - `"standard_class"` - `"express"` - `"certified"` - `"certified_return_receipt"` - `"registered"` - `"usps_first_class"` - `"usps_standard_class"` - `"usps_eddm"` - `"usps_express_2_day"` - `"usps_express_3_day"` - `"usps_first_class_certified"` - `"usps_first_class_certified_return_receipt"` - `"usps_first_class_registered"` - `"usps_express_3_day_signature_confirmation"` - `"usps_express_3_day_certified"` - `"usps_express_3_day_certified_return_receipt"` - `"ca_post_lettermail"` - `"ca_post_personalized"` - `"ca_post_neighbourhood_mail"` - `"ups_express_overnight"` - `"ups_express_2_day"` - `"ups_express_3_day"` - `"royal_mail_first_class"` - `"royal_mail_second_class"` - `"au_post_second_class"` - `object: Literal["postcard"]` Always `postcard`. - `"postcard"` - `send_date: datetime` 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. - `size: PostcardSize` Enum representing the supported postcard sizes. - `"6x4"` - `"9x6"` - `"11x6"` - `status: Literal["ready", "printing", "processed_for_delivery", 2 more]` See `OrderStatus` for more details on the status of this order. - `"ready"` - `"printing"` - `"processed_for_delivery"` - `"completed"` - `"cancelled"` - `to: Contact` The recipient of this order. This will be provided even if you delete the underlying contact. - `id: str` A unique ID prefixed with contact_ - `address_line1: str` The first line of the contact's address. - `address_status: Literal["verified", "corrected", "failed"]` One of `verified`, `corrected`, or `failed`. - `"verified"` - `"corrected"` - `"failed"` - `country_code: str` The ISO 3611-1 country code of the contact's address. - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `object: Literal["contact"]` Always `contact`. - `"contact"` - `updated_at: datetime` The UTC time at which this resource was last updated. - `address_errors: Optional[str]` A series of human-readable errors/warnings that were raised when running the provided address through our address verification. - `address_line2: Optional[str]` Second line of the contact's address, if applicable. - `city: Optional[str]` The city of the contact's address. - `company_name: Optional[str]` Company name of the contact. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `email: Optional[str]` Email of the contact. - `first_name: Optional[str]` First name of the contact. - `force_verified_status: Optional[bool]` If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise. - `job_title: Optional[str]` Job title of the contact. - `last_name: Optional[str]` Last name of the contact. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `phone_number: Optional[str]` Phone number of the contact. - `postal_or_zip: Optional[str]` The postal or ZIP code of the contact's address. - `province_or_state: Optional[str]` Province or state of the contact's address. - `skip_verification: Optional[bool]` If `true`, PostGrid will skip running this contact's address through our address verification system. - `updated_at: datetime` The UTC time at which this resource was last updated. - `cancellation: Optional[Cancellation]` The cancellation details of this order. Populated if the order has been cancelled. - `reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"]` The reason for the cancellation. - `"user_initiated"` - `"invalid_content"` - `"invalid_order_mailing_class"` - `cancelled_by_user: Optional[str]` The user ID who cancelled the order. - `note: Optional[str]` An optional note provided by the user who cancelled the order. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `from_: Optional[Contact]` The contact information of the sender. - `imb_date: Optional[datetime]` The last date that the IMB status was updated. See `imbStatus` for more details. - `imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "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. - `"entered_mail_stream"` - `"out_for_delivery"` - `"returned_to_sender"` - `imb_zip_code: Optional[str]` The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present. - `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. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `tracking_number: Optional[str]` The tracking number of this order. Populated after an express/certified order has been processed for delivery. - `url: Optional[str]` 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. ### Example ```python 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 ) page = client.print_mail.postcards.list() page = page.data[0] print(page.id) ``` #### Response ```json { "object": "list", "limit": 10, "skip": 0, "totalCount": 1, "data": [ { "id": "postcard_123456", "object": "postcard", "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": "6x4", "sendDate": "2020-11-12T23:23:47.974Z", "createdAt": "2020-11-12T23:23:47.974Z", "updatedAt": "2020-11-12T23:23:47.974Z", "mailingClass": "first_class" } ] } ``` ## Get Postcard `print_mail.postcards.retrieve(strid) -> Postcard` **get** `/print-mail/v1/postcards/{id}` Retrieve a postcard by ID. ### Parameters - `id: str` ### Returns - `class Postcard: …` - `id: str` A unique ID prefixed with postcard_ - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `mailing_class: Literal["first_class", "standard_class", "express", 23 more]` The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details. - `"first_class"` - `"standard_class"` - `"express"` - `"certified"` - `"certified_return_receipt"` - `"registered"` - `"usps_first_class"` - `"usps_standard_class"` - `"usps_eddm"` - `"usps_express_2_day"` - `"usps_express_3_day"` - `"usps_first_class_certified"` - `"usps_first_class_certified_return_receipt"` - `"usps_first_class_registered"` - `"usps_express_3_day_signature_confirmation"` - `"usps_express_3_day_certified"` - `"usps_express_3_day_certified_return_receipt"` - `"ca_post_lettermail"` - `"ca_post_personalized"` - `"ca_post_neighbourhood_mail"` - `"ups_express_overnight"` - `"ups_express_2_day"` - `"ups_express_3_day"` - `"royal_mail_first_class"` - `"royal_mail_second_class"` - `"au_post_second_class"` - `object: Literal["postcard"]` Always `postcard`. - `"postcard"` - `send_date: datetime` 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. - `size: PostcardSize` Enum representing the supported postcard sizes. - `"6x4"` - `"9x6"` - `"11x6"` - `status: Literal["ready", "printing", "processed_for_delivery", 2 more]` See `OrderStatus` for more details on the status of this order. - `"ready"` - `"printing"` - `"processed_for_delivery"` - `"completed"` - `"cancelled"` - `to: Contact` The recipient of this order. This will be provided even if you delete the underlying contact. - `id: str` A unique ID prefixed with contact_ - `address_line1: str` The first line of the contact's address. - `address_status: Literal["verified", "corrected", "failed"]` One of `verified`, `corrected`, or `failed`. - `"verified"` - `"corrected"` - `"failed"` - `country_code: str` The ISO 3611-1 country code of the contact's address. - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `object: Literal["contact"]` Always `contact`. - `"contact"` - `updated_at: datetime` The UTC time at which this resource was last updated. - `address_errors: Optional[str]` A series of human-readable errors/warnings that were raised when running the provided address through our address verification. - `address_line2: Optional[str]` Second line of the contact's address, if applicable. - `city: Optional[str]` The city of the contact's address. - `company_name: Optional[str]` Company name of the contact. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `email: Optional[str]` Email of the contact. - `first_name: Optional[str]` First name of the contact. - `force_verified_status: Optional[bool]` If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise. - `job_title: Optional[str]` Job title of the contact. - `last_name: Optional[str]` Last name of the contact. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `phone_number: Optional[str]` Phone number of the contact. - `postal_or_zip: Optional[str]` The postal or ZIP code of the contact's address. - `province_or_state: Optional[str]` Province or state of the contact's address. - `skip_verification: Optional[bool]` If `true`, PostGrid will skip running this contact's address through our address verification system. - `updated_at: datetime` The UTC time at which this resource was last updated. - `cancellation: Optional[Cancellation]` The cancellation details of this order. Populated if the order has been cancelled. - `reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"]` The reason for the cancellation. - `"user_initiated"` - `"invalid_content"` - `"invalid_order_mailing_class"` - `cancelled_by_user: Optional[str]` The user ID who cancelled the order. - `note: Optional[str]` An optional note provided by the user who cancelled the order. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `from_: Optional[Contact]` The contact information of the sender. - `imb_date: Optional[datetime]` The last date that the IMB status was updated. See `imbStatus` for more details. - `imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "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. - `"entered_mail_stream"` - `"out_for_delivery"` - `"returned_to_sender"` - `imb_zip_code: Optional[str]` The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present. - `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. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `tracking_number: Optional[str]` The tracking number of this order. Populated after an express/certified order has been processed for delivery. - `url: Optional[str]` 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. ### Example ```python 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.retrieve( "id", ) print(postcard.id) ``` #### Response ```json { "id": "postcard_123456", "object": "postcard", "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": "6x4", "sendDate": "2020-11-12T23:23:47.974Z", "createdAt": "2020-11-12T23:23:47.974Z", "updatedAt": "2020-11-12T23:23:47.974Z", "mailingClass": "first_class" } ``` ## Cancel Postcard `print_mail.postcards.delete(strid) -> Postcard` **delete** `/print-mail/v1/postcards/{id}` Cancel a postcard by ID. Note that this operation cannot be undone. ### Parameters - `id: str` ### Returns - `class Postcard: …` - `id: str` A unique ID prefixed with postcard_ - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `mailing_class: Literal["first_class", "standard_class", "express", 23 more]` The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details. - `"first_class"` - `"standard_class"` - `"express"` - `"certified"` - `"certified_return_receipt"` - `"registered"` - `"usps_first_class"` - `"usps_standard_class"` - `"usps_eddm"` - `"usps_express_2_day"` - `"usps_express_3_day"` - `"usps_first_class_certified"` - `"usps_first_class_certified_return_receipt"` - `"usps_first_class_registered"` - `"usps_express_3_day_signature_confirmation"` - `"usps_express_3_day_certified"` - `"usps_express_3_day_certified_return_receipt"` - `"ca_post_lettermail"` - `"ca_post_personalized"` - `"ca_post_neighbourhood_mail"` - `"ups_express_overnight"` - `"ups_express_2_day"` - `"ups_express_3_day"` - `"royal_mail_first_class"` - `"royal_mail_second_class"` - `"au_post_second_class"` - `object: Literal["postcard"]` Always `postcard`. - `"postcard"` - `send_date: datetime` 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. - `size: PostcardSize` Enum representing the supported postcard sizes. - `"6x4"` - `"9x6"` - `"11x6"` - `status: Literal["ready", "printing", "processed_for_delivery", 2 more]` See `OrderStatus` for more details on the status of this order. - `"ready"` - `"printing"` - `"processed_for_delivery"` - `"completed"` - `"cancelled"` - `to: Contact` The recipient of this order. This will be provided even if you delete the underlying contact. - `id: str` A unique ID prefixed with contact_ - `address_line1: str` The first line of the contact's address. - `address_status: Literal["verified", "corrected", "failed"]` One of `verified`, `corrected`, or `failed`. - `"verified"` - `"corrected"` - `"failed"` - `country_code: str` The ISO 3611-1 country code of the contact's address. - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `object: Literal["contact"]` Always `contact`. - `"contact"` - `updated_at: datetime` The UTC time at which this resource was last updated. - `address_errors: Optional[str]` A series of human-readable errors/warnings that were raised when running the provided address through our address verification. - `address_line2: Optional[str]` Second line of the contact's address, if applicable. - `city: Optional[str]` The city of the contact's address. - `company_name: Optional[str]` Company name of the contact. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `email: Optional[str]` Email of the contact. - `first_name: Optional[str]` First name of the contact. - `force_verified_status: Optional[bool]` If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise. - `job_title: Optional[str]` Job title of the contact. - `last_name: Optional[str]` Last name of the contact. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `phone_number: Optional[str]` Phone number of the contact. - `postal_or_zip: Optional[str]` The postal or ZIP code of the contact's address. - `province_or_state: Optional[str]` Province or state of the contact's address. - `skip_verification: Optional[bool]` If `true`, PostGrid will skip running this contact's address through our address verification system. - `updated_at: datetime` The UTC time at which this resource was last updated. - `cancellation: Optional[Cancellation]` The cancellation details of this order. Populated if the order has been cancelled. - `reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"]` The reason for the cancellation. - `"user_initiated"` - `"invalid_content"` - `"invalid_order_mailing_class"` - `cancelled_by_user: Optional[str]` The user ID who cancelled the order. - `note: Optional[str]` An optional note provided by the user who cancelled the order. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `from_: Optional[Contact]` The contact information of the sender. - `imb_date: Optional[datetime]` The last date that the IMB status was updated. See `imbStatus` for more details. - `imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "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. - `"entered_mail_stream"` - `"out_for_delivery"` - `"returned_to_sender"` - `imb_zip_code: Optional[str]` The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present. - `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. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `tracking_number: Optional[str]` The tracking number of this order. Populated after an express/certified order has been processed for delivery. - `url: Optional[str]` 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. ### Example ```python 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.delete( "id", ) print(postcard.id) ``` #### Response ```json { "id": "postcard_123456", "object": "postcard", "status": "cancelled", "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": "6x4", "sendDate": "2020-11-12T23:23:47.974Z", "createdAt": "2020-11-12T23:23:47.974Z", "updatedAt": "2020-11-12T23:23:47.974Z", "mailingClass": "first_class" } ``` ## Get Postcard Preview `print_mail.postcards.retrieve_url(strid) -> PostcardRetrieveURLResponse` **get** `/print-mail/v1/postcards/{id}/url` Retrieve a postcard preview URL. This is only available for customers with our document management addon, which offers document generation and hosting capabilities. This endpoint has a much higher rate limit than the regular order retrieval endpoint, so it is suitable for customer-facing use-cases. ### Parameters - `id: str` ### Returns - `class PostcardRetrieveURLResponse: …` - `id: str` A unique ID prefixed with postcard_ - `object: str` - `url: str` A signed URL linking to the order preview PDF. The link remains valid for 15 minutes from the time of the API call. ### Example ```python 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 ) response = client.print_mail.postcards.retrieve_url( "id", ) print(response.id) ``` #### Response ```json { "id": "postcard_123456", "object": "postcard_url", "url": "https://pg-prod-bucket-1.s3.amazonaws.com/test/postcard_uzTtdAPiBVC25hjEYDvyLk?AWSAccessKeyId=AKIA5GFUILSULWTWCR64&Expires=1736192587&Signature=GS6kJK3fgWWy49jq1Yb%2FRn%2BQjD4%3D" } ``` ## Domain Types ### Postcard - `class Postcard: …` - `id: str` A unique ID prefixed with postcard_ - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `mailing_class: Literal["first_class", "standard_class", "express", 23 more]` The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details. - `"first_class"` - `"standard_class"` - `"express"` - `"certified"` - `"certified_return_receipt"` - `"registered"` - `"usps_first_class"` - `"usps_standard_class"` - `"usps_eddm"` - `"usps_express_2_day"` - `"usps_express_3_day"` - `"usps_first_class_certified"` - `"usps_first_class_certified_return_receipt"` - `"usps_first_class_registered"` - `"usps_express_3_day_signature_confirmation"` - `"usps_express_3_day_certified"` - `"usps_express_3_day_certified_return_receipt"` - `"ca_post_lettermail"` - `"ca_post_personalized"` - `"ca_post_neighbourhood_mail"` - `"ups_express_overnight"` - `"ups_express_2_day"` - `"ups_express_3_day"` - `"royal_mail_first_class"` - `"royal_mail_second_class"` - `"au_post_second_class"` - `object: Literal["postcard"]` Always `postcard`. - `"postcard"` - `send_date: datetime` 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. - `size: PostcardSize` Enum representing the supported postcard sizes. - `"6x4"` - `"9x6"` - `"11x6"` - `status: Literal["ready", "printing", "processed_for_delivery", 2 more]` See `OrderStatus` for more details on the status of this order. - `"ready"` - `"printing"` - `"processed_for_delivery"` - `"completed"` - `"cancelled"` - `to: Contact` The recipient of this order. This will be provided even if you delete the underlying contact. - `id: str` A unique ID prefixed with contact_ - `address_line1: str` The first line of the contact's address. - `address_status: Literal["verified", "corrected", "failed"]` One of `verified`, `corrected`, or `failed`. - `"verified"` - `"corrected"` - `"failed"` - `country_code: str` The ISO 3611-1 country code of the contact's address. - `created_at: datetime` The UTC time at which this resource was created. - `live: bool` `true` if this is a live mode resource else `false`. - `object: Literal["contact"]` Always `contact`. - `"contact"` - `updated_at: datetime` The UTC time at which this resource was last updated. - `address_errors: Optional[str]` A series of human-readable errors/warnings that were raised when running the provided address through our address verification. - `address_line2: Optional[str]` Second line of the contact's address, if applicable. - `city: Optional[str]` The city of the contact's address. - `company_name: Optional[str]` Company name of the contact. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `email: Optional[str]` Email of the contact. - `first_name: Optional[str]` First name of the contact. - `force_verified_status: Optional[bool]` If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise. - `job_title: Optional[str]` Job title of the contact. - `last_name: Optional[str]` Last name of the contact. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `phone_number: Optional[str]` Phone number of the contact. - `postal_or_zip: Optional[str]` The postal or ZIP code of the contact's address. - `province_or_state: Optional[str]` Province or state of the contact's address. - `skip_verification: Optional[bool]` If `true`, PostGrid will skip running this contact's address through our address verification system. - `updated_at: datetime` The UTC time at which this resource was last updated. - `cancellation: Optional[Cancellation]` The cancellation details of this order. Populated if the order has been cancelled. - `reason: Literal["user_initiated", "invalid_content", "invalid_order_mailing_class"]` The reason for the cancellation. - `"user_initiated"` - `"invalid_content"` - `"invalid_order_mailing_class"` - `cancelled_by_user: Optional[str]` The user ID who cancelled the order. - `note: Optional[str]` An optional note provided by the user who cancelled the order. - `description: Optional[str]` An optional string describing this resource. Will be visible in the API and the dashboard. - `from_: Optional[Contact]` The contact information of the sender. - `imb_date: Optional[datetime]` The last date that the IMB status was updated. See `imbStatus` for more details. - `imb_status: Optional[Literal["entered_mail_stream", "out_for_delivery", "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. - `"entered_mail_stream"` - `"out_for_delivery"` - `"returned_to_sender"` - `imb_zip_code: Optional[str]` The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present. - `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. - `metadata: Optional[Dict[str, object]]` See the section on Metadata. - `tracking_number: Optional[str]` The tracking number of this order. Populated after an express/certified order has been processed for delivery. - `url: Optional[str]` 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.