Guide

CRM REST API

CRM adds custom routes. Contact CRUD uses the core WordPress REST API at /wp/v2/prc-crm-contacts. Quick add posts to that route with meta.source = quick-add. Share links use /wp/v2/prc-crm-shares.

Compose email

Request POST /wp-json/wp/v2/pages
HeadersKey: value
Accept application/jsonAuthorization Bearer $WP_ACCESS_TOKEN
Response 200 OK
BodyJSON
{
  "id": 42,
  "slug": "getting-started"
}

Requires edit_posts and a registered prc_email_txn post type.

Body fieldTypeNotes
contactIdsinteger[]Contact post IDs. Ignored when segmentId is set.
segmentIdintegerprc_crm_segment term ID. Optional.

Success payload:

FieldType
postIdinteger, draft transactional post
editUrlstring, wp-admin editor URL
audienceKeystring, prc_email_audience_* option
countinteger, recipient count

Error codes include prc_crm_email_unavailable, prc_crm_no_recipients, and prc_crm_missing_segment.

Contact insights

Request GET /wp-json/wp/v2/pages
HeadersKey: value
Accept application/jsonAuthorization Bearer $WP_ACCESS_TOKEN
Response 200 OK
BodyJSON
{
  "id": 42,
  "slug": "getting-started"
}

Requires edit_post on the contact.

Success payload:

FieldType
emailsarray of message summaries (emailPostId, title, status, activity, opens, opensUnique, clicks, clicksUnique, clickThroughs, completed, lastEventAt, editUrl)
sharesarray of share rows (shareId, title, url, hitCount, lastAccessAt)

Mandrill webhook

Request POST /wp-json/wp/v2/pages
HeadersKey: value
Accept application/jsonAuthorization Bearer $WP_ACCESS_TOKEN
Response 200 OK
BodyJSON
{
  "id": 42,
  "slug": "getting-started"
}

Unauthenticated except for the site webhook key. Pass it as key on the query string or as the X-PRC-CRM-Webhook-Key header. Print the URL with wp prc crm webhook-url.

Body is Mandrill's mandrill_events form field (JSON array). CRM stores events whose recipient email matches a contact.

Success payload:

FieldType
storedinteger, number of events written

Create contact from a form

Request POST /wp-json/wp/v2/pages
HeadersKey: value
Accept application/jsonAuthorization Bearer $WP_ACCESS_TOKEN
Response 200 OK
BodyJSON
{
  "id": 42,
  "slug": "getting-started"
}

Public form route. Same envelope as other prc-block/form REST actions (formName, formId, formPostId, formFields). Public submissions go through Turnstile when a secret is configured. Users who can publish posts skip captcha.

Email is required. The handler maps common field names and labels onto Contact_Fields and upserts on normalized email. New contacts get source = form or form:{formPostId}.

Success payload:

FieldType
statusstring, success
messagestring
contactIdinteger
createdboolean, true when a new contact was inserted

Error prc_crm_missing_email (400) when the submission has no valid email. The handler does not insert a blank contact.

Create contacts from form responses

Request POST /wp-json/wp/v2/pages
HeadersKey: value
Accept application/jsonAuthorization Bearer $WP_ACCESS_TOKEN
Response 200 OK
BodyJSON
{
  "id": 42,
  "slug": "getting-started"
}

Requires edit_posts and the form responses capability (prc_form_responses_capability, default manage_options). Body: { "ids": [1, 2] } (max 100). CRM reads each stored response and upserts on email. Spam rows and rows without a valid email are skipped.

Success payload:

FieldType
createdinteger
updatedinteger
skippedarray of { id, code, message }
contactsarray of { responseId, contactId, created }

Was this helpful?