Skip to content

Data Events

The core sheepCRM emits data events in response to system changes. The most common and most useful data events are lifecycle events such as new_membership. Data events are useful for auditing, reporting and for connecting to supplementary actions. The default expiry for data events is two years but a custom expiry can be added on a record by record basis.

Key concepts:

TermDescription
data eventBase name for the event, e.g. new_membership.
variationsDate/time variations; event and variation are joined with an underscore, e.g. 2wk creates new_membership_2wk (new membership + 2 weeks), or 90d creates lapsed_90d (lapsed + 90 days).
DaysModifier
180180d
9090d
284wk
213wk
142wk
71wk
11d
0(none)
-1minus_1d
-2minus_2d
-7minus_1wk
-14minus_2wk
-21minus_3wk
-28minus_4wk
-90minus_90d
-180minus_180d
Data EventVariationsData PresentDateNotes
action_required_summarytextdailySummary of actions required
donation / pledgepledgepledge start dateUse for one-off action
no_payment_invoice180, 90, 28, 7invoiceinvoice date
contactcreatedcontactcreation datePeople and orgs
evidence_draft_reference1wk, 2wk, 3wkevidencecreation date
form_responsecreated, submitted, withdrawn, scoring_completeform_responsedate/time of action
form_responsestate_{from}_to_{to}form_responsedate/time of actionSent from flow changes
reservationcreated, cancelled, state_{from}_to_{to}reservationcreation / update date
ticketconfirmationticketcreation date
ticketed_event7, 1, 0, -1, -2, -7, -14, -28, -90ticketbooking start date
vm_start7, 1, 0, -1, -2, -7, -14, -21, -28, -30, -90bookingbooking start date
achievementcompletedachievementmarked as complete/finished
Data EventVariationsDateNotes
cancelled_membershipend_dateAt time of end date
cancelling_membershipdate/time of actionAt time of cancellation
expiring1wk, 2wk, 3wk, 4wk, 6wk, soonend_date minusWhen auto renew has not been set. Fires before the expiry date, e.g. expiring_3wk is 3 weeks before expiry
lapsed1d, 1wk, 2wk, 3wk, 4wk, 90d, 180dend_date plusFire after a membership end date where it has not been renewed
linked_memberadded, removed, added_no_useraccounttime of actionWelcome email sequence; linked member is the entity
new_membership1d, 2d, 1wk, 2wk, 3wk, 4wk, 180dmembership start date+Use a receipt/confirmation on renewal
renewalconfirmationtime of renewalUse as a welcome to your renewed membership
renewed_membership1wk, 2wkstart_date
renewing1wk, 2wk, 3wk, 4wk, soonend_date minus
no_payment_membership1d, 1wk, 2wk, 3wk, 4wk, 90dstart_date plus

The payment record is the context to these events:

Data EventDateNotes
membership_payment_receivedpayment date
order_payment_receivedpayment dateWhere the payment reference is a booking
ticket_payment_receivedpayment dateWhere the payment reference is a ticket
donation_payment_receivedpayment date
reservation_payment_receivedpayment date
invoice_payment_receivedpayment date
payment_receivedpayment dateWhere the payment reference is none of the above

The following events are deprecated and should not be used for new integrations:

  • renewing_1wk_no_dd_mandate, renewing_1wk_woo
  • renewing_2wk_no_dd_mandate, renewing_2wk_woo
  • renewing_3wk_no_dd_mandate, renewing_3wk_woo
  • renewing_4wk_no_dd_mandate, renewing_4wk_woo
  • renewing_soon_no_dd_mandate, renewing_soon_woo
Data EventDateVariationsNotes
applicationdate/time of actionaccepted, rejected, submittedApplication e.g. group membership
email_undeliverabledate/time of email sendFailed email delivery
enrichmentdate/time of actionWhen an enrichment token is used
exportdate/time of actionData export from sheepCRM
failed_logindate/time of action
form_score_review_bydate/time of action14, 7, 2, 1, 0, -1, -2, -7
form_score_expirydate/time of action
gocardlessdate/time of actionsync, error
logindate/time of action
multiple_failed_logindate/time of actionMultiple failures within short time window
mailchimpopen, click, bounce, sent, unsubscribe, syncEvents from MailChimp
mandatemandate date / date of updateactive, created, cancelled, failed, pending_customer_approval, pending_submission, submittedEvents from GoCardless
woocommercedate/time of actionsync, error

