---
title: How to Trigger a Marqet Workflow from Salesforce
description: Learn how to configure Salesforce webhooks to automatically trigger Marqet workflows when records update — including Opportunities, Contacts, and Accounts.
---

[Skip to content](https://help.marq.com/how-to-trigger-a-marqet-workflow-from-salesforce#main-content)

English

Show submenu for translations

<https://help.marq.com/kb-tickets/new?hsLang=en>

![marq.svg\]](https://help.marq.com/hubfs/Brand%20Logos/marq.svg)

Open main navigation

Close main navigation

- English
  
  Show submenu for translations
- <https://help.marq.com/kb-tickets/new>
- [Projects](https://app.marq.com/documents#/documents)

[Projects](https://app.marq.com/documents#/documents)

 How can we help?

- There are no suggestions because the search field is empty.

1. [Help Center](https://help.marq.com/?hsLang=en)
2. [Integrations](https://help.marq.com/integrations?hsLang=en)
3. [Salesforce](https://help.marq.com/integrations?hsLang=en#salesforce)

# How to Trigger a Marqet Workflow from Salesforce

## Use this guide to configure Salesforce to automatically send a webhook to Marqet when a record is updated. No third-party tools required. Everything is built using native Salesforce Apex and Named Credentials.

#### Prerequisites

- System Administrator access in Salesforce
- Your Marqet webhook URL (found in your Marqet workflow settings)
- Access to the Salesforce Developer Console

---

#### Step 1: Get your Marqet webhook URL

In Marqet, navigate to your workflow settings and copy the webhook receiver URL. It will look like this:

```
https://marqet.marq.com/api/webhooks/catch/[your-unique-id]
```

Keep this handy — you'll need it in step 5.

---

#### Step 2: Create an External Credential

In Salesforce, go to **Setup → Named Credentials → External Credentials tab → New**

| Field | Value |
| --- | --- |
| Label | `Marq_Webhook_Cred` |
| Name | `Marq_Webhook_Cred` |
| Authentication Protocol | `No Authentication` |

Save, then scroll down to **Principals → New**:

| Field | Value |
| --- | --- |
| Parameter Name | `anonymous` |
| Sequence Number | `1` |
| Identity Type | `Anonymous` |

Save.

---

#### Step 3: Create a Named Credential

In Salesforce, go to **Setup → Named Credentials → Named Credentials tab → New**

| Field | Value |
| --- | --- |
| Label | `Marq_Webhook` |
| Name | `Marq_Webhook` |
| URL | `https://marqet.marq.com` |
| External Credential | `Marq_Webhook_Cred` |

Save.

---

#### Step 4: Grant permission set access in Salesforce

Users who trigger the webhook need access to the External Credential.

1. Go to **Setup → Permission Sets → New**
2. Name it `Webhook_Access`, leave License as `--None--`, and save
3. Inside the permission set, click **External Credential Principal Access → Edit**
4. Move `Marq_Webhook_Cred - anonymous` to the Enabled column and save
5. Click **Manage Assignments → Add Assignment**, find your user, and assign

> **Note:** Any user or automation profile that updates records which trigger the webhook must be assigned this permission set.

---

#### Step 5: Deploy the Queueable Apex class

This class handles building the payload and sending the HTTP POST to Marqet. It runs asynchronously so it doesn't block the Salesforce record transaction.

In Salesforce, go to **Developer Console → File → New → Apex Class**, name it `WebhookQueueable`, and paste the code for your trigger type below.

---

### Option A: Opportunity stage change (e.g. Closed Won)

**`WebhookQueueable.cls`** 

 apex

```
public class WebhookQueueable implements Queueable, Database.AllowsCallouts {     private List<Id> recordIds;      public WebhookQueueable(List<Id> ids) {         this.recordIds = ids;     }      public void execute(QueueableContext ctx) {         for (Id rId : recordIds) {             Opportunity opp = [SELECT Id, Name, StageName, Amount,                                        AccountId, OwnerId, CloseDate                                FROM Opportunity                                WHERE Id = :rId LIMIT 1];              Map<String, Object> payload = new Map<String, Object>{                 'event'         => 'opportunity.closed_won',                 'opportunityId' => opp.Id,                 'name'          => opp.Name,                 'stage'         => opp.StageName,                 'amount'        => opp.Amount,                 'accountId'     => opp.AccountId,                 'ownerId'       => opp.OwnerId,                 'closeDate'     => String.valueOf(opp.CloseDate),                 'changedAt'     => System.now().format()             };              HttpRequest req = new HttpRequest();             req.setEndpoint('callout:Marq_Webhook/api/webhooks/catch/[your-unique-id]');             req.setMethod('POST');             req.setHeader('Content-Type', 'application/json');             req.setBody(JSON.serialize(payload));              Http http = new Http();             HttpResponse res = http.send(req);             System.debug('Webhook response: ' + res.getStatusCode());         }     } }
```

**`OpportunityWebhookTrigger.apxt`** (File → New → Apex Trigger, sObject: Opportunity) 

 apex

```
trigger OpportunityWebhookTrigger on Opportunity (after update) {     List<Id> changedIds = new List<Id>();      for (Opportunity newRec : Trigger.new) {         Opportunity oldRec = Trigger.oldMap.get(newRec.Id);          // Only fires when stage CHANGES to Closed Won         if (newRec.StageName != oldRec.StageName             && newRec.StageName == 'Closed Won') {             changedIds.add(newRec.Id);         }     }      if (!changedIds.isEmpty()) {         System.enqueueJob(new WebhookQueueable(changedIds));     } }
```

**Example payload received by Marqet:** 

 json

```
{   "event": "opportunity.closed_won",   "opportunityId": "006...",   "name": "Acme Corp Deal",   "stage": "Closed Won",   "amount": 15000,   "accountId": "001...",   "ownerId": "005...",   "closeDate": "2026-05-27",   "changedAt": "2026-05-27 17:59:44" }
```

---

### Option B: Contact field change (e.g. status becomes Business Partner)

Update `WebhookQueueable.cls` with the following execute method, or create a second class (e.g. `ContactWebhookQueueable`) if you need both running simultaneously:

**`WebhookQueueable.cls`** (Contact version)

 apex

```
public class WebhookQueueable implements Queueable, Database.AllowsCallouts {     private List<Id> recordIds;      public WebhookQueueable(List<Id> ids) {         this.recordIds = ids;     }      public void execute(QueueableContext ctx) {         for (Id rId : recordIds) {             Contact c = [SELECT Id, FirstName, LastName, Email,                                 AccountId, Title, Phone                          FROM Contact                          WHERE Id = :rId LIMIT 1];              Map<String, Object> payload = new Map<String, Object>{                 'event'       => 'contact.status_changed',                 'contactId'   => c.Id,                 'firstName'   => c.FirstName,                 'lastName'    => c.LastName,                 'email'       => c.Email,                 'title'       => c.Title,                 'phone'       => c.Phone,                 'accountId'   => c.AccountId,                 'changedAt'   => System.now().format()             };              HttpRequest req = new HttpRequest();             req.setEndpoint('callout:Marq_Webhook/api/webhooks/catch/[your-unique-id]');             req.setMethod('POST');             req.setHeader('Content-Type', 'application/json');             req.setBody(JSON.serialize(payload));              Http http = new Http();             HttpResponse res = http.send(req);             System.debug('Webhook response: ' + res.getStatusCode());         }     } }
```

**`ContactWebhookTrigger.apxt`** (File → New → Apex Trigger, sObject: Contact)

 apex

```
trigger ContactWebhookTrigger on Contact (after update) {     List<Id> changedIds = new List<Id>();      for (Contact newRec : Trigger.new) {         Contact oldRec = Trigger.oldMap.get(newRec.Id);          // Fires when Partner_Status__c changes to "Business Partner"         // Replace Partner_Status__c with your actual field API name         if (newRec.Partner_Status__c != oldRec.Partner_Status__c             && newRec.Partner_Status__c == 'Business Partner') {             changedIds.add(newRec.Id);         }     }      if (!changedIds.isEmpty()) {         System.enqueueJob(new WebhookQueueable(changedIds));     } }
```

**Example payload received by Marqet:**

 json

```
{   "event": "contact.status_changed",   "contactId": "003...",   "firstName": "Jane",   "lastName": "Smith",   "email": "jane.smith@example.com",   "title": "VP of Partnerships",   "phone": "+1 (415) 555-0100",   "accountId": "001...",   "changedAt": "2026-05-27 17:59:44" }
```

> **Tip:** The field `Partner_Status__c` is an example custom field name. Replace it with the actual API name of the field in your Salesforce org. You can find this under **Setup → Object Manager → Contact → Fields & Relationships**.

---

### Option C: Account field change (e.g. Type changes to Partner)

**`AccountWebhookTrigger.apxt`** (File → New → Apex Trigger, sObject: Account)

 apex

```
trigger AccountWebhookTrigger on Account (after update) {     List<Id> changedIds = new List<Id>();      for (Account newRec : Trigger.new) {         Account oldRec = Trigger.oldMap.get(newRec.Id);          // Fires when Type changes to "Partner"         if (newRec.Type != oldRec.Type             && newRec.Type == 'Partner') {             changedIds.add(newRec.Id);         }     }      if (!changedIds.isEmpty()) {         System.enqueueJob(new WebhookQueueable(changedIds));     } }
```

Update `WebhookQueueable.cls` to query Account fields instead:

 apex

```
Account acc = [SELECT Id, Name, Type, Industry, OwnerId, BillingCity, BillingCountry                FROM Account WHERE Id = :rId LIMIT 1];  Map<String, Object> payload = new Map<String, Object>{     'event'     => 'account.type_changed',     'accountId' => acc.Id,     'name'      => acc.Name,     'type'      => acc.Type,     'industry'  => acc.Industry,     'ownerId'   => acc.OwnerId,     'city'      => acc.BillingCity,     'country'   => acc.BillingCountry,     'changedAt' => System.now().format() };
```

---

#### Step 6: Test the integration

To verify the connection before testing a live record, run this in **Developer Console → Debug → Open Execute Anonymous Window**: 

 apex

```
HttpRequest req = new HttpRequest(); req.setEndpoint('callout:Marq_Webhook/api/webhooks/catch/[your-unique-id]'); req.setMethod('POST'); req.setHeader('Content-Type', 'application/json'); req.setBody('{"event": "test", "message": "Salesforce connection test"}');  Http http = new Http(); HttpResponse res = http.send(req); System.debug('Status: ' + res.getStatusCode()); System.debug('Body: ' + res.getBody());
```

Check the **Logs** tab — you want to see `Status: 200`. If Marqet receives the payload, the Named Credential is configured correctly.

Then do a live record test:

1. Open an Opportunity (or Contact/Account depending on your trigger)
2. Update the relevant field and save
3. Check your Marqet workflow — the trigger should fire within a few seconds

---

#### Troubleshooting

| Error | Likely cause | Fix |
| --- | --- | --- |
| `We couldn't access the credential` | Permission set not assigned | Assign `Webhook_Access` permission set to the user (step 4) |
| `Duplicate value found` on deploy | Class or trigger already exists | Open the existing file via **File → Open** and overwrite the code |
| No payload in Marqet after record save | Trigger condition not met, or wrong field name | Check the Developer Console log for a `USER_DEBUG` line with the HTTP status |
| `Status: 404` | Webhook path mismatch | Verify the path in your Apex class matches your Marqet URL exactly |
| `Status: 401` or `403` | Auth issue on Marqet's side | Confirm the webhook URL is active in your Marqet workflow settings |

---

#### Customizing the trigger condition

The trigger fires based on a field value change. The general pattern is:

 apex

```
if (newRec.YOUR_FIELD__c != oldRec.YOUR_FIELD__c     && newRec.YOUR_FIELD__c == 'YOUR_TARGET_VALUE') {     changedIds.add(newRec.Id); }
```

To find the correct API field name, go to **Setup → Object Manager → \[Object\] → Fields & Relationships** and look in the **Field Name** column.

You can also trigger on any field change without requiring a specific value:

 apex

```
// Fires whenever the field changes to anything if (newRec.YOUR_FIELD__c != oldRec.YOUR_FIELD__c) {     changedIds.add(newRec.Id); }
```

---

#### Adding payload fields

To include additional Salesforce fields in the payload sent to Marqet, add them to the `SELECT` query in `WebhookQueueable` and the `payload` map:

 apex

```
// In the SELECT: Contact c = [SELECT Id, Email, Custom_Field__c FROM Contact WHERE Id = :rId LIMIT 1];  // In the payload map: 'customField' => c.Custom_Field__c,
```

---

*For questions or setup support, contact the Support team at [support@marq.com](mailto:support@marq.com)*

- [Intro to Marq](https://help.marq.com/intro-to-marq?hsLang=en#main-content)

    - [Getting started](https://help.marq.com/intro-to-marq?hsLang=en#getting-started)
    - [Tips and tricks](https://help.marq.com/intro-to-marq?hsLang=en#tips-and-tricks)
    - [Common issues](https://help.marq.com/intro-to-marq?hsLang=en#common-issues)
    - [Get support](https://help.marq.com/intro-to-marq?hsLang=en#get-support)
    - [Other resources](https://help.marq.com/intro-to-marq?hsLang=en#other-resources)
- [Content AI](https://help.marq.com/content-ai?hsLang=en#main-content)

    - [AI Assistant](https://help.marq.com/content-ai?hsLang=en#ai-assistant)
    - [AI Marqet](https://help.marq.com/content-ai?hsLang=en#ai-marqet)
    - [Brand Guardian](https://help.marq.com/content-ai?hsLang=en#brand-guardian)
- [Account setup and billing](https://help.marq.com/account-setup-and-billing?hsLang=en#main-content)

    - [Account settings](https://help.marq.com/account-setup-and-billing?hsLang=en#account-settings)
    - [Storage](https://help.marq.com/account-setup-and-billing?hsLang=en#storage)
    - [Billing and plans](https://help.marq.com/account-setup-and-billing?hsLang=en#billing-and-plans)
    - [Privacy and security](https://help.marq.com/account-setup-and-billing?hsLang=en#privacy-and-security)
- [Creating your design](https://help.marq.com/creating-your-design?hsLang=en#main-content)

    - [The Editor](https://help.marq.com/creating-your-design?hsLang=en#the-editor)
    - [Document and page settings](https://help.marq.com/creating-your-design?hsLang=en#document-and-page-settings)
    - [Templates](https://help.marq.com/creating-your-design?hsLang=en#templates)
    - [Images](https://help.marq.com/creating-your-design?hsLang=en#images)
    - [Text](https://help.marq.com/creating-your-design?hsLang=en#text)
    - [Shapes and graphics](https://help.marq.com/creating-your-design?hsLang=en#shapes-and-graphics)
    - [Layers and objects](https://help.marq.com/creating-your-design?hsLang=en#layers-and-objects)
    - [Elements](https://help.marq.com/creating-your-design?hsLang=en#elements)
    - [Video and interactive objects](https://help.marq.com/creating-your-design?hsLang=en#video-and-interactive-objects)
    - [Tables](https://help.marq.com/creating-your-design?hsLang=en#tables)
    - [Locking](https://help.marq.com/creating-your-design?hsLang=en#locking)
    - [Uploading](https://help.marq.com/creating-your-design?hsLang=en#uploading)
    - [Automation and other advanced features](https://help.marq.com/creating-your-design?hsLang=en#automation-and-other-advanced-features)
- [Exporting and sharing](https://help.marq.com/exporting-and-sharing?hsLang=en#main-content)

    - [Collaborate](https://help.marq.com/exporting-and-sharing?hsLang=en#collaborate)
    - [Export to social media](https://help.marq.com/exporting-and-sharing?hsLang=en#export-to-social-media)
    - [Embedding](https://help.marq.com/exporting-and-sharing?hsLang=en#embedding)
    - [Publishing](https://help.marq.com/exporting-and-sharing?hsLang=en#publishing)
    - [Printing](https://help.marq.com/exporting-and-sharing?hsLang=en#printing)
    - [Downloading](https://help.marq.com/exporting-and-sharing?hsLang=en#downloading)
    - [GIFs](https://help.marq.com/exporting-and-sharing?hsLang=en#gifs)
- [Admin settings and team management](https://help.marq.com/admin-settings-and-team-management?hsLang=en#main-content)

    - [Managing your team](https://help.marq.com/admin-settings-and-team-management?hsLang=en#managing-your-team)
    - [Licensing and roles](https://help.marq.com/admin-settings-and-team-management?hsLang=en#licensing-and-roles)
    - [Brand assets](https://help.marq.com/admin-settings-and-team-management?hsLang=en#brand-assets)
    - [User experience and workflows](https://help.marq.com/admin-settings-and-team-management?hsLang=en#user-experience-and-workflows)
    - [Settings and configuration](https://help.marq.com/admin-settings-and-team-management?hsLang=en#settings-and-configuration)
    - [Implementation resources](https://help.marq.com/admin-settings-and-team-management?hsLang=en#implementation-resources)
- [Integrations](https://help.marq.com/integrations?hsLang=en#main-content)

    - [Printer integrations](https://help.marq.com/integrations?hsLang=en#printer-integrations)
    - [Data integrations](https://help.marq.com/integrations?hsLang=en#data-integrations)
    - [Custom integrations](https://help.marq.com/integrations?hsLang=en#custom-integrations)
    - [Security and sign-on integrations](https://help.marq.com/integrations?hsLang=en#security-and-sign-on-integrations)
    - [Email integrations](https://help.marq.com/integrations?hsLang=en#email-integrations)
    - [Productivity and analytics integrations](https://help.marq.com/integrations?hsLang=en#productivity-and-analytics-integrations)
    - [Workflow Integrations](https://help.marq.com/integrations?hsLang=en#workflow-integrations)
    - [Salesforce](https://help.marq.com/integrations?hsLang=en#salesforce)
    - [MediaValet](https://help.marq.com/integrations?hsLang=en#mediavalet)
- [Training videos](https://help.marq.com/training-videos?hsLang=en#main-content)

    - [View](https://help.marq.com/training-videos?hsLang=en#view)
- [Courses](https://help.marq.com/courses?hsLang=en#main-content)

    - [View](https://help.marq.com/courses?hsLang=en#view)
- [Tutorials and resources](https://help.marq.com/tutorials-and-resources?hsLang=en#main-content)

    - [View](https://help.marq.com/tutorials-and-resources?hsLang=en#view)
- [Design services](https://help.marq.com/design-services?hsLang=en#main-content)

    - [View](https://help.marq.com/design-services?hsLang=en#view)
- [Events](https://help.marq.com/events?hsLang=en#main-content)

    - [View](https://help.marq.com/events?hsLang=en#view)
- [Analytics](https://help.marq.com/analytics?hsLang=en#main-content)

    - [Account Setup](https://help.marq.com/analytics?hsLang=en#account-setup)
    - [Basic Analytics](https://help.marq.com/analytics?hsLang=en#basic-analytics)
    - [Advanced Analytics](https://help.marq.com/analytics?hsLang=en#advanced-analytics)
    - [Navigating Reports](https://help.marq.com/analytics?hsLang=en#navigating-reports)
    - [Glossary of Terms](https://help.marq.com/analytics?hsLang=en#glossary-of-terms)
- [App Marketplace](https://help.marq.com/app-marketplace?hsLang=en#main-content)

    - [Workflow Connectors](https://help.marq.com/app-marketplace?hsLang=en#workflow-connectors)
- [Campaigns](https://help.marq.com/campaigns?hsLang=en#main-content)

    - [Getting Started](https://help.marq.com/campaigns?hsLang=en#getting-started)
    - [Connect to Facebook](https://help.marq.com/campaigns?hsLang=en#connect-to-facebook)
    - [Industry](https://help.marq.com/campaigns?hsLang=en#industry)
    - [Objectives](https://help.marq.com/campaigns?hsLang=en#objectives)
    - [Analytics](https://help.marq.com/campaigns?hsLang=en#analytics)
- [Creator Studio](https://help.marq.com/creator-studio?hsLang=en#main-content)

    - [Getting Started](https://help.marq.com/creator-studio?hsLang=en#getting-started)
    - [Studio FAQ](https://help.marq.com/creator-studio?hsLang=en#studio-faq)
- [Templates](https://help.marq.com/templates?hsLang=en#main-content)

    - [Getting Started](https://help.marq.com/templates?hsLang=en#getting-started)
    - [Advanced Features](https://help.marq.com/templates?hsLang=en#advanced-features)
    - [Team Management](https://help.marq.com/templates?hsLang=en#team-management)
    - [Troubleshooting](https://help.marq.com/templates?hsLang=en#troubleshooting)
- [CRM Integrations](https://help.marq.com/crm-integrations?hsLang=en)
- [DAM Integrations](https://help.marq.com/dam-integrations?hsLang=en)
- [Marq 2026 Packaging Updates](https://help.marq.com/marq-2026-packaging-updates?hsLang=en)
- [AI Brand Creations](https://help.marq.com/ai-brand-creations?hsLang=en)

[![Chill listening crop-3](https://help.marq.com/hubfs/Brand%20Logos/marq.svg "Chill listening crop-3")](https://help.marq.com?hsLang=en)

<https://www.facebook.com/marqhq> <https://twitter.com/marq_hq> <https://www.youtube.com/marqhq> <https://www.linkedin.com/company/marqhq>

Copyright © 2026, Marq