Back to top

API Documentation

Deal Triggers

Brand-level deal automation defaults. Each rule is defined on a brand and applied to that brand’s deals (resolved across the brand’s ancestry).

A rule has a trigger, an action, and a wait_for offset:

  • trigger — what schedules it: deal_created, offer_checklist_added, or context_date_arrived (which also requires a context deal-context key, e.g. closing_date).

  • action — what it does. The only action today is send_email, which requires an email (a brand email template id) and emails the deal’s client(s).

  • wait_for — a Postgres interval offset (e.g. -3 days to fire three days before a context date, 0 to fire immediately).

Endpoints

Create a brand deal trigger

Create a brand deal trigger
POST/brands/:id/deals/triggers

Example URI

POST /brands/:id/deals/triggers
URI Parameters
HideShow
id
string (required) Example: d209a02b-421c-4d1c-adcb-7e82b7a3c106
Request
HideShow
Body
{
  "trigger": "context_date_arrived",
  "context": "review_date",
  "action": "send_email",
  "email": "74352a27-02df-42dc-b546-1e9441a955da",
  "wait_for": "-3 days",
  "brand": "d209a02b-421c-4d1c-adcb-7e82b7a3c106",
  "created_by": "4a305929-0883-49de-a005-cb63d991b9a7"
}
Response  200
HideShow
Body
{
  "code": "OK",
  "data": {
    "id": "97c74e8e-985a-41ac-8e1e-d0e405e534aa",
    "created_at": 1783014835,
    "updated_at": 1783014835,
    "deleted_at": null,
    "created_by": "4a305929-0883-49de-a005-cb63d991b9a7",
    "brand": "d209a02b-421c-4d1c-adcb-7e82b7a3c106",
    "trigger": "context_date_arrived",
    "context": "review_date",
    "wait_for": {
      "days": -3
    },
    "action": "send_email",
    "email": "74352a27-02df-42dc-b546-1e9441a955da",
    "type": "brand_deal_trigger"
  }
}

Get a brand's deal triggers

Get a brand's deal triggers
GET/brands/:id/deals/triggers

Example URI

GET /brands/:id/deals/triggers
URI Parameters
HideShow
id
string (required) Example: d209a02b-421c-4d1c-adcb-7e82b7a3c106
Response  200
HideShow
Body
{
  "code": "OK",
  "data": [
    {
      "id": "97c74e8e-985a-41ac-8e1e-d0e405e534aa",
      "created_at": 1783014835,
      "updated_at": 1783014835,
      "deleted_at": null,
      "created_by": "4a305929-0883-49de-a005-cb63d991b9a7",
      "brand": "d209a02b-421c-4d1c-adcb-7e82b7a3c106",
      "trigger": "context_date_arrived",
      "context": "review_date",
      "wait_for": {
        "days": -3
      },
      "action": "send_email",
      "email": "74352a27-02df-42dc-b546-1e9441a955da",
      "type": "brand_deal_trigger"
    }
  ],
  "info": {
    "count": 1,
    "total": 0
  }
}

Update a brand deal trigger

Update a brand deal trigger
PUT/brands/:id/deals/triggers/:tid

Example URI

PUT /brands/:id/deals/triggers/:tid
URI Parameters
HideShow
id
string (required) Example: d209a02b-421c-4d1c-adcb-7e82b7a3c106
tid
string (required) Example: 97c74e8e-985a-41ac-8e1e-d0e405e534aa
Request
HideShow
Body
{
  "trigger": "deal_created",
  "action": "send_email",
  "email": "74352a27-02df-42dc-b546-1e9441a955da",
  "wait_for": "0",
  "id": "97c74e8e-985a-41ac-8e1e-d0e405e534aa"
}
Response  200
HideShow
Body
{
  "code": "OK",
  "data": {
    "id": "97c74e8e-985a-41ac-8e1e-d0e405e534aa",
    "created_at": 1783014835,
    "updated_at": 1783014835,
    "deleted_at": null,
    "created_by": "4a305929-0883-49de-a005-cb63d991b9a7",
    "brand": "d209a02b-421c-4d1c-adcb-7e82b7a3c106",
    "trigger": "deal_created",
    "context": null,
    "wait_for": {},
    "action": "send_email",
    "email": "74352a27-02df-42dc-b546-1e9441a955da",
    "type": "brand_deal_trigger"
  }
}

Delete a brand deal trigger

Delete a brand deal trigger
DELETE/brands/:id/deals/triggers/:tid

Example URI

DELETE /brands/:id/deals/triggers/:tid
URI Parameters
HideShow
id
string (required) Example: d209a02b-421c-4d1c-adcb-7e82b7a3c106
tid
string (required) Example: 97c74e8e-985a-41ac-8e1e-d0e405e534aa
Response  204
HideShow
Body
Brand defaults are materialized onto each deal as scheduled instances. All of a
deal's triggers are exposed via the `deal.triggers` association; the context-date
subset is additionally grouped per context key under `deal_context.triggers`
(event triggers like `deal_created` have no context, so they only appear under
`deal.triggers`). Either can be rescheduled or cancelled for the individual deal.

Get a deal's scheduled triggers

Get a deal's scheduled triggers
GET/deals/:id?associations[]=deal.triggers

Example URI

