PlugPress

Mailpuff

Mailpuff API and Webhooks: Add Subscribers From Any Site or App

Add subscribers to Mailpuff from another site or app, give an app its own limited key, and get told when someone joins or leaves.

Mailpuff gives other apps three ways in: a signup address that adds a subscriber with one request, keys that let one app read or change only what you tick, and webhooks that tell another app when something happens. All three are in Mailpuff → Settings → MCP & API. Nothing is sent to another app until you set one up.

You want to Use
Sign people up from another website, app or script The Subscribe API
Let an app read subscribers and reports, or add and change subscribers An API key
Tell another app when someone subscribes, leaves or bounces A webhook

How do I add a subscriber with the Subscribe API?

Send a POST request to /wp-json/mailpuff/v1/subscribe with the person’s email, and your key in the X-Mailpuff-Key header. No WordPress login is needed.

POST https://your-site.com/wp-json/mailpuff/v1/subscribe
X-Mailpuff-Key: mailpuff_your_key_here
Content-Type: application/json

{
  "email": "[email protected]",
  "first_name": "Jane",
  "last_name": "Doe",
  "group_ids": [5, 7]
}

It works like a signup form. The person gets a confirmation email and joins your list when they click its link.

Where do I find the key?

Open Mailpuff → Settings → MCP & API and look under Subscribe API. The key starts with mailpuff_. The page also shows when the key was made and when it was last used.

Anyone with the key can sign people up, so keep it on a server. Don’t put it in JavaScript that runs in a visitor’s browser. If the key leaks, click Regenerate key. The old key stops working at once.

Send the key in the header. If a tool can’t set headers, send it as an api_key field in the JSON body. A key in the URL is refused, because URLs end up in server logs.

Which fields does the request take?

Field Type Required What it is
email string Yes The person’s email address
first_name string No First name
last_name string No Last name
group_id integer No One tag to give the person
group_ids array or string No Several tags, as [5, 7] or "5,7"

How do tags work here?

Mailpuff calls them tags everywhere you read them. These fields keep their older names, group_id and group_ids, and you can use either or both. Unknown ids are ignored.

  • With the key, only public tags are given: the ones offered on signup forms and the preferences page. Internal tag ids are ignored, so a leaked key can’t put people on private lists.
  • Tags go to new and existing subscribers alike. Posting an address again is a safe way to give someone another tag.
  • To find tag ids, ask your AI agent to run list-audiences.

What does the Subscribe API return?

With the key, the answer is always the same:

HTTP 202 Accepted

{ "received": true }

It is the same whether the address was new, already on your list, pending, unsubscribed or bounced. That way the key can’t be used to find out who is on your list.

  • A new address gets a confirmation email.
  • Posting the same address twice never makes a duplicate. A pending address gets its confirmation email again, at most 3 a day.
  • An address that unsubscribed has to confirm again.
  • An address that bounced, complained or was erased is never added back.

Which errors can it return?

Errors use the standard WordPress shape: { "code": "...", "message": "...", "data": { "status": 400 } }.

Status Code Cause
401 invalid_key The key is missing or wrong
400 invalid_email The email is missing or malformed
429 rate_limit More than 10 requests in a minute from one visitor

The limit is 10 requests a minute for each visitor address. Past that, wait a minute and retry. To move a whole list, use Mailpuff → Subscribers → Import instead of a loop.

Code examples

cURL:

curl -X POST https://your-site.com/wp-json/mailpuff/v1/subscribe \
  -H "X-Mailpuff-Key: mailpuff_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{ "email": "[email protected]", "first_name": "Jane", "group_ids": [5, 7] }'

PHP, from another WordPress site:

$response = wp_remote_post(
    'https://your-site.com/wp-json/mailpuff/v1/subscribe',
    array(
        'headers' => array(
            'X-Mailpuff-Key' => 'mailpuff_your_key_here',
            'Content-Type'   => 'application/json',
        ),
        'body'    => wp_json_encode(
            array(
                'email'     => '[email protected]',
                'group_ids' => array( 5, 7 ),
            )
        ),
    )
);
$code = wp_remote_retrieve_response_code( $response ); // 202

Node.js, on a server:

const res = await fetch( 'https://your-site.com/wp-json/mailpuff/v1/subscribe', {
  method: 'POST',
  headers: {
    'X-Mailpuff-Key': process.env.MAILPUFF_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify( { email: '[email protected]', first_name: 'Jane' } ),
} );
// res.status is 202 for every address

How do I give another app its own key?

Under API keys, click New key. Name it after the app that uses it and tick what it may do:

It may What the key can call
Read subscribers and tags GET /api/subscribers, GET /api/subscribers/<id>, GET /api/tags
Add and change subscribers POST /api/subscribers, PATCH /api/subscribers/<id>
Read campaigns and reports GET /api/campaigns, GET /api/campaigns/<id>

The paths sit under /wp-json/mailpuff/v1. The page shows the full base address with a copy button.

  • The key starts with mpk_ and is shown once. Copy it when you make it.
  • Send it in the X-Mailpuff-Key header, or as Authorization: Bearer. Never in the URL.
  • One key may make 120 requests a minute.
  • Revoke stops a key at once.

A new address added with a key goes through the signup flow. As pending it gets the confirmation email. As subscribed, your app already has their consent. Someone who unsubscribed gets a confirmation email instead, and bounced, complained or erased addresses are refused. No key can send a campaign or delete anyone.

How do I tell another app when something happens?

Under Webhooks, click Add webhook. Enter an https address and pick the events:

Event Fires when
subscriber.created Someone is added
subscriber.subscribed Someone subscribes
subscriber.unsubscribed Someone unsubscribes
subscriber.bounced An address bounces or marks an email as spam
campaign.sent A campaign finishes sending

Mailpuff sends a JSON body with id, event, created_at and data. For a subscriber, the data holds their id, email address, name, status, tags and when they joined. For a campaign, it holds the name, subject, recipients, deliveries, failures and web address.

How do I check a webhook call is real?

Each call carries an X-Mailpuff-Signature header:

X-Mailpuff-Signature: t=<unix time>,v1=<signature>

The signature is the hex HMAC-SHA256 of <t>.<body>, made with the webhook’s secret. Mailpuff shows the secret once, when you add the webhook. Compute the same value in your app and compare.

What happens when my app is down?

A failed call is tried again after 1 minute, 10 minutes and 60 minutes. After 10 events in a row that never got through, the webhook turns itself off, and the settings page says so. The page also shows how each webhook’s last call went, and Send test sends a test call.

Imports send no webhook calls.

FAQ

Can I use the Subscribe API from a form on a static site?

Not straight from the browser, because the key would be public. Post the form to a small server function and call the API from there, with the key in an environment variable. Or show a Mailpuff form on that site with its tag, which needs no key. See how to make a signup form.

Can I skip the confirmation email?

Not with the Subscribe key. To add people who already agreed, use an API key that may add and change subscribers, and add them as subscribed.

Does Mailpuff work with Zapier or Make?

There is no dedicated app for either. Use a webhook to start a Zap or scenario, and an API key to add or change subscribers from one.

Can I react in PHP when someone is added?

Yes. A new subscriber fires the mailpuff_contact_created action. The hooks reference lists every hook.