← Back to Blog
Mautic Migration Marketing Automation

Connecting SAP and CRM to Mautic through middleware: what the integration team needs from you

Plan a Mautic CRM integration through middleware: data model, identifiers, field names, auth, testing, monitoring and cutover. A guide for integration teams.

M Mautomic Team
13 min read

A Mautic CRM integration rarely fails on the API itself. It fails on questions nobody asked early: where company data lives, which identifier wins, what an empty value means. In a recent Marketo to Mautic migration, the client’s own MuleSoft team re-pointed its SAP ERP and itmX CRM flows to Mautic. This guide shows what we hand such a team and in what order.

Who does what when middleware feeds Mautic?

Many B2B companies already run an integration layer, such as MuleSoft, Boomi or a home-grown service, between the ERP, the CRM and the marketing platform. When the marketing platform changes, that layer stays. Only its target changes.

In our project the split looked like this. The client’s MuleSoft team owned the middleware before the migration and kept owning it after. We owned Mautic: the data model, the custom fields, the companies, the campaigns that react to the data. Our part of the integration work was to make the Mautic side easy to write to. We delivered API and data model documentation, a Postman collection for testing calls, and developer support while their team built the mapping.

The people who know the ERP map it. The people who know Mautic explain how Mautic will store it. That only works if both sides agree on a few things before anyone writes a mapping. The stages below are the order in which we settle them.

Stage 1: which data flows exist, and in which direction?

Start with an inventory, not with the API. For every flow that touches the old marketing platform, write down:

  • the source system (ERP, CRM, shop, event tool),
  • the target system,
  • the objects it carries (people, companies, orders, events),
  • the trigger (on change, nightly batch, manual export),
  • the expected volume per run and on peak days,
  • the person who owns it on the client side.

Ask the integration team for this list directly. The marketing team describes campaigns. The integration team knows which objects it writes, how often, and from where. The surprises sit in the difference.

Mark the direction of each flow. Data coming into Mautic (customer master data, order dates, account status) needs a target field and an owner. Data leaving Mautic (consent changes, form submissions, unsubscribes) needs a trigger in Mautic, such as a webhook or a campaign action. Outbound flows are easy to forget.

Stage 2: does the data live on the contact or on the company?

This is the decision with the biggest consequences. Make it before the first contact import.

Mautic has contacts and companies. A contact can belong to several companies, and one of them is marked as primary. You can store business data (customer number, sales region, first and last order date, account type) on the contact, on the company, or split it between both.

Each choice changes how the rest of the system behaves:

  • Data on the contact is simple to filter and to use in emails. It duplicates company data across every person from the same customer, and it drifts when one record updates and the others do not.
  • Data on the company matches how an ERP thinks. A customer number belongs to an account, not to a person. Segments and campaign conditions then have to work with “any linked company”, which behaves differently from a contact field.

In our project the integration team planned to write company data as companies, an object the marketing team had never mentioned in the brief. About 64 fields moved from the contact to the company, keyed by the 10-digit SAP customer number. When fields move from contacts to companies, conflicting values from several contacts collapse into one value on the company. Settle the model first, then import.

We describe how segments and filters behave with several companies per contact in our post on what transfers from Marketo to Mautic.

Stage 3: how will each system find the right record?

Every write needs a rule for finding the record it updates. Without that rule, the middleware creates a new record each time and duplicates pile up.

In our project the rules were short:

  • Companies are identified by the SAP customer number.
  • Contacts are identified by email address.
  • Links between a contact and a company are created explicitly, and removed explicitly when a person leaves a company.

That last point matters more than it looks. If the middleware only ever adds links, a person who moved to another customer stays linked to both. Every segment built on company data then counts them twice. Agree that the integration will send an unlink when the CRM ends a relationship.

Decision rules for identifiers

  • Pick one identifier per object, and make it the one the source system already uses. The ERP number beats the company name every time. Names change, get abbreviated and get typed in two ways.
  • Store the external identifier in its own Mautic field, and never let marketing users edit it.
  • Decide what happens when the identifier is missing. Reject the write, or park it for review. Do not fall back to matching by name.
  • Decide what happens when one email appears under two customers. In B2B this is normal, which is why the contact and the company need separate identifiers.

What happens to existing records?

If the old platform stored companies by name only, those records will not match the new identifier. We removed about 42,000 name-only companies and rebuilt them from SAP keys, in place in the Mautic database. Plan this step before the integration goes live, so the first sync writes into clean records.

Stage 4: what is the field naming agreement?

