Skip to main content

Email management API

This page documents the 3 gateway endpoints tagged email management in the gateway's OpenAPI document. Every example targets a gateway on http://localhost:4000 and authenticates with the SPANWAY_API_KEY environment variable, which holds the master key or a virtual key that has access to the route. Request and response fields are taken from the schema the running gateway publishes at /openapi.json, and the same document is bundled with this site as openapi.json.

MethodPathSummary
GET/email/event_settingsList the email events and whether each one is on
PATCH/email/event_settingsTurn email events on or off
POST/email/event_settings/resetTurn every email event back on

Endpoints​

GET /email/event_settings​

List the email events and whether each one is on

Return every email event the gateway can send with enabled set to whether it is currently sent.

Events that were never changed report their default, which is on. Proxy admins and admin viewers may read this.

Docs

Example request:

curl -X GET "http://localhost:4000/email/event_settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY"

Responses:

StatusDescriptionBody
200Every email event with its current switch.application/json EmailEventSettingsResponse
403The caller is not a proxy admin or admin viewer.application/json ErrorDetail
500The gateway has no database, so no settings are stored.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
settingsarray of EmailEventSettingsYesSettings

PATCH /email/event_settings​

Turn email events on or off

Set enabled for the events in settings and leave every other event as it is.

The change applies at once on every gateway replica and is written to the audit log with the settings before and after. Only proxy admins may call this, and it is refused when email_settings is fixed in the config file.

Docs

Request body (application/json, schema EmailEventSettingsUpdateRequest):

FieldTypeRequiredDescription
settingsarray of EmailEventSettingsYesSettings

Example request:

curl -X PATCH "http://localhost:4000/email/event_settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"settings": [
{
"event": "Virtual Key Created",
"enabled": true
},
{
"event": "Soft Budget Crossed",
"enabled": false
}
]
}'

Responses:

StatusDescriptionBody
200The switches were saved and an audit row was written.application/json EmailEventSettingsMessage
400email_settings is set in the config file and cannot be changed through the API.application/json ErrorDetail
403The caller is not a proxy admin.application/json ErrorDetail
422Validation Errorapplication/json HTTPValidationError
500The gateway has no database, so there is nowhere to store it.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage

POST /email/event_settings/reset​

Turn every email event back on

Put every email event back to its default, which is on, and write the change to the audit log.

The route takes no body. Only proxy admins may call it, and it is refused when email_settings is fixed in the config file.

Docs

Request body (application/json, object):

Example request:

curl -X POST "http://localhost:4000/email/event_settings/reset" \
-H "Authorization: Bearer $SPANWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'

Responses:

StatusDescriptionBody
200Every event is on again and an audit row was written.application/json EmailEventSettingsMessage
400email_settings is set in the config file and cannot be changed through the API.application/json ErrorDetail
403The caller is not a proxy admin.application/json ErrorDetail
500The gateway has no database, so there is nowhere to store it.application/json ErrorDetail

Response fields (200):

FieldTypeRequiredDescription
messagestringYesMessage