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.
| Method | Path | Summary |
|---|---|---|
| GET | /email/event_settings | List the email events and whether each one is on |
| PATCH | /email/event_settings | Turn email events on or off |
| POST | /email/event_settings/reset | Turn 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.
Example request:
curl -X GET "http://localhost:4000/email/event_settings" \
-H "Authorization: Bearer $SPANWAY_API_KEY"
Responses:
| Status | Description | Body |
|---|---|---|
| 200 | Every email event with its current switch. | application/json EmailEventSettingsResponse |
| 403 | The caller is not a proxy admin or admin viewer. | application/json ErrorDetail |
| 500 | The gateway has no database, so no settings are stored. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
settings | array of EmailEventSettings | Yes | Settings |
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.
Request body (application/json, schema EmailEventSettingsUpdateRequest):
| Field | Type | Required | Description |
|---|---|---|---|
settings | array of EmailEventSettings | Yes | Settings |
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:
| Status | Description | Body |
|---|---|---|
| 200 | The switches were saved and an audit row was written. | application/json EmailEventSettingsMessage |
| 400 | email_settings is set in the config file and cannot be changed through the API. | application/json ErrorDetail |
| 403 | The caller is not a proxy admin. | application/json ErrorDetail |
| 422 | Validation Error | application/json HTTPValidationError |
| 500 | The gateway has no database, so there is nowhere to store it. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |
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.
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:
| Status | Description | Body |
|---|---|---|
| 200 | Every event is on again and an audit row was written. | application/json EmailEventSettingsMessage |
| 400 | email_settings is set in the config file and cannot be changed through the API. | application/json ErrorDetail |
| 403 | The caller is not a proxy admin. | application/json ErrorDetail |
| 500 | The gateway has no database, so there is nowhere to store it. | application/json ErrorDetail |
Response fields (200):
| Field | Type | Required | Description |
|---|---|---|---|
message | string | Yes | Message |