Mautic addresses fields by their alias, not by the label marketers see in the interface. The middleware must send the exact alias for every field. Old platform names, labels or a slightly different spelling will not match.

Here is the trap. A payload with field names that do not exist in Mautic still gets HTTP 200. Nothing is saved. The middleware logs a success, and the data never arrives.

So the field list becomes a shared agreement between the two teams. For each field it states:

  • the Mautic alias,
  • the object (contact or company),
  • the type (text, number, date, boolean, select),
  • the allowed values for select fields,
  • the format for dates,
  • the owner: which system is the source of truth.

The owner column prevents a quiet kind of conflict. Some fields belong to the ERP or the CRM. Some belong to Mautic, such as consent dates, the double opt-in flag and Do Not Contact status. The middleware should never overwrite a field Mautic owns unless both teams agreed on it in writing.

Freeze the list before the integration team starts mapping. If a field has to change later, change the list first and tell the integration team, then change Mautic.

Empty values are writes too

The second trap sits in the same place. When the middleware writes a company, an empty string clears the field in Mautic. If the ERP sends every field on every update, including the empty ones, it can wipe data that marketing entered or that came from another source.

Agree on one of two rules. Send only the fields that changed. Or send every field, and accept that the ERP is the full source of truth for the company record. Both work. Mixing them does not.

Stage 5: how will the middleware authenticate?

Mautic supports two ways for an external system to call its API: Basic Authentication and OAuth2. OAuth2 in Mautic supports the authorization code, refresh token and client credentials grant types. For machine-to-machine traffic such as middleware, the client credentials flow fits best. The middleware exchanges a client ID and secret for a short-lived access token and requests a new one when it expires.

Mautic recommends OAuth2. Basic Authentication has to be switched on in the API settings first, and it sends a Mautic user’s credentials with every request. Whichever method you choose, apply the same rules:

  • One credential per integration. With client credentials, Mautic records changes under the name of the API credential. The contact history then shows which system wrote what.
  • Limited rights. If you use an API user, give it a role that covers only the objects the integration writes. It should not be able to send emails or edit campaigns.
  • Secrets in the middleware vault, never in shared documents or in the Postman collection you send around.
  • A separate credential for test and production, so a test run can never write into live data.

Stage 6: where will the integration team test?

The integration team needs a Mautic instance it can break. It should have the final field list, the final company model and realistic test data.

We gave the MuleSoft team a Postman collection with example calls for every operation the integration uses: write a company, write a contact, link them, unlink them. Each request used the real field aliases. Their developers could run a call, open the record in Mautic and see the result within minutes.

A good test round covers more than the happy path:

  • a new company and a new contact,
  • an update to one field only,
  • an update that sends an empty value,
  • a contact linked to two companies, then unlinked from one,
  • a payload with a misspelled field alias,
  • a write with an expired token,
  • the same message sent twice.

After every write, read the record back and compare it with what was sent. A status code is not proof.

Stage 7: what happens when a write fails?

Some writes will fail. The token expires, the server restarts during a deploy, a field value does not fit its type. Agree with the integration team how the middleware will react.

  • Make every write safe to repeat. Look up the record by its identifier, then update it. A retry then cannot create a duplicate.
  • Respect the order of operations. A link needs both the company and the contact to exist. If the company write fails, hold the link and retry it after the company succeeds.
  • Retry with a delay on network errors and server errors. Do not retry validation errors. They will fail again.
  • Park what fails repeatedly in an error queue with the full payload, and alert a person.
  • Refresh the token when Mautic answers that the access token is no longer valid, then repeat the call once.

Do not forget the silent case. A write that returns HTTP 200 and saves nothing will never reach the error queue. Only monitoring will catch it.

Stage 8: how will you know the sync is healthy?

Monitoring answers one question: does Mautic hold what the ERP and the CRM hold? A few simple checks cover most problems.

  • Volume. Compare how many records the middleware sent per day with how many records changed in Mautic. A gap points to dropped or ignored writes.
  • Sync stamp. Ask the middleware to write a “last synced” date field on each record. Records with an old stamp show where the sync stopped.
  • Duplicates. Run a regular check for companies that share an ERP number and contacts that share an email. In a healthy setup both lists stay empty.
  • Fill rates. Track how many companies have a value in fields that the business depends on, such as the customer number or the order dates. A sudden drop usually means empty overwrites.
  • Spot checks. Each week, pick a few customers in the ERP and compare them field by field with Mautic.

Campaigns depend on this data. In our project the shop flows read the first and last order dates from the companies linked to a contact. Wrong dates mean the wrong email to a real customer.

