Trapd REST API (v2)
You can view and update trapd configuration over REST. These endpoints are useful for automation and external configuration tooling.
The Trapd REST API base path is /api/v2/trapd.
Endpoint overview
| Method | Path | Content type | Description |
|---|---|---|---|
|
|
|
Get the current trapd configuration. |
|
|
|
Replace trapd configuration using JSON payload. |
|
|
|
Upload |
Get configuration
curl -u admin:admin "http://localhost:8980/opennms/api/v2/trapd/config"
{
"snmpTrapAddress": "*",
"snmpTrapPort": 1162,
"newSuspectOnTrap": false,
"includeRawMessage": false,
"threads": 0,
"queueSize": 10000,
"batchSize": 1000,
"batchInterval": 500,
"useAddressFromVarbind": true,
"snmpv3User": [
{
"engineId": "0x8000000001020304",
"securityName": "opennms",
"securityLevel": 3,
"authProtocol": "SHA",
"authPassphrase": "my-auth-secret",
"privacyProtocol": "AES",
"privacyPassphrase": "my-privacy-secret"
}
]
}
The current implementation returns SNMPv3 passphrases as stored values when they are present.
They are not masked in GET /api/v2/trapd/config responses.
|
Update configuration with JSON
curl -u admin:admin \
-H "Content-Type: application/json" \
-X PUT "http://localhost:8980/opennms/api/v2/trapd/config" \
-d '{
"snmpTrapAddress": "*",
"snmpTrapPort": 1162,
"newSuspectOnTrap": false,
"includeRawMessage": true,
"threads": 4,
"queueSize": 10000,
"batchSize": 1000,
"batchInterval": 500,
"useAddressFromVarbind": true,
"snmpv3User": [
{
"securityName": "opennms",
"securityLevel": 3,
"authProtocol": "SHA",
"authPassphrase": "my-auth-secret",
"privacyProtocol": "AES",
"privacyPassphrase": "my-privacy-secret"
}
]
}'
Upload trapd XML
The multipart form field name must be upload.
trapd-configuration.xml for upload<trapd-configuration xmlns="http://xmlns.opennms.org/xsd/config/trapd"
snmp-trap-address="*"
snmp-trap-port="1162"
new-suspect-on-trap="false"
include-raw-message="true"
queue-size="10000"
batch-size="1000"
batch-interval="500"
use-address-from-varbind="true">
<snmpv3-user security-name="opennms"
security-level="3"
auth-protocol="SHA"
auth-passphrase="${scv:trapd-v3-user:authPassphrase}"
privacy-protocol="AES"
privacy-passphrase="${scv:trapd-v3-user:privacyPassphrase}"/>
</trapd-configuration>
You can use SCV metadata expressions for passphrases in uploaded XML (${scv:<alias>:<attribute>}).
curl -u admin:admin \
-X POST "http://localhost:8980/opennms/api/v2/trapd/upload" \
-F "upload=@/opt/opennms/etc/trapd-configuration.xml;type=application/xml"
Validation rules
The API validates both top-level trapd fields and SNMPv3 user definitions.
-
snmpTrapAddressis required forPUT /api/v2/trapd/config. -
snmpTrapPortis required and must be between1and65535. -
newSuspectOnTrapis required. -
threads,queueSize,batchSize, andbatchIntervalmust be>= 0when provided.
-
queueSizemust be>= 1. -
batchSizemust be>= 1. -
In XML uploads,
snmp-trap-addressis optional and defaults to*when omitted.
-
securityNameis required. -
securityLevelis required and must be1,2, or3. -
Supported
authProtocol:MD5,SHA,SHA-224,SHA-256,SHA-512. -
Supported
privacyProtocol:DES,AES,AES192,AES256. -
authProtocolandauthPassphrasemust be provided together. -
privacyProtocolandprivacyPassphrasemust be provided together. -
securityLevel=1: no auth or privacy credentials allowed. -
securityLevel=2: auth credentials required, privacy credentials not allowed. -
securityLevel=3: both auth and privacy credentials are required.
Response codes
| Endpoint | Success | Error responses |
|---|---|---|
|
|
|
|
|
|
|
|
|
For XML-based upload, schema validation errors are returned as the response body text.