1. UK Knowledge Base
  2. API
  3. Third Party Intergration

How to Set Up a Webhook in a HubSpot Workflow to Create a Postcard Using Stannp API

This article explains how to configure a webhook in a HubSpot workflow to create a postcard using the Stannp API.

Prerequisites

  1. API Key: Obtain your Stannp API key from your Stannp account.
  2. API Endpoint: Use the following endpoint for the webhook:
    https://api-eu1.stannp.com/v1/postcards/create
  3. Plan Requirements: Webhooks are available on HubSpot’s Professional or Enterprise plans.
  4. Permissions: You must have Super Admin permissions or sufficient access to workflows.

Steps to Create the Webhook

Step 1: Create or Open a Workflow

  1. Log in to your HubSpot account.
  2. Navigate to Automation > Workflows in the top menu.
  3. Create a new workflow or open an existing one.
  4. Select the type of workflow (e.g., contact-based, deal-based) and set enrollment triggers as needed.

Step 2: Add the Webhook Action

  1. Click the + button to add a new action in the workflow editor.
  2. Select Trigger a webhook.

Step 3: Configure the Webhook

Method and URL

  1. Set the Method to POST.
  2. Enter the following URL in the URL field, replacing YOUR_API_KEY with your Stannp API key:
    https://api-eu1.stannp.com/v1/postcards/create?api_key=YOUR_API_KEY

Body

Construct the request body. Depending on your use case, include either the template parameter or both the front and back parameters.

Example Body with Template:

{
"size": "A5-postcard",
  "test": true,
  "template": "TEMPLATE_ID",
  "recipient": {
    "title": "Mr.",
    "company": "ABC Corp",
    "firstname": "John",
    "lastname": "Doe",
    "address1": "123 Main Street",
    "address2": "",
  "city": "Barnstaple",
  "postcode": "EX311JZ",
  "country": "GB"
},
  "tags": "new customer, postcard campaign",
  "addons": "FIRST_CLASS"
}

Example Body with Front & Back Parameters:

{
"size": "A5-postcard",
"test": false,
"recipient": {
"title": "Ms.",
"firstname": "Jane",
"lastname": "Smith",
"address1": "456 Elm Street",
"city": "Barnstaple",
"postcode": "EX311JZ",
"country": "GB"
},
"front": "https://example.com/front_image.jpg",
"back": "https://example.com/back_image.jpg",
"signature": "https://example.com/signature_image.jpg",
"padding": 0,
"post_unverified": true,
"tags": "loyal customer",
"addons": "FIRST_CLASS"
}

Step 4: Customize with HubSpot Tokens

To make the request dynamic, replace static values in the body with HubSpot property tokens. For example:

  • Replace recipient[firstname] with Contact: First Name by clicking Insert token.
  • Repeat this for other fields like recipient[lastname], recipient[address1], etc.

Step 5: Test the Webhook

  1. Click the Test button in the webhook configuration panel.
  2. Send a test request using sample data.
  3. Review the response from the Stannp API to confirm that the request was successful.

Step 6: Save and Activate the Workflow

  1. Once you’ve configured and tested the webhook, click Save.
  2. Turn the workflow ON to start automating postcard creation.

Additional Notes

  • Error Handling: If the webhook fails, check the response error in the workflow log. Common issues include missing required parameters or incorrect formatting.
  • Testing Mode: Use the test parameter set to true for testing without actually sending a postcard.
  • Dynamic Tokens: Use HubSpot tokens for personalized and dynamic content.

By following these steps, you can automate postcard creation with the Stannp API directly from HubSpot workflows. For further assistance, contact your administrator or the Stannp support team.