# Blueshift

### Before You Start <a href="#before-you-start" id="before-you-start"></a>

Make sure you’ve completed the following in Poplar:

* Create a **Campaign** in Poplar.
* Upload at least one **Creative** (a placeholder is fine for testing).
* Locate your **Test Access Token** and **Production Access Token** on the **API** page of your Poplar account.

For webhook requests to successfully create or test mailers, the `campaign_id` you send must reference an **Active** Poplar campaign that has creative artwork uploaded.

***

### App Hub (Custom App) <a href="#app-hub-custom-app" id="app-hub-custom-app"></a>

1. In Blueshift, go to **App Hub → My Apps → +ADD CUSTOM APP**.
2. Name it (e.g., **Poplar Mail**).
3. Authentication: choose **Basic HTTP** and add the **HTTP Headers** as shown below.
4. (Optional) Upload a logo and save.

<figure><img src="https://docs.heypoplar.com/~gitbook/image?url=https%3A%2F%2F882964084-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FQQrKGAkEKUx55lzOfxs1%252Fuploads%252FIS466wc0Ci1vhPaQLINZ%252Fimage.png%3Falt%3Dmedia%26token%3D4c713391-b126-4f45-ac63-f93ed2f5fd81&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=e9a72b94&#x26;sv=2" alt="" width="563"><figcaption></figcaption></figure>

### Add an Adapter <a href="#add-an-adapter" id="add-an-adapter"></a>

1. Open your new **Poplar Mail** app → click **+ADAPTER**.
2. Enter the HTTP Headers exactly as pictured below. Copy and paste your Test API key from Poplar in the API Key section after "Bearer" (later the production API key will be used when you want to set the campaign live).
3. **Save** the adapter.

<figure><img src="https://docs.heypoplar.com/~gitbook/image?url=https%3A%2F%2F882964084-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FQQrKGAkEKUx55lzOfxs1%252Fuploads%252F76WuR7j6NBff27SBLuui%252Fimage.png%3Falt%3Dmedia%26token%3Da9056052-96b5-455b-ac1b-01cd5bd0dccf&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=68d1baa&#x26;sv=2" alt=""><figcaption></figcaption></figure>

You’ll select this adapter later in your Cloud App template and journey trigger.

### Cloud App Template (Payload) <a href="#cloud-app-template-payload" id="cloud-app-template-payload"></a>

1. Go to **Templates → Cloud App → +TEMPLATE** and choose your **Poplar Webhook** app.
2. **Properties → Settings**: select your **Adapter** and set **API Endpoint** to: `https://api.heypoplar.com/v1/mailing/`
3. **Advanced settings**:
   * **HTTP method**: `POST`
   * **HTTP headers**: add `Authorization: Bearer YOUR_TEST_OR_PRODUCTION_ACCESS_TOKEN`
   * Leave default `Content-Type: application/json`
   * (Optional) **Unique Sent Identifier** → choose `email` or `customer_id` to prevent duplicates.
4. Click the eye in the top right to pull up your user attributes for reference

   <figure><img src="https://docs.heypoplar.com/~gitbook/image?url=https%3A%2F%2F882964084-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FQQrKGAkEKUx55lzOfxs1%252Fuploads%252FNu0lSBn9dH0krjYqIGV6%252Fimage.png%3Falt%3Dmedia%26token%3Da6f91414-eee7-40da-bc28-8667232e2254&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=3bedb979&#x26;sv=2" alt=""><figcaption></figcaption></figure>
5. **Content**: set the **Payload** to JSON and paste one of the templates below.

Address DataEmails (for Address Enrichment)Copy

```
{
  "recipient": {
    "full_name": "{{user.firstname}} {{user.lastname}}", 
    "address_1": "{{user.address_line1}}",
    "address_2": "{{user.address_line2}}",
    "city": "{{user.address_city}}",
    "state": "{{user.address_state}}",
    "postal_code": "{{user.address_postal_code}}"
  },
  "campaign_id": "REPLACE-WITH-YOUR-CAMPAIGN-ID",
  "creative_id": "REPLACE-WITH-YOUR-CREATIVE-ID"
}
```

* Use Liquid to reference Blueshift **user** attributes (e.g., `{{user.firstname}}`).
* Replace `campaign_id` and `creative_id` with your Poplar values. If `creative_id` is omitted, Poplar will select the only active creative in the campaign, and if there are multiple active creatives they will all fire as an A/B test.

**Merge-tags (Optional):** If using custom merge tags for a dynamic creative, they should be listed within a merge\_tags object like so:

```
{
"recipient": {
    "email": "{{user.email}}"
},
"merge_tags": {
    "promo-code": "{{user.code}}"
},
"campaign_id": "REPLACE-WITH-YOUR-CAMPAIGN-ID",
"creative_id": "REPLACE-WITH-YOUR-CREATIVE-ID"
}
```

***

### Journey (Trigger) <a href="#journey-trigger" id="journey-trigger"></a>

1. Create or open a **Campaign** in Blueshift.
2. In **Journey** builder, choose the trigger type you need (e.g., **Event-triggered** for cart abandonment, **Segment-triggered** for lifecycle).
3. Add a **Cloud App** node. Select:
   * **Channel/App**: your **Poplar Webhook** app
   * **Adapter**: the adapter you created
   * **Template**: the Cloud App template you just built
4. Connect it in the flow where the mailer should be sent.
5. Validate and launch your Journey!

<figure><img src="https://docs.heypoplar.com/~gitbook/image?url=https%3A%2F%2F882964084-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FQQrKGAkEKUx55lzOfxs1%252Fuploads%252F8F9vd8avpqx1hMz2Udcf%252Fimage.png%3Falt%3Dmedia%26token%3Dcc56ddfa-5b20-4f94-a5e6-6a5b97cfb399&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=13304077&#x26;sv=2" alt=""><figcaption></figcaption></figure>

### Conditional / Decision Splits (optional) <a href="#conditional-decision-splits-optional" id="conditional-decision-splits-optional"></a>

If some customers have only email while others have full address data, branch your journey:

* Add a **Decision Split** that checks for presence of address fields (e.g., `user.address_1` and `user.postal_code`).
* **Path A** → Use **Template A (Email-only)** for Address Enrichment.
* **Path B** → Use **Template B (Address Data)** for direct mail.

Without a split, address-required calls may 400 if any required address attributes are missing.

### Test & Preview <a href="#test-and-preview" id="test-and-preview"></a>

There are two reliable ways to test in Blueshift:

**1) Test from the Cloud App Template**

* Open your template → **Test Send**.
* Pick a **Preview User** and send.
* Confirm a **201** response is returned
  * 400 indicates an error in the payload setup, or missing required data from the user's profile (address 1, city, postal code).

**2) Test from the Journey**

* In your campaign’s **Journey** tab, use **Test send message** on the Cloud App node.
* This method uses the **actual adapter + campaign context**, which is handy if you rely on campaign parameters.

### Validate the Connection in Poplar <a href="#validate-the-connection-in-poplar" id="validate-the-connection-in-poplar"></a>

* In your Poplar **Campaign**, scroll to the **History** section to see the test mailers.
* Click into a mailer to view the **PDF proof** and **Request Details**; verify the request matches the payload you built in Blueshift.
* If everything looks good, Edit your Adapter and enter your Poplar production API key to start sending mailers
