Skip to content

Email Campaigns API

Create and manage email marketing campaigns for your store.

Feature Requirement

Email campaigns require the email_marketing feature enabled on your plan.

List Campaigns

http
GET /api/external/v1/email-campaigns

Query Parameters

ParameterTypeDescription
pageintegerPage number (default: 1)
per_pageintegerItems per page (default: 20, max: 100)
statusstringFilter: draft, scheduled, sending, sent, cancelled
fromstringStart date (YYYY-MM-DD)
tostringEnd date (YYYY-MM-DD)

Example Request

bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/email-campaigns?status=sent" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "name": "Summer Sale Announcement",
      "subject": "Exclusive 25% Off - Summer Sale Now Live!",
      "status": "sent",
      "recipient_type": "all_customers",
      "from_name": "GameStore",
      "from_email": "noreply@gamestore.com",
      "recipients_count": 1250,
      "opens_count": 487,
      "clicks_count": 156,
      "bounces_count": 12,
      "unsubscribes_count": 3,
      "open_rate": 38.96,
      "click_rate": 12.48,
      "bounce_rate": 0.96,
      "unsubscribe_rate": 0.24,
      "scheduled_at": null,
      "sent_at": "2025-01-15T14:00:00Z",
      "created_at": "2025-01-14T10:30:00Z",
      "updated_at": "2025-01-15T14:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "last_page": 3,
    "per_page": 20,
    "total": 52
  }
}

Get Single Campaign

http
GET /api/external/v1/email-campaigns/{id}

Example Request

bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/1" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "success": true,
  "data": {
    "id": 1,
    "name": "Summer Sale Announcement",
    "subject": "Exclusive 25% Off - Summer Sale Now Live!",
    "content": "<html>...</html>",
    "status": "sent",
    "recipient_type": "all_customers",
    "recipient_filters": null,
    "from_name": "GameStore",
    "from_email": "noreply@gamestore.com",
    "recipients_count": 1250,
    "opens_count": 487,
    "clicks_count": 156,
    "bounces_count": 12,
    "unsubscribes_count": 3,
    "open_rate": 38.96,
    "click_rate": 12.48,
    "bounce_rate": 0.96,
    "unsubscribe_rate": 0.24,
    "scheduled_at": null,
    "sent_at": "2025-01-15T14:00:00Z",
    "created_at": "2025-01-14T10:30:00Z",
    "updated_at": "2025-01-15T14:00:00Z",
    "recipient_summary": {
      "total": 1250,
      "sent": 1238,
      "opened": 487,
      "clicked": 156,
      "bounced": 12,
      "unsubscribed": 3
    }
  }
}

Create Campaign

http
POST /api/external/v1/email-campaigns

Request Body

FieldTypeRequiredDescription
namestringYesCampaign name (max 255 chars)
subjectstringConditionalEmail subject line (required if no template_id)
contentstringConditionalHTML email content (required if no template_id)
from_namestringYesSender display name
from_emailstringYesSender email address
recipient_typestringYesall_customers, segment, or custom_list
recipient_filtersobjectNoFilters when using segment type
template_idintegerNoUse existing email template

Example Request

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/email-campaigns" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "New Product Launch",
    "subject": "Introducing Our Latest Ranks!",
    "content": "<html><body><h1>New Ranks Available!</h1><p>Check out our new VIP+ rank with exclusive perks.</p></body></html>",
    "from_name": "GameStore",
    "from_email": "noreply@gamestore.com",
    "recipient_type": "all_customers"
  }'

Response

json
{
  "success": true,
  "data": {
    "id": 2,
    "name": "New Product Launch",
    "subject": "Introducing Our Latest Ranks!",
    "status": "draft",
    "recipient_type": "all_customers",
    "from_name": "GameStore",
    "from_email": "noreply@gamestore.com",
    "recipients_count": 0,
    "opens_count": 0,
    "clicks_count": 0,
    "bounces_count": 0,
    "unsubscribes_count": 0,
    "created_at": "2025-01-20T15:00:00Z",
    "updated_at": "2025-01-20T15:00:00Z"
  },
  "message": "Campaign created successfully"
}