GET /deals/:id?associations[]=deal.triggers
URI Parameters
HideShow
id
string (required) Example: fb1cd6e4-c85f-4432-84d7-522391a3db2e
associations
string (required) Example: deal.triggers
Response  200
HideShow
Body
{
  "code": "OK",
  "data": {
    "id": "fb1cd6e4-c85f-4432-84d7-522391a3db2e",
    "created_at": 1783014836.131447,
    "updated_at": 1783014836.131447,
    "deleted_at": null,
    "listing": null,
    "deal_type": "Buying",
    "brokerwolf_tier_id": null,
    "brokerwolf_id": null,
    "brokerwolf_row_version": null,
    "number": 7,
    "faired_at": null,
    "title": "[Draft]",
    "type": "deal",
    "attention_requested_at": null,
    "is_draft": true,
    "roles": null,
    "context": {
      "property_type": {
        "id": null,
        "type": "deal_context_item",
        "created_at": null,
        "created_by": null,
        "approved_by": null,
        "approved_at": null,
        "key": "property_type",
        "text": "Residential Lease",
        "number": null,
        "date": null,
        "data_type": "Text",
        "deal": "fb1cd6e4-c85f-4432-84d7-522391a3db2e",
        "checklist": null,
        "source": "PropertyType",
        "definition": "c6829628-0d0a-4589-b40f-8151be35593b",
        "searchable": "'leas':2 'residenti':1",
        "deleted_at": null
      },
      "review_date": {
        "id": "15795459-ee64-481f-9442-3edd3bd7d0bd",
        "type": "deal_context_item",
        "created_at": "2026-07-02T17:53:55.161607+00:00",
        "created_by": "4a305929-0883-49de-a005-cb63d991b9a7",
        "approved_by": null,
        "approved_at": null,
        "key": "review_date",
        "text": "2017/12/06",
        "number": null,
        "date": 1512518400,
        "data_type": "Date",
        "deal": "fb1cd6e4-c85f-4432-84d7-522391a3db2e",
        "checklist": "4cf8f9fc-f172-4ef4-a6ec-3212da54dc5d",
        "source": "Provided",
        "definition": "16768b43-0bca-409d-83d5-caa1e4f6e2b4",
        "searchable": "'2017/12/06':1",
        "deleted_at": null
      },
      "type": "deal_context"
    },
    "new_notifications": null,
    "attention_requests": 0,
    "has_active_offer": true,
    "triggers": [
      {
        "id": "4a3a7ba7-5b14-4caa-a429-fa12398d9f5a",
        "created_at": 1783014835,
        "updated_at": 1783014835,
        "deleted_at": null,
        "created_by": "4a305929-0883-49de-a005-cb63d991b9a7",
        "deal": "fb1cd6e4-c85f-4432-84d7-522391a3db2e",
        "brand_deal_trigger": "97c74e8e-985a-41ac-8e1e-d0e405e534aa",
        "trigger": "context_date_arrived",
        "context": "review_date",
        "action": "send_email",
        "email": "74352a27-02df-42dc-b546-1e9441a955da",
        "wait_for": {
          "days": -3
        },
        "effective_at": 1783014835,
        "due_at": 1512259200,
        "executed_at": null,
        "failed_at": null,
        "failure": null,
        "email_campaign": null,
        "type": "deal_trigger"
      }
    ],
    "email": "[email protected]"
  }
}

Reschedule / retarget a scheduled trigger

Reschedule / retarget a scheduled trigger
PUT/deals/:id/triggers/:tid

Body accepts wait_for (interval offset) and/or email (brand email template id).

Example URI

PUT /deals/:id/triggers/:tid
URI Parameters
HideShow
id
string (required) Example: fb1cd6e4-c85f-4432-84d7-522391a3db2e
tid
string (required) Example: 4a3a7ba7-5b14-4caa-a429-fa12398d9f5a
Request
HideShow
Body
{
  "wait_for": "-1 day",
  "email": "74352a27-02df-42dc-b546-1e9441a955da"
}
Response  200
HideShow
Body
{
  "code": "OK",
  "data": {
    "id": "4a3a7ba7-5b14-4caa-a429-fa12398d9f5a",
    "created_at": 1783014835,
    "updated_at": 1783014835,
    "deleted_at": null,
    "created_by": "4a305929-0883-49de-a005-cb63d991b9a7",
    "deal": "fb1cd6e4-c85f-4432-84d7-522391a3db2e",
    "brand_deal_trigger": "97c74e8e-985a-41ac-8e1e-d0e405e534aa",
    "trigger": "context_date_arrived",
    "context": "review_date",
    "action": "send_email",
    "email": "74352a27-02df-42dc-b546-1e9441a955da",
    "wait_for": {
      "days": -1
    },
    "effective_at": 1783014835,
    "due_at": 1512432000,
    "executed_at": null,
    "failed_at": null,
    "failure": null,
    "email_campaign": null,
    "type": "deal_trigger"
  }
}

Cancel a scheduled trigger

Cancel a scheduled trigger
DELETE/deals/:id/triggers/:tid

Example URI

DELETE /deals/:id/triggers/:tid
URI Parameters
HideShow
id
string (required) Example: fb1cd6e4-c85f-4432-84d7-522391a3db2e
tid
string (required) Example: 4a3a7ba7-5b14-4caa-a429-fa12398d9f5a
Response  204

Generated by aglio on 02 Jul 2026