The Newsletter Plugin for WordPress provides a robust REST API designed to bridge external applications with your mailing list. To use it, you generally need to install the free Newsletter REST API Addon, which can be found in the “Addons” panel within the plugin’s dashboard.
This is EXACTLY the same product as distributed by the developer. Sales Page
1. Authentication
To interact with the API, you must generate credentials.
-
Method: Basic Authentication using a Client Key and Client Secret.
-
Setup: 1. Go to Newsletter > API in your WordPress dashboard.
2. Click Create Key.
3. Associate the key with a WordPress user (ensure the user has “Administrator” or “Newsletter Manager” roles).
4. Choose permissions: Read, Write, or Read/Write.
2. Core Endpoints (v2)
All endpoints are relative to your site’s REST base, typically:
https://yourdomain.com/wp-json/newsletter/v2/
| Endpoint | Method | Description |
/subscribers |
POST |
Add or update a subscriber. |
/subscribers/{id} |
GET |
Retrieve details for a specific subscriber. |
/subscribers/{id} |
PUT/PATCH |
Update subscriber data (lists, custom fields). |
/subscribers/{id} |
DELETE |
Remove a subscriber from the database. |
/lists |
GET |
Retrieve all defined mailing lists (IDs and names). |
/newsletters |
GET |
Get a list of sent newsletters (last 10 by default). |
3. Key Features & Specifications
-
Public Subscriptions: The
/subscribersPOST endpoint can be configured to allow “public” access (no API key required). This is useful for custom-built frontends or mobile apps where you want to allow sign-ups without exposing your secret keys. -
Subscriber Status: You can manually set statuses such as
confirmed,unconfirmed, orunsubscribed. If omitted, the API usually defaults toconfirmed. -
Data Structure: The API uses standard JSON. A typical subscriber payload looks like this:
JSON{ "email": "[email protected]", "name": "John", "surname": "Doe", "status": "confirmed", "lists": [1, 5] } -
Automation Triggering: If a subscriber is added via the API to a list associated with an Autoresponder, the automated sequence will trigger (usually within a 5-minute processing window).
4. Developer Tools (PHP API)
If you are coding directly within WordPress (not via external HTTP calls), you don’t need the REST API addon. You can use the TNP class:
-
Subscribe:
TNP::subscribe(['email' => '[email protected]', 'name' => 'John']); -
Unsubscribe:
TNP::unsubscribe('[email protected]');
- Categories: WordPress Plugins
- Tags: Newsletter
