Custom API and payload mapping
7 min
custom api automations let another system trigger peach use this when an external app, backend service, form, crm, billing system, or internal tool should start an automation rule api styles peach supports two custom api styles in the automation builder style endpoint best for automation endpoint a rule specific endpoint one payload should trigger one automation topic mapped payload the general events endpoint multiple automations may listen to the same topic automation endpoint use the automation endpoint when the payload belongs to one specific rule after saving the rule, peach shows the url for that automation example shape curl x post https //your domain/api/v1/streams/stream id/events \\ h "x account api key your api key" \\ h "content type application/json" \\ d '{ "contact" { "phone number" "+14155550123", "name" "jane doe" } }' topic mapped payload use topic mapped payloads when the event should be routed by a topic name example shape curl x post https //your domain/api/v1/events \\ h "x account api key your api key" \\ h "content type application/json" \\ d '{ "topic" "lead created", "contact" { "phone number" "+14155550123", "name" "jane doe" } }' the rule's topic condition must match the payload topic recipient mapping recipient mapping tells peach who the automation should run for common fields are field example jsonpath name $ contact name phone number $ contact phone number email $ contact email the phone number is the most important field for whatsapp automations template variable mapping when an automation sends a whatsapp template or flow template with placeholders, map incoming payload fields to those variables for example, if a template needs order id and delivery date , map each placeholder to the matching field in the payload deduplication keys deduplication keys help peach avoid running the same automation twice for the same external event use a stable external id when available, such as order id payment id event id ticket id testing tips start with a test contact and a narrow payload confirm that the api key is valid the topic or automation endpoint is correct the recipient phone number is present template variables resolve correctly the rule is active the phone number is in a whatsapp ready format