API

API overview

The Marketing API lets your website or backend:

  • Subscribe people with proper consent handling
  • Record behavioral and commerce events
  • Read and upsert profiles
  • List campaigns and segments
  • Power public embed forms
  • Receive outbound webhooks when consent or deliverability events happen

Base URL

Production: https://app.mailpirate.com/api/v1/marketing

All authenticated routes expect JSON (Content-Type: application/json) and a Marketing API token from Settings → API & webhooks.

Endpoint map

Method Path Auth Purpose
POST /subscribe Token Consent-aware signup + default list
POST /events Token Track events (optional profile upsert)
GET /profiles Token Search/list profiles
POST /profiles Token Create/update profile by email (no DOI by itself)
GET /profiles/{public_id} Token Profile detail + predictive when present
GET /campaigns Token Campaign list + counters
GET /segments Token Segment list + cached counts
POST /forms/{form_public_id}/subscribe Public Website form signup

Outbound: configure webhooks under Settings → API & webhooks. See Outbound webhooks.

Choose the right signup path

Goal Use
Person opted in to marketing POST /subscribe or an embed form
Sync CRM fields without starting confirmation email POST /profiles
Track “Viewed Product” / custom events POST /events

Conventions

  • Always send store_slug for the store you mean
  • Identify people, campaigns, segments, and forms with public IDs
  • Retry safely: use idempotency_key on events
  • Treat 401 / 403 / 422 / 429 as described in Errors & limits

Next

  1. Authentication
  2. Subscribe
  3. Events
  4. Outbound webhooks