GreenArrow Email Software Documentation

Event Destinations API

Overview

The Event Destinations API manages the event delivery destinations that the “Event Destinations” page of the Engine UI edits. Each Event Destination is an HTTP destination of the Event Processor that is configured in the database instead of in greenarrow.conf. Its format is json, form or compat_mg (Mailgun-Compatible Webhooks).

The Event Destinations run beside the event_delivery_destination blocks of greenarrow.conf. In the configuration, GreenArrow names each Event Destination ui-destination-{id}, for example ui-destination-12. The config_name attribute gives this name. It shows in greenarrow events status and in the Event Processor logs. greenarrow.conf cannot use a name that starts with ui-destination-.

Applying Changes

You do not have to run greenarrow config reload after a change. The Event Processor reads the enabled Event Destinations each second, and adds them to its running configuration. Thus a change applies within about a second. In a cluster, each MTA and event processor instance pulls the Event Destinations from the shared database every 10 seconds, and its Event Processor then applies them.

The Event Processor checks each enabled Event Destination with the same rules as an event_delivery_destination block of greenarrow.conf. The API checks most of these rules when you save, but the Event Processor can still refuse an Event Destination that the API saved. The error_text attribute gives the error. When the Event Destination loads, error_text becomes null. A save that changes an attribute other than name sets error_text to null. If the changed Event Destination does not load, the Event Processor sets error_text again.

While an Event Destination fails, the Event Processor keeps the settings that it last loaded for it, and GreenArrow keeps queuing its events. If the Event Processor restarts while an Event Destination fails, that Event Destination delivers no events until you correct it. GreenArrow keeps the queued events of that Event Destination. An Event Destination that fails does not stop the other Event Destinations or a greenarrow config reload.

In a cluster, each MTA and event processor instance writes its own error_text. The leader does not run the Event Processor, so the API on the leader does not give the errors of the other instances. An error on an instance shows in the Event Processor log of that instance.

Disabling and Deleting

When you disable an Event Destination (set enabled to false) or delete it, GreenArrow stops queuing events for it. GreenArrow removes the events in its queue one hour later. A disabled Event Destination keeps its settings. If you enable it again within that hour, it delivers the events that are still in its queue. GreenArrow does not queue the events that occur while the Event Destination is disabled.

Permissions

The API permission of the Engine User (permissions.api in the Engine Users API) controls access. A user with the read-only API permission can only get Event Destinations. An API key has full access.

Attributes

The following attributes are defined for Event Destinations. A null value gives the default of the greenarrow.conf directive that is shown in parentheses in the description of the attribute.

event_destination

hash

/

required


id

integer

/

read-only

A unique automatically generated identifier.

name

string

/

required

A descriptive name for this Event Destination. GreenArrow removes the spaces at the start and end of the name. Only the API and the Engine UI use the name.

  • Must be unique (case-insensitive)
  • Must be 1-100 characters long
config_name

string

/

read-only

The name of this Event Destination in the configuration: ui-destination-{id}. greenarrow events status, the Event Processor logs and error_text use this name.

enabled

boolean

/

default: true

When false, GreenArrow does not deliver or queue events for this Event Destination. See Disabling and Deleting.

format

string

/

default: json

The format of the requests (event_delivery_format).

  • Must be one of: json, form, or compat_mg
url

string

/

required

The URL that receives the events (event_delivery_url).

  • Must start with http:// or https://, and have a host name
timeout_seconds

integer

/

default: null

The number of seconds to wait for the URL to respond (event_delivery_timeout). null gives the default of 30 seconds.

  • Must be a positive whole number
disable_batching

boolean

/

default: null

When true, each request has one event (event_delivery_disable_batching). null gives false for json, and true for form and compat_mg.

  • Cannot be false when format is form or compat_mg
http_keepalive

boolean

/

default: null

Whether to keep the HTTP connections open between requests (event_delivery_http_keepalive). null gives true.

http_user_agent

string

/

default: null

The User-Agent header of the requests (event_delivery_http_user_agent). null gives GreenArrow. A blank value is stored as null.

max_batch_size

integer

/

default: null

The largest number of events in one request (event_delivery_max_batch_size). null gives 100. Used only when batching is enabled (disable_batching is false, or null with the json format).

  • Must be between 1 and 1000
max_concurrent_connections

integer

/

default: null

The largest number of requests at the same time (event_delivery_max_concurrent_connections). null gives 3.

  • Must be between 1 and 250
verify_peer

boolean

/

default: null

Whether to verify the TLS certificate of an https:// URL (event_delivery_verify_peer). null gives true.

event_types

array of strings

/

default: []

The types of events to deliver (event_delivery_events). The Event Destination receives no events when this list is empty. List each type by name: the keyword all is not accepted.