Actions are the tasks which should be executed in response to a data event.

ActionNotes
send-templated-emailSend a templated email.
draft-templated-emailCreate a draft templated email.
send-json-webhookSend a webhook. URL field must be a full URL to POST to (only POST to secure URLs is supported).
send-webhookDeprecated. Send a webhook. URL field must be a full URL to POST to.
send-email-to-fixed-addressSend a templated email but always to the same address (use like a BCC or to alert someone to an error event).

The API offers a read-only view on events and actions:

GET https://api.sheepcrm.com/api/v1/{flock}/triggers/
Authorization: Bearer $API_KEY
HTTP/1.1 200 OK
{
"new_membership": [
{
"trigger": "new_membership",
"action": "send-templated-email",
"template": "New member welcome",
"url": null,
"active": true,
"comment": ""
}
],
"new_membership_1wk": [
{
"trigger": "new_membership_1wk",
"action": "send-templated-email",
"template": "New member (1 week)",
"url": null,
"active": true,
"comment": ""
}
]
}

Actions can be added and edited through the administrator interface at https://sheepcrm.com/{flock}/action/.

  • The “standard template” will provide the data packet of the event (e.g. membership + some basic people data about the contact).
  • If a webhook does not get a 200 or 201 response it will retry for approximately 7 days.
  • A trigger will successfully fire only once (a tag is added to the event when successfully fired — removing the tag will cause re-firing).

Use conditional template rules when you want to choose a template based upon data. This allows you, for example, to design one template for your personal members and another for your corporate members.

{
"template": [
{
"order": 1,
"template": "new membership a",
"conditions": [
{"membership_type": "Graduate Member"}
]
},
{
"order": 4,
"template": "new membership b",
"conditions": [
{
"membership_type": "ASSOCIATE MEMBERSHIP",
"tags": "special"
}
]
}
]
}

How it works:

  • Template rules are JSON (invalid JSON will not be evaluated; use a JSON validator to check your rules).
  • Template rules are checked in number order from low to high.
  • Each rule can have any number of conditions.
  • All conditions must evaluate to True for the rule to be used.
  • If no rule is successful then the template field on the action is used.
  • If no default action is desired, do not configure the base template field.
  • Conditions can use any field available on the data event.
  • Only simple equality is implemented:
    • List types: "tags": "fish" (will evaluate to True if “fish” is one of the tags)
    • Reference types: the name of the reference or the URI can be used, e.g. "membership_type": "ASSOCIATE MEMBERSHIP" or "membership_type": "/example/membership_type/123456/"

Bulk actions use a one-off action and a sheep_event to perform a background update based on a query. The text_body of the sheep_event is updated with details of the action when it has been completed.

ParameterDescription
actionadd_tag, remove_tag, set-single-field, set-single-field-on-last-membership
queryLookup query.
fieldThe field to change.
valueThe new value.
descriptionName your bulk action for future reference.
resource_typeOptional. Resource type to query against (default is contacts).
POST https://api.sheepcrm.com/api/v1/example/bulk_action/
Authorization: Bearer $API_KEY
Content-Type: application/json
{
"action": "set-single-field",
"query": {"first_name": "Bob"},
"value": "Robert",
"field": "first_name",
"description": "bob->robert"
}
POST https://api.sheepcrm.com/api/v1/example/bulk_action/
Authorization: Bearer $API_KEY
Content-Type: application/json
{
"action": "set-single-field-on-last-membership",
"query": {"first_name": "Peter"},
"value": "/example/payment_plan/5e62258ab4d5a22356535ce2/",
"field": "next_payment_plan",
"description": "Move all Peter's to invoice payment plans"
}