How to Integrate Third-Party APIs with WordPress: Plugin or Custom Code
At some point nearly every client wants WordPress to talk to something else. Leads from the contact form should land in the CRM. Orders should reach the ERP. New subscribers belong in the email platform, and bookings in the calendar.
Built well, these integrations save clients hours of copying data by hand. Built badly, they lose data for months before anyone notices.
Map the data before you write code
Before you pick a plugin or open an editor, sit down and answer a few questions. Which system owns each piece of data? What starts a sync: a form submission, a new order, a timer? Does data move one way or both ways? What should happen when a request fails? And how much data are we talking about, and how often?
Draw it as a simple diagram with boxes and arrows. Most integration problems we get called in to fix go back to a question nobody asked at this stage.
Plugin or custom code?
A connector plugin is enough when
- it’s a common pairing, like a form plugin sending leads to Mailchimp or HubSpot;
- the plugin is maintained and handles exactly the fields you need;
- the logic is simple and unlikely to change.
Custom code is the better choice when
- the rules are specific to the business, for example different CRM pipelines depending on what someone picked in the form;
- you’re syncing a lot of data, like thousands of products from an ERP;
- there’s no reliable plugin for the service;
- you need full control over error handling and logging.
Plenty of projects end up with both: a plugin for the standard part and a small custom extension for the rest. Our article on when to build a custom WordPress plugin covers that decision in more detail.
Keys and secrets
API keys and OAuth tokens are passwords, so handle them that way. Keep them out of the theme and out of Git. Store them in environment variables, wp-config.php or encrypted settings. Use different keys for staging and production, and give each key only the permissions it needs.
Use what WordPress already has
You rarely need to reinvent anything. wp_remote_get() and wp_remote_post() handle HTTP requests. Hooks let you trigger a sync when a form is submitted, an order is placed or a post is updated. For background and scheduled work there’s WP-Cron, a real server cron, or a queue like Action Scheduler. Transients cache responses and help you stay under rate limits, and the REST API can receive webhooks from other systems.
Whatever you build, keep long syncs out of the visitor’s page load. Run them in the background.
Expect failures
Every external API goes down now and then. A dependable integration retries failed requests with sensible delays, logs each request and response without storing sensitive data, and alerts a person when a sync keeps failing. Most importantly, it never drops data quietly. Failed submissions go into a queue and wait. For the cron, queue and webhook side of this, see syncing WordPress with external data.
Skip the logging and alerts, and you find out about the problem when the client asks why the CRM has been empty for a month.
Check incoming webhooks
When another system sends data to WordPress, say payment updates from Stripe, verify the signature on every request and validate the payload. Reply quickly and push any heavy processing to the background.
Test against sandboxes
Most services have a sandbox or test mode. Build on staging with test accounts and try the unhappy paths too: failures, duplicates, odd characters, missing fields. Connect production only when those pass.
Write it down
APIs change. Versions get retired, fields get renamed, rate limits move. For each integration, note what it does, where the keys live, how to test it and who to contact at the other end. Then check it regularly, ideally as part of a maintenance plan.
Selling integrations as an agency
Integrations bring in steady work, but they need someone who has debugged a failing webhook before. We build them for agencies under their brand: see WordPress API integration services, or white label WooCommerce development for store projects.
Tell us which systems need to connect, and we will send a short spec and quote.