Using Templates

You can use a pre-defined email template instead of specifying content:

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/email-campaigns" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Weekly Newsletter",
    "from_name": "GameStore",
    "from_email": "noreply@gamestore.com",
    "recipient_type": "all_customers",
    "template_id": 5
  }'

Recipient Filters

When using recipient_type: "segment", you can specify filters:

json
{
  "name": "VIP Customer Exclusive",
  "subject": "Special Offer for Our VIP Customers",
  "content": "<html>...</html>",
  "from_name": "GameStore",
  "from_email": "noreply@gamestore.com",
  "recipient_type": "segment",
  "recipient_filters": {
    "total_spent_min": 100,
    "has_purchased": true,
    "last_order_days": 30
  }
}

Update Campaign

Update a draft or scheduled campaign.

http
PUT /api/external/v1/email-campaigns/{id}

Note

Only campaigns with draft or scheduled status can be updated.

Request Body

FieldTypeRequiredDescription
namestringNoCampaign name
subjectstringNoEmail subject line
contentstringNoHTML email content
from_namestringNoSender display name
from_emailstringNoSender email address
recipient_typestringNoall_customers, segment, or custom_list
recipient_filtersobjectNoFilters when using segment type

Example Request

bash
curl -X PUT "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/2" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "subject": "Updated: Introducing Our Latest Ranks!",
    "content": "<html><body><h1>New Ranks Available!</h1><p>Updated content with more details.</p></body></html>"
  }'

Response

json
{
  "success": true,
  "data": {
    "id": 2,
    "name": "New Product Launch",
    "subject": "Updated: Introducing Our Latest Ranks!",
    "status": "draft",
    "updated_at": "2025-01-20T16:00:00Z"
  },
  "message": "Campaign updated successfully"
}

Send Campaign

Send a campaign immediately or schedule it for later.

http
POST /api/external/v1/email-campaigns/{id}/send

Request Body

FieldTypeRequiredDescription
scheduled_atstringNoISO 8601 datetime to schedule (must be in future)
test_emailstringNoSend test email to this address instead of full send
forcebooleanNoSkip content validation warnings

Send Immediately

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/2/send" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json"

Response

json
{
  "success": true,
  "data": {
    "id": 2,
    "name": "New Product Launch",
    "status": "sending",
    "sent_at": "2025-01-20T16:30:00Z"
  },
  "message": "Campaign is being sent"
}

Schedule for Later

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/2/send" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "scheduled_at": "2025-01-25T10:00:00Z"
  }'

Response

json
{
  "success": true,
  "data": {
    "id": 2,
    "name": "New Product Launch",
    "status": "scheduled",
    "scheduled_at": "2025-01-25T10:00:00Z"
  },
  "message": "Campaign scheduled for 2025-01-25 10:00:00"
}

Send Test Email

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/2/send" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "test_email": "test@example.com"
  }'

Response

json
{
  "success": true,
  "message": "Test email sent successfully"
}

Content Validation Warnings

If the content contains potential spam triggers, you'll receive warnings:

json
{
  "success": false,
  "warnings": [
    "Subject line contains excessive punctuation",
    "Content contains commonly blocked phrases"
  ],
  "message": "Content validation warnings found. Send with force=true to ignore."
}

To proceed anyway, add force: true to the request.

Get Campaign Stats

Get detailed statistics for a campaign.

http
GET /api/external/v1/email-campaigns/{id}/stats

Example Request

bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/1/stats" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "success": true,
  "data": {
    "campaign_id": 1,
    "name": "Summer Sale Announcement",
    "status": "sent",
    "sent_at": "2025-01-15T14:00:00Z",
    "delivery": {
      "total": 1250,
      "sent": 1238,
      "failed": 12,
      "delivery_rate": 99.04
    },
    "engagement": {
      "opens": 487,
      "unique_opens": 423,
      "open_rate": 38.96,
      "clicks": 156,
      "unique_clicks": 134,
      "click_rate": 12.48,
      "click_to_open_rate": 32.03
    },
    "negative": {
      "bounces": 12,
      "bounce_rate": 0.96,
      "unsubscribes": 3,
      "unsubscribe_rate": 0.24,
      "spam_complaints": 0
    },
    "timeline": {
      "first_open": "2025-01-15T14:02:15Z",
      "last_open": "2025-01-18T09:45:00Z",
      "first_click": "2025-01-15T14:05:30Z",
      "last_click": "2025-01-17T21:15:00Z"
    }
  }
}

