Skip to main content

REST API Keys

LetterPress exposes a small REST API for adding and listing subscribers from your own code: contact forms, checkout flows, scripts, or any integration you build. API keys authenticate those requests.

Open LetterPress > API Keys.

The API keys page

Creating a key​

  1. Type a New key label that names the integration, for example Website contact form.
  2. Click Generate API key.
  3. The secret is displayed once after creation. Copy it immediately. LetterPress stores only a hash and cannot show it again.

Revoking a key stops clients using it immediately. Existing keys keep working until revoked, so generate one key per integration to stay able to revoke them separately.

Authentication​

Send the key in the Authorization header with the Bearer prefix.

Authorization: Bearer YOUR_API_KEY

Query string keys are not accepted. Requests over plain HTTP will expose the key in transit, so use HTTPS in production.

The endpoints​

Both endpoints live under /wp-json/letterpress/v1/ and use the same Bearer key in the Authorization header.

The quick API reference

List subscribers​

GET /wp-json/letterpress/v1/subscribers

Returns subscribed addresses only, newest first. Pending, unsubscribed, and blocked contacts are not included.

ParameterRequiredMeaning
sourceOptionalFilter by a registered source key. Unknown keys are rejected with the valid keys listed
per_pageOptionalResults per request, 10 by default, clamped between 10 and 100
pageOptionalResult page, 1 by default

Each subscriber carries id, email, name, status, source, and subscribed_at. The response also includes pagination metadata:

{
"subscribers": [
{
"id": 94,
"email": "[email protected]",
"name": "Reader",
"status": "subscribed",
"source": "default",
"subscribed_at": 1762819200
}
],
"total_subscribers": 1,
"total_pages": 1,
"current_page": 1
}
curl "https://example.com/wp-json/letterpress/v1/subscribers?source=default&per_page=25&page=2" \
-H "Authorization: Bearer YOUR_API_KEY"

A 400 response means the source key is unknown. The error data includes available_sources with the registered keys, so the caller can correct the request without opening the admin.

Add a subscriber​

POST /wp-json/letterpress/v1/add-subscriber

Creates or resubscribes a subscriber. Pass group_id to add the subscriber to an existing group as well.

FieldRequiredMeaning
emailRequiredA valid email address
nameOptionalSubscriber name, trimmed to 100 characters
sourceOptionalThe source key to attribute the signup to, from the Sources page. Defaults to the default source, and unknown or inactive keys are stored as default
group_idOptionalID of an existing subscriber group. New and existing subscribers are added to the group, and adding an existing member is safe to repeat

The response includes created, email, source, and status. When group_id is supplied, it also includes group_id and group_added. If the confirmation email could not be sent, confirmation_email is set to failed while the subscriber row is still saved.

curl -X POST "https://example.com/wp-json/letterpress/v1/add-subscriber" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"email":"[email protected]","name":"Reader","source":"default","group_id":3}'
ResponseMeaning
201Subscriber created or resubscribed. status is pending when confirmation is required, otherwise subscribed
200The address was already subscribed and is now in the requested group. created is false
400Invalid email or unknown group
401Missing, invalid, or revoked API key
403The address is blocklisted or otherwise cannot be added
409The address is already subscribed and no group_id was supplied

Security notes​

  • Secrets are stored as SHA-256 hashes, so a leaked database dump cannot reveal your keys.
  • Send requests over HTTPS in production so the Bearer key cannot be observed in transit.
  • Treat the key like a password. Use one key per integration, and rotate by generating a new key and revoking the old one.
  • The endpoints manage subscribers, not campaigns or settings. They cannot send email.

Next steps​