1. US Knowledge base
  2. API
  3. Third Party Intergration

How to Integrate the Stannp Send a Letter Endpoint with Shopify

This guide walks you through how to use Shopify to trigger the Send a Letter action through Stannp's API. You can automatically send personalized letters based on customer actions, such as order placement or customer registration.

Prerequisites

  1. Stannp Account & API Key:

    • Ensure you have a Stannp account and obtain your API key from Account Settings > API Keys on Stannp.
  2. Shopify Store:

    • Have an active Shopify store with customer data and relevant triggers (e.g., order placement or customer creation).
  3. Shopify App or Automation Tool (Optional):

    • For advanced automation, you can use tools like Zapier, Make.com, or Shopify's Flow to integrate webhooks between Shopify and Stannp.

Step-by-Step Integration Guide

Step 1: Create a Shopify Webhook or Use Shopify Flow

  1. Log in to Shopify Admin.

  2. If you're using Shopify Flow (for advanced automation), you can create a new flow to trigger the letter action. Alternatively, you can set up a Webhook for simpler use cases.

    • Flow Example:
      Trigger the flow when a new order is created, or when a new customer is added.
    • Webhook Example:
      Use the Shopify Webhook to monitor specific events (e.g., order creation, customer update).

Step 2: Set Up the Stannp API Endpoint for "Send a Letter"

When your Shopify event triggers, send a request to Stannp's Send a Letter endpoint.

Endpoint URL:

https://api-us1.stannp.com/v1/letters/create?api_key=YOUR_API_KEY

Step 3: Add Required Parameters in the API Call

The following parameters are required for the API call to create and send a letter:

  • recipient: This should be a customer’s address data, pulled from Shopify.
  • template: Use an existing template ID from Stannp, or specify a custom file.
  • Optional parameters: test, duplex, tags, and addons.

For example, using Shopify customer data, you might pass their name, address, and other details as recipient information:

Example API Request Body:

{
"recipient": {
"firstname": "",
"lastname": "",
"address1": "",
"city": "",
"postcode": "",
"country": ""
},
"template": 12345,
"test": false,
"duplex": true,
"tags": "shopify, new_order",
"addons": "FIRST_CLASS"
}

Notes on Parameters:

  • recipient: Use Shopify Liquid placeholders like to dynamically pass customer data from Shopify.
  • template: Use the Stannp template ID or leave it out if you are uploading a custom letter file using the file parameter.
  • test: Set this to true to test without sending the letter (this will generate a PDF sample).
  • duplex: Set to false if you only want the letter to be printed on the front.
  • tags: Optional tags to track the letter’s details in your Stannp dashboard.
  • addons: Use Stannp’s addon codes, such as FIRST_CLASS, for faster shipping.

Step 4: Send Data to Stannp via Webhook

You can use Shopify Flow or an external tool like Zapier or Make.com to send this data to Stannp's Send a Letter endpoint.

  1. In Shopify Flow:
    Add an HTTP request action to call the Stannp API. Use the webhook URL and include the payload with customer data, API key, and other parameters.

  2. In Zapier or Make.com:

    • Trigger: Select the appropriate Shopify event (e.g., New Order, Customer Created).
    • Action: Use a Webhooks action to make a POST request to Stannp’s endpoint.

Step 5: Test the Integration

  1. Create a test order or add a test customer in Shopify to trigger the workflow.
  2. Verify that Stannp receives the data and processes the letter.
  3. Check your Stannp dashboard to confirm the letter was created and dispatched successfully.

Example API Request for Stannp:

Here’s an example of the full request sent to Stannp’s API, with the API key query parameter for authentication:

POST https://api-us1.stannp.com/v1/letters/create?api_key=YOUR_API_KEY
{
"recipient": {
"firstname": "",
"lastname": "",
"address1": "",
"city": "",
"postcode": "",
"country": ""
},
"template": 12345,
"test": false,
"duplex": true,
"tags": "shopify, new_order",
"addons": "FIRST_CLASS"
}

Endpoint URL with API key:

POST https://api-us1.stannp.com/v1/letters/create?api_key=YOUR_API_KEY

Additional Notes:

  • Shopify Merge Tags: You can use Shopify Liquid placeholders (e.g., , ) to dynamically pass customer information to Stannp.
  • Stannp’s API Documentation: For more details on additional parameters and settings, check the official Stannp API documentation.

With this setup, Shopify will automatically trigger the creation of personalized letters through Stannp based on customer activity in your Shopify store. This makes it easy to automate physical communications like welcome letters, order confirmations, or thank you notes.


This integration allows you to bridge Shopify's digital customer experience with personalized direct mail, enhancing your customer engagement and automating your business processes.