Stage 9: in what order do you switch over?

The integration switch has to fit the marketing platform switch. We planned the order like this:

  1. The integration team finishes testing against the Mautic test instance.
  2. We run the main contact import into production Mautic, with consent history and Do Not Contact status.
  3. The old platform keeps running and sending.
  4. The middleware switches its target to production Mautic, using the production credential.
  5. We run a delta import of contacts that changed in the old platform after the main import.
  6. The first Mautic sends go out and we validate them.
  7. Only then does the client switch off the old platform.

This order keeps a way back. If a blocking problem appears, the middleware can point to the old platform again while the team fixes it. In our project Marketo kept running until the Mautic sends were validated, and the platform went live before the Marketo contract ran out. Our post on how to plan a marketing automation migration covers the wider schedule.

What documentation should you hand over?

An integration team works faster with a short, exact package than with a long manual. This is what we hand over.

DocumentWhat it containsWhy the integration team needs it
Data modelContacts, companies, the link between them, primary company ruleTo map ERP and CRM objects to Mautic objects
Field listAlias, object, type, allowed values, date format, ownerTo build the mapping without guessing
Identifier rulesWhich field identifies each object, what to do when it is missingTo avoid duplicates
Example payloadsOne per operation, with real aliases and realistic valuesTo copy a working shape instead of inventing one
Postman collectionReady calls against the test instanceTo test a mapping in minutes
Behavior notesEmpty values, unknown fields, multiple companies per contactTo avoid silent data loss

Keep the package in one place and version it. Name the person on the Mautic side who answers questions.

A checklist for the integration kickoff

Bring these to the first meeting with the integration team:

  • List of every flow into and out of the old platform, with source, target, trigger and volume
  • Owner of each flow on the client side
  • Decision: which data lives on the contact and which on the company
  • Identifier per object, and the rule when it is missing
  • Rule for linking and unlinking contacts and companies
  • Frozen field list with aliases, types, formats and owners
  • Rule for empty values: send changes only, or send everything
  • Fields Mautic owns that the middleware must not write
  • Authentication method, one credential per integration and environment
  • Test instance with the final model and realistic data
  • Postman collection and example payloads
  • Retry, error queue and alerting rules
  • Monitoring checks and who reviews them
  • Cutover order and the way back

Common failure modes and how to detect them

FailureWhat you seeHow to detect itHow to prevent it
Silent no-op writeMiddleware logs success, Mautic shows no changeRead back after each test write; compare daily volumesFrozen field list with exact aliases
Empty overwriteFields that had values become blankFill rate drops on watched fieldsSend only changed fields, or agree the ERP owns the record
Duplicate companiesTwo companies with the same customerRegular check on the ERP numberIdentify companies by ERP number, never by name
Duplicate contactsOne person appears twiceRegular check on emailIdentify contacts by email; make writes safe to repeat
Stale linksA person stays linked to a former employerContacts with more companies than expectedSend an unlink when the CRM ends a relationship
Wrong ownerConsent or marketing data overwritten by the ERPUnexpected changes in contact historyOwner column in the field list

The first two do the most damage. Nothing breaks loudly, and campaigns keep running on wrong data. Test both on purpose before go-live.

FAQ

Do we have to replace our middleware when we move to Mautic? No. In our project the client’s MuleSoft team kept its middleware and changed its target to Mautic. We supplied the documentation, the Postman collection and developer support.

Should we use Basic Authentication or OAuth2? Mautic recommends OAuth2. For middleware, the client credentials flow fits machine-to-machine traffic, and changes appear under the credential’s name.

Why did Mautic answer with HTTP 200 when nothing was saved? The payload most likely used field names that do not exist in Mautic. Check every alias against the field list and read the record back after the write.

Who should own the field list? Both teams agree on it, and one person on the Mautic side maintains it. The integration team should never discover a renamed field in production.

Need Mautic connected to your ERP and CRM?

This is one of the building blocks of our Marketo to Mautic migration for Meesenburg.

Planning a move to Mautic with an existing integration layer? Tell us which systems feed your marketing platform today. We will prepare the data model and documentation your integration team needs. Talk to the Mautomic team.

Tags

#Mautic#Integration#CRM#Migration#Marketo
M

Written by

Mautomic Team

Mautic experts sharing insights on marketing automation, custom development, and open-source technology.

Need help with Mautic?

Our team of experts is ready to help you implement and optimize your marketing automation.

We'll get back within 24h. Privacy Policy