Used only when format is json or form. A compat_mg Event Destination keeps this value, so that it applies again if the format changes back.

  • Each entry must be one of: delivery_attempt, bounce_all.engine, bounce_all.studio, bounce_bad_address.engine, bounce_bad_address.studio, scomp.engine, scomp.studio, engine_click, engine_open, engine_unsub, studio_click, studio_open, studio_unsub, studio_subscriber_created, studio_subscriber_updated, bounce_lite, scomp_lite, incoming_email, or new_message
  • Must not name a type more than once
  • Can add the Studio types (*.studio and studio_*) only on a standalone GreenArrow that has a Studio license
  • Can add incoming_email only when the s3 incoming_email_event purpose is configured
  • An Event Destination keeps the Studio and incoming_email types that it already has, even when GreenArrow no longer offers them
delivery_attempts

hash



Which delivery_attempt events to deliver (event_delivery_delivery_attempt_config). Used only when format is json or form, and event_types includes delivery_attempt. Each value must be true or false.

status_success

boolean

/

default: true

Successful deliveries.

status_deferral

boolean

/

default: false

Deferrals.

status_failure

boolean

/

default: true

Failures for reasons other than the time in the queue.

status_failure_toolong

boolean

/

default: true

Failures because the message was in the queue too long.

status_connmaxout

boolean

/

default: false

Deferrals because of throttling (connmaxout).

include_first_attempt_regardless_of_status

boolean

/

default: true

The first attempt of each message, whatever its status.

include_local_channel

boolean

/

default: false

Local deliveries.

anonymize_localparts

boolean

/

default: null

Whether to anonymize the local parts of email addresses (event_delivery_anonymize_localparts). null gives false. Used only when format is json or form.

anonymize_clicktrackingid

boolean

/

default: null

Whether to anonymize the Click Tracking IDs (event_delivery_anonymize_clicktrackingid). null gives false. Used only when format is json or form.

compat_mg

hash



The settings of the compat_mg format. Used only when format is compat_mg.

signing_key

string

/

write-only

The key of the webhook signature (event_delivery_compat_mg_signing_key). The response never includes the key. A request with no key, or with a blank key, keeps the current key.

  • Required when format is compat_mg
signing_key_is_set

boolean

/

read-only

Whether a signing key is set.

webhooks

array of strings

/

default: []

The webhook types to send (event_delivery_compat_mg_webhooks).

  • Required when format is compat_mg
  • Each entry must be one of: accepted, delivered, permanent_fail, temporary_fail, complained, opened, clicked, or unsubscribed
error_text

string

/

read-only

The error that the Event Processor gave when it last loaded this Event Destination, or null. See Applying Changes.

A compat_mg Event Destination also needs the global log_header directive of greenarrow.conf to log the From, To and Subject headers. The API refuses to create a compat_mg Event Destination, or to change the format of an Event Destination to compat_mg, if these headers are not logged. The API checks the configuration of the last greenarrow config reload. After you add them to greenarrow.conf, run greenarrow config reload before you save the Event Destination. If greenarrow.conf stops logging these headers later, the Event Destination continues to deliver, but its webhooks do not include the headers that are not logged. The Engine UI shows a warning for such an Event Destination.

The API does not support the other event_delivery_destination directives, such as event_delivery_filter_mail_class or event_delivery_client_certificate_file. To use them, configure the destination in greenarrow.conf.

Get a List of Event Destinations

GET /ga/api/v3/eng/event_destinations

Parameters

The following parameters are valid for the above endpoint.

page

integer

/

optional

The page number from which to retrieve. Page numbering starts at 0.

per_page

integer

/

optional

The number of records to return on each page. The default is 100. The maximum is 2000.

page_token

string

/

optional

The page_token to retrieve the next page based on the prior query results.

name

string

/

optional

Give only the Event Destination that has this name. The comparison ignores case.

Examples:

GET /ga/api/v3/eng/event_destinations?page={page}
GET /ga/api/v3/eng/event_destinations?page={page}&per_page={per_page}
GET /ga/api/v3/eng/event_destinations?page_token={page_token}
GET /ga/api/v3/eng/event_destinations?name={name}

Response

The response will contain a list of Event Destinations, in the order of their id, in the following format.

event_destinations

array of hashes


id

integer

An automatically generated identifier.

name

string

A descriptive name for this Event Destination.

config_name

string

The name of this Event Destination in the configuration: ui-destination-{id}.

enabled

boolean

Whether this Event Destination is enabled.

format

string

The format of the requests: json, form, or compat_mg.

url

string

The URL that receives the events.

pagination

hash


page

integer

The page number of this result set. Page numbers start at 0.

