Contents

Introduction

Prerequisites

Requirements

Components Used

Background Information

Configure

Safelist GET and POST

GET

POST

Blocklist GET and POST

GET

POST

Related information

Introduction

This document describes configurations to add senders in Safelist / Blocklist (SL/BL) for Secure Management Appliance (SMA) with API and curl command.

Prerequisites

Requirements

Cisco recommends knowledge of these topics:

- Secure Management Appliance (SMA)

- API Knowledge

- Spam Quarantine Knowledge

- Safelist / Blocklist knowledge

Components Used

The information in this document is based on these software and hardware versions:

- Security Management Appliance,  AsyncOS version 12.0 or newer.

- A client or programming library cURL. This must support JSON to interpret the response from the API.

- Authorization to access the AsyncOS API.

- Centralized Spam Quarantine.

- Safelist and Blocklist enabled.

The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, ensure that you understand the potential impact of any command.

Background Information

API service main purpose is to get reports and configuration information from the SMA.

You can get Safe List and Block List information from the Spam Quarantine as well as add new users with API cURL queries.

Configure

Safelist GET and POST

GET

This query gets the information from the Safelist where sma1.example.com is the SMA hostname and adminis the username.

curl --location --request GET 'https://sma1.example.com/sma/api/v2.0/quarantine/safelist?action=view&quarantineType=spam&viewBy=recipient' -u admin

Enter the password for the user in question.

As output you get:

{"meta": {"totalCount": 2}, "data": [{"senderList": ["example.com"], "recipientAddress": "user2@example.com"}, {"senderList": ["test.com"], "recipientAddress": "user2@test.com"}]}

The GUI Safelist is shown in the image:

GUI Safelist output

POST

This query adds sender information to the Safelist where sma1.example.com is the SMA hostname and adminis the username, user1@example.comis the new recipient, and  example.com is the sender to Safelist.

curl --location --request POST 'https://sma1.example.com/sma/api/v2.0/quarantine/safelist' -u admin --data-raw '{

"action": "add",

"quarantineType": "spam",

"recipientAddresses": ["user1@example.com"],

"senderList": ["example.com"],

"viewBy": "recipient"

}'

Run this command and enter the password for the user in question.

The GUI Safelist is shown in the image:

GUI Safelist output

Blocklist GET and POST

GET

This query gets the information from the Safelist, where sma1.example.com is the SMA hostname and adminis the username

curl --location --request GET 'https://sma1.example.com/sma/api/v2.0/quarantine/blocklist?action=view&quarantineType=spam&viewBy=recipient' -u admin

As output you get:

{"meta": {"totalCount": 2}, "data": [{"senderList": ["example1.com"], "recipientAddress": "user2@example.com"}, {"senderList": ["test1.com"], "recipientAddress": "user2@test.com"}]

The GUI Safelist is shown in the image:

GUI Blocklist output

POST

This query adds sender information to the Safelist where sma1.example.com is the SMA hostname and adminis the username, user1@example.comis the new recipient and  example1.com is the sender to blocklist.

curl --location --request POST 'https://sma1.example.com/sma/api/v2.0/quarantine/blocklist' -u admin --data-raw '{

"action": "add",

"quarantineType": "spam",

"recipientAddresses": ["user1@example.com"],

"senderList": ["example1.com"],

"viewBy": "recipient"

}'

Run this command and enter the password for the user in question.

The GUI Safelist is shown in the image:

GUI Blocklist Output

Related information

- Programming Guides SMA

- End User Guide SMA