You can use the Notifications API to tell the archive who to notify, for example when an ingest fails or a SIP has a virus. A notification configuration links one event to one channel. The channel is an email, a webhook call, or an event log that you can report on.
Every call needs the headers in Common headers.
Events you can be notified about
Set eventType to one of these values. Each event has a fixed severity, which you can filter on with event_severity.
|
|
When it happens |
Severity |
|---|---|---|
|
|
A SIP was ingested into its package. |
Low |
|
|
A SIP couldn't be ingested. |
Severe |
|
|
The archive couldn't accept or validate a SIP. |
Severe |
|
|
The archive couldn't create or find the package for a SIP. |
Severe |
|
|
The virus scan found a virus in a SIP. |
Severe |
|
|
A preservation action failed on a package or a SIP. |
Moderate |
|
|
A preservation action finished with a warning on a package or a SIP. |
Low |
|
|
A package or a SIP was permanently deleted. |
None. For |
|
|
The archive generated a report. See Reports API. |
Low |
Channels
Set actionType to the channel, and put its settings in configuration:
-
EMAIL: sends an HTML email to the address indestination_mail. -
WEBHOOK: sends aPOSTrequest to the URL indestination_url, withContent-Type: application/json. You can add your own headers inheaders. If the call fails, the archive tries again up to three times, after 1, 2, and 4 seconds. -
COLLECTION: logs each event in the event log that you name indestination_collection. To turn these events into a report, create areport_collection_queryreport in the Reports API.
Write the message template
notification_template is a FreeMarker template. The archive fills it in for each event, and sends the result as the email body or the webhook body. For a webhook, make sure that the result is the JSON that your endpoint expects.
You can use these variables:
|
Variable |
Description |
|---|---|
|
|
The event type, for example |
|
|
What happened, in a short English sentence. |
|
|
|
|
|
The ID of the package or the SIP. |
|
|
|
|
|
When the event happened. |
|
|
For |
For documentRemoved, message and severity have no value. A template that uses them sends nothing, so use only name, packageId, packageType, and time.
For example, a webhook template that sends JSON:
{
"event": "${name}",
"severity": "${severity}",
"package": "${packageId}",
"message": "${message}"
}
When you save the configuration, the archive tries the template with sample values for every severity and package type. If the template uses a variable that isn't in the list, or can't be processed, the save fails.
List notification configurations
GET /v2/notifications/configs
Required role: archive-content-manager
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
integer |
No |
The page number, starting at 0. Default: |
|
|
integer |
No |
The number of configurations per page. Default: |
Response: 200 OK with a NotificationConfigList, sorted by name.
Get a notification configuration
GET /v2/notifications/configs/{configId}
Required role: archive-content-manager
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
string |
Yes |
The ID of the notification configuration. |
Response: 200 OK with a NotificationConfig.
-
404: there's no notification configuration with this ID.
Create a notification configuration
Sets up a notification. It applies to the events that happen after you save it.
POST /v2/notifications/configs
Required role: archive-content-manager
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
string |
Yes |
The name of the configuration. |
|
|
string |
Yes |
The event that triggers the notification. See Events you can be notified about. |
|
|
string |
Yes |
|
|
|
object |
Yes |
The settings of the notification. See the next table. |
|
|
boolean |
No |
If |
The configuration object takes these keys:
|
Name |
Type |
Required |
Description |
|---|---|---|---|
|
|
string |
Yes |
The FreeMarker template of the message. Only |
|
|
string |
For |
The email address to send to. |
|
|
string |
For |
The URL to call, with |
|
|
array of objects |
No |
For |
|
|
string |
For |
The name of the event log to write the events to. |
|
|
string |
No |
The lowest severity that triggers the notification: |
{
"name": "Ingest failures to the DMS",
"eventType": "ingest_failed",
"actionType": "WEBHOOK",
"enabled": true,
"configuration": {
"destination_url": "https://dms.example.com/hooks/archive",
"headers": [
{ "headerKey": "X-Api-Key", "headerValue": "example-key" }
],
"notification_template": "{\"event\": \"${name}\", \"package\": \"${packageId}\", \"message\": \"${message}\"}"
}
}
Response: 200 OK with the NotificationConfig.
-
400withREQUIRED_FIELD:notification_template, or the destination that the channel needs, is missing. -
400withINVALID_VALUE: the configuration has a setting of another channel, thedestination_urlisn't allowed, or the template uses a variable that isn't available. -
400withINVALID_FORMAT: the template isn't valid FreeMarker. -
400withUNSUPPORTED_VALUE:event_severityisn'tlow,moderate, orsevere.
Update a notification configuration
Replaces the configuration with the body that you send. The body has the same fields as Create a notification configuration, so send all of them.
PUT /v2/notifications/configs/{configId}
Required role: archive-content-manager
Response: 200 OK with the updated NotificationConfig.
-
404: there's no notification configuration with this ID. -
The
400errors of Create a notification configuration.
Delete a notification configuration
DELETE /v2/notifications/configs/{configId}
Required role: archive-content-manager
Response: 204 No Content. The archive stops sending this notification.
-
404: there's no notification configuration with this ID.
Schemas
NotificationConfig
|
Field |
Type |
Description |
|---|---|---|
|
|
string |
The ID of the configuration. |
|
|
string |
The name of the configuration. |
|
|
string |
The event that triggers the notification. |
|
|
string |
|
|
|
object |
The settings, with the keys that you sent. It also holds |
|
|
boolean |
Whether the archive sends the notification. |
|
|
string (date-time) |
When the configuration was created. |
NotificationConfigList
|
Field |
Type |
Description |
|---|---|---|
|
|
number |
The number of configurations. |
|
|
number |
The page number. |
|
|
number |
The page size. |
|
|
array of NotificationConfig |
The configurations in the page of results. |