Delete Campaign

Delete a campaign. Cannot delete campaigns that are currently being sent.

http
DELETE /api/external/v1/email-campaigns/{id}

Example Request

bash
curl -X DELETE "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/2" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

json
{
  "success": true,
  "message": "Campaign deleted successfully"
}

Duplicate Campaign

Create a copy of an existing campaign.

http
POST /api/external/v1/email-campaigns/{id}/duplicate

Example Request

bash
curl -X POST "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/1/duplicate" \
  -H "Authorization: Bearer YOUR_TOKEN"

Response

json
{
  "success": true,
  "data": {
    "id": 3,
    "name": "Summer Sale Announcement (Copy)",
    "status": "draft",
    "created_at": "2025-01-20T17:00:00Z"
  },
  "message": "Campaign duplicated successfully"
}

Preview Recipients

Preview the recipients list before sending.

http
GET /api/external/v1/email-campaigns/{id}/preview-recipients

Example Request

bash
curl -X GET "https://yourstore.pixlpay.net/api/external/v1/email-campaigns/2/preview-recipients" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Response

json
{
  "success": true,
  "data": {
    "total_recipients": 1250,
    "sample_recipients": [
      {
        "id": 1,
        "name": "John Doe",
        "email": "john@example.com"
      },
      {
        "id": 2,
        "name": "Jane Smith",
        "email": "jane@example.com"
      }
    ]
  }
}

Campaign Object

FieldTypeDescription
idintegerUnique identifier
namestringCampaign name
subjectstringEmail subject line
contentstringHTML email content
statusstringdraft, scheduled, sending, sent, cancelled
recipient_typestringall_customers, segment, custom_list
recipient_filtersobjectFilters for segment targeting
from_namestringSender display name
from_emailstringSender email address
recipients_countintegerTotal recipients
opens_countintegerTotal opens
clicks_countintegerTotal clicks
bounces_countintegerTotal bounces
unsubscribes_countintegerTotal unsubscribes
open_ratefloatPercentage of recipients who opened
click_ratefloatPercentage of recipients who clicked
bounce_ratefloatPercentage of bounced emails
unsubscribe_ratefloatPercentage who unsubscribed
scheduled_atstringISO 8601 scheduled send time
sent_atstringISO 8601 actual send time
created_atstringISO 8601 creation timestamp
updated_atstringISO 8601 last update timestamp

Campaign Statuses

StatusDescription
draftCampaign is being created, not yet sent
scheduledCampaign is scheduled for future delivery
sendingCampaign is currently being delivered
sentCampaign has been fully delivered
cancelledCampaign was cancelled before sending

Recipient Types

TypeDescription
all_customersSend to all customers who have not unsubscribed
segmentSend to customers matching filter criteria
custom_listSend to a custom uploaded list

Merge Tags

Use these tags in your email content for personalization:

TagDescription
{customer_name}Customer's full name
{customer_email}Customer's email address
{store_name}Your store name
{store_url}Your store URL
{unsubscribe_link}Link to unsubscribe

Example Content

html
<html>
<body>
  <h1>Hello, {customer_name}!</h1>
  <p>Thank you for shopping at {store_name}.</p>
  <p>Visit us at <a href="{store_url}">{store_url}</a></p>
  <hr>
  <small><a href="{unsubscribe_link}">Unsubscribe</a></small>
</body>
</html>

Errors

StatusErrorDescription
401UnauthorizedInvalid or missing token
403ForbiddenToken lacks email_campaigns:read or email_campaigns:write scope
403Campaign cannot be editedCampaign status doesn't allow editing
403Cannot delete sending campaignCampaign is currently being sent
404Not FoundCampaign doesn't exist
422Validation ErrorInvalid request parameters
422Content warningsEmail content has potential issues

Built for game developers, by game developers.