per_page

integer

The number of records returned on each page.

num_pages

integer

The total number of pages in the result set.

num_records

integer

The total number of records that are in the result set.

next_page_token

string

A unique identifier that can be used to retrieve the next result set.

null is returned if this is the last page.

Example 1: Get the First Page of Event Destinations

GET /ga/api/v3/eng/event_destinations

HTTP/1.1 200 OK

{
  "success": true,
  "data": {
    "event_destinations": [
      {
        "id": 12,
        "name": "Webhooks",
        "config_name": "ui-destination-12",
        "enabled": true,
        "format": "json",
        "url": "https://example.com/webhooks"
      },
      {
        "id": 13,
        "name": "Mailgun",
        "config_name": "ui-destination-13",
        "enabled": false,
        "format": "compat_mg",
        "url": "https://api.example.com/webhooks/mailgun"
      },
      {
        "id": 14,
        "name": "Archive",
        "config_name": "ui-destination-14",
        "enabled": true,
        "format": "form",
        "url": "https://archive.example.com/events"
      }
    ],
    "pagination": {
      "page": 0,
      "per_page": 100,
      "num_pages": 1,
      "num_records": 3,
      "next_page_token": null
    }
  },
  "error_code": null,
  "error_messages": null
}

Example 2: Get a Specific Page of Event Destinations with Per-Page Limits

GET /ga/api/v3/eng/event_destinations?page=1&per_page=2

HTTP/1.1 200 OK

{
  "success": true,
  "data": {
    "event_destinations": [
      {
        "id": 14,
        "name": "Archive",
        "config_name": "ui-destination-14",
        "enabled": true,
        "format": "form",
        "url": "https://archive.example.com/events"
      }
    ],
    "pagination": {
      "page": 1,
      "per_page": 2,
      "num_pages": 2,
      "num_records": 3,
      "next_page_token": null
    }
  },
  "error_code": null,
  "error_messages": null
}

Example 3: Find an Event Destination by Name

GET /ga/api/v3/eng/event_destinations?name=mailgun

HTTP/1.1 200 OK

{
  "success": true,
  "data": {
    "event_destinations": [
      {
        "id": 13,
        "name": "Mailgun",
        "config_name": "ui-destination-13",
        "enabled": false,
        "format": "compat_mg",
        "url": "https://api.example.com/webhooks/mailgun"
      }
    ],
    "pagination": {
      "page": 0,
      "per_page": 100,
      "num_pages": 1,
      "num_records": 1,
      "next_page_token": null
    }
  },
  "error_code": null,
  "error_messages": null
}

Get Details on a Single Event Destination

GET /ga/api/v3/eng/event_destinations/{id}

Response

The response will contain details on the requested record:

event_destination

hash

The attributes for this hash are defined in the Attributes section of this document.

If there is no Event Destination with this id, the error_code is not_found.

Example

GET /ga/api/v3/eng/event_destinations/12

HTTP/1.1 200 OK

{
  "success": true,
  "data": {
    "event_destination": {
      "id": 12,
      "name": "Webhooks",
      "config_name": "ui-destination-12",
      "enabled": true,
      "format": "json",
      "url": "https://example.com/webhooks",
      "timeout_seconds": null,
      "disable_batching": null,
      "http_keepalive": null,
      "http_user_agent": null,
      "max_batch_size": null,
      "max_concurrent_connections": null,
      "verify_peer": null,
      "event_types": [
        "delivery_attempt",
        "engine_click"
      ],
      "delivery_attempts": {
        "status_success": true,
        "status_deferral": false,
        "status_failure": true,
        "status_failure_toolong": true,
        "status_connmaxout": false,
        "include_first_attempt_regardless_of_status": true,
        "include_local_channel": false
      },
      "anonymize_localparts": null,
      "anonymize_clicktrackingid": null,
      "compat_mg": {
        "signing_key_is_set": false,
        "webhooks": []
      },
      "error_text": null
    }
  },
  "error_code": null,
  "error_messages": null
}

Create an Event Destination

POST /ga/api/v3/eng/event_destinations

Payload

event_destination

hash

/

required

The content of this hash is described in the Attributes section of this page.

The data may contain a mixture of required and optional fields. Do not specify read-only fields.

Response

The response will include an event_destination key containing the full Event Destination record as defined in the Event Destination Attributes.

Example 1: Create a Mailgun-Compatible Event Destination

For this example, the global log_header directive must log the From, To and Subject headers. See the note after Attributes.

POST /ga/api/v3/eng/event_destinations

{
  "event_destination": {
    "name": "Mailgun",
    "format": "compat_mg",
    "url": "https://api.example.com/webhooks/mailgun",
    "compat_mg": {
      "signing_key": "key-3ax6xnjp29jd6fds4gc373sgvjxteol0",
      "webhooks": [
        "permanent_fail",
        "complained"
      ]
    }
  }
}

HTTP/1.1 200 OK

{
  "success": true,
  "data": {
    "event_destination": {
      "id": 13,
      "name": "Mailgun",
      "config_name": "ui-destination-13",
      "enabled": true,
      "format": "compat_mg",
      "url": "https://api.example.com/webhooks/mailgun",
      "timeout_seconds": null,
      "disable_batching": null,
      "http_keepalive": null,
      "http_user_agent": null,
      "max_batch_size": null,
      "max_concurrent_connections": null,
      "verify_peer": null,
      "event_types": [],
      "delivery_attempts": {
        "status_success": true,
        "status_deferral": false,
        "status_failure": true,
        "status_failure_toolong": true,
        "status_connmaxout": false,
        "include_first_attempt_regardless_of_status": true,
        "include_local_channel": false
      },
      "anonymize_localparts": null,
      "anonymize_clicktrackingid": null,
      "compat_mg": {
        "signing_key_is_set": true,
        "webhooks": [
          "permanent_fail",
          "complained"
        ]
      },
      "error_text": null
    }
  },
  "error_code": null,
  "error_messages": null
}

Example 2: Validation Errors

In this example, the Event Destination “Webhooks” already exists.

POST /ga/api/v3/eng/event_destinations

{
  "event_destination": {
    "name": "WEBHOOKS",
    "url": "ftp://example.com",
    "max_batch_size": 0,
    "event_types": [
      "bogus"
    ]
  }
}

HTTP/1.1 200 OK

{
  "success": false,
  "data": null,
  "error_code": "validation_failed",
  "error_messages": [
    "event_destination.name: has already been taken",
    "event_destination.url: must be a URL that starts with http:// or https:// and has a host name",
    "event_destination.max_batch_size: must be greater than or equal to 1",
    "event_destination.event_types: contains an unknown event type: bogus"
  ]
}

Update an Event Destination

PUT /ga/api/v3/eng/event_destinations/{id}

An update changes only the attributes that the request names.

For an attribute whose default is null, a null value clears it, so the default of its greenarrow.conf directive applies. name, enabled, format, url and the delivery_attempts values cannot be null. A null or blank compat_mg.signing_key keeps the current key.

Payload

event_destination

hash

/

required

The content of this hash is described in the Attributes section of this page.

The data may contain a mixture of required and optional fields. Do not specify read-only fields.

Response

The response will include an event_destination key containing the full Event Destination record as defined in the Event Destination Attributes. An update that changes an attribute other than name sets error_text to null. See Applying Changes.

If there is no Event Destination with this id, the error_code is not_found.

Example 1: Change the Timeout

PUT /ga/api/v3/eng/event_destinations/12

{
  "event_destination": {
    "timeout_seconds": 15
  }
}

HTTP/1.1 200 OK

{
  "success": true,
  "data": {
    "event_destination": {
      "id": 12,
      "name": "Webhooks",
      "config_name": "ui-destination-12",
      "enabled": true,
      "format": "json",
      "url": "https://example.com/webhooks",
      "timeout_seconds": 15,
      "disable_batching": null,
      "http_keepalive": null,
      "http_user_agent": null,
      "max_batch_size": null,
      "max_concurrent_connections": null,
      "verify_peer": null,
      "event_types": [
        "delivery_attempt",
        "engine_click"
      ],
      "delivery_attempts": {
        "status_success": true,
        "status_deferral": false,
        "status_failure": true,
        "status_failure_toolong": true,
        "status_connmaxout": false,
        "include_first_attempt_regardless_of_status": true,
        "include_local_channel": false
      },
      "anonymize_localparts": null,
      "anonymize_clicktrackingid": null,
      "compat_mg": {
        "signing_key_is_set": false,
        "webhooks": []
      },
      "error_text": null
    }
  },
  "error_code": null,
  "error_messages": null
}

Example 2: Change the Name

PUT /ga/api/v3/eng/event_destinations/12

{
  "event_destination": {
    "name": "Order Webhooks"
  }
}

The response is the full Event Destination, with name set to Order Webhooks.

Delete an Event Destination

DELETE /ga/api/v3/eng/event_destinations/{id}

See Disabling and Deleting for what happens to the queued events.

Response

The response is a standard success or error response. If there is no Event Destination with this id, the error_code is not_found.

Example

DELETE /ga/api/v3/eng/event_destinations/13

HTTP/1.1 200 OK

{
  "success": true,
  "data": {
  },
  "error_code": null,
  "error_messages": null
}


Copyright © 2012–2026 GreenArrow Email