Skip to main content

Service API: Am I Attacking

info
  • We're assuming your API key is set in the environment variable $KEY with the necessary permissions.
  • The /v1/am-i-attacking endpoints require a key with the am-i-attacking scope: read access for GET, write access for POST, PATCH and DELETE.
  • The /v1/am-i-attacking-events endpoint requires a key with the separate am-i-attacking-events scope, with read access.
  • The two scopes are independent: the am-i-attacking scope does not open the events, and the reverse. A key needs both to use every endpoint on this page. Otherwise the API returns 403 Forbidden.

Am I Attacking tells you when the CrowdSec network sees one of the IPs you operate attacking someone. An Am I Attacking configuration groups the addresses you want to watch (single IPs or CIDR ranges, IPv4 or IPv6) with a deduplication window (alarm_expiration): after an alert on one of these IPs, further detections on that same IP stay silent until the window is over. Each detection is recorded as an event for your organization, which you can read with Get Am I Attacking events.

Monitored addresses count against your organization's monitored IP quota. An address is counted once across all your configurations, and a range counts for every address it covers (a /24 counts for 256).

Create a configurationโ€‹

Create an Am I Attacking configuration for your organization

ips and alarm_expiration are required, name is optional. Each unit of alarm_expiration (days, hours, minutes) defaults to 0; set them all to 0 to be notified on every detection.

SH
curl -i -H "x-api-key: ${KEY}" -X POST -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/am-i-attacking \
-d '{ "name": "My web servers", "ips": ["1.2.3.4", "5.6.7.0/24"], "alarm_expiration": { "days": 0, "hours": 1, "minutes": 0 } }'
answer on success (201 Created)
JSON
{
"id": "string",
"name": "My web servers",
"ips": [
"1.2.3.4",
"5.6.7.0/24"
],
"alarm_expiration": {
"minutes": 0,
"hours": 1,
"days": 0
}
}

The API returns:

  • 400 Bad Request when an entry of ips is neither a valid IP nor a valid CIDR range.
  • 429 Too Many Requests when the new addresses would exceed your monitored IP quota.
  • 409 Conflict when another change to your configurations is in progress; retry the request.

List configurationsโ€‹

Get all the Am I Attacking configurations of your organization

The answer is a plain array, not paginated.

SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/am-i-attacking
answer on success
JSON
[
{
"id": "string",
"name": "string",
"ips": [
"string"
],
"alarm_expiration": {
"minutes": 0,
"hours": 0,
"days": 0
}
}
]

Get the summaryโ€‹

Get the number of configurations of your organization and the number of addresses they monitor

unique_ips_count is the number of addresses covered by all your configurations together: each address is counted once, and a range counts for every address it covers. This is the figure checked against your monitored IP quota.

SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/am-i-attacking/summary
answer on success
JSON
{
"configurations_count": 5,
"unique_ips_count": 10
}

Get a configurationโ€‹

Retrieve a single configuration, using the id returned by Create a configuration or List configurations

The API returns 404 Not Found when no configuration of your organization has this id.

SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/am-i-attacking/${CONFIG_ID}
answer on success
JSON
{
"id": "string",
"name": "string",
"ips": [
"string"
],
"alarm_expiration": {
"minutes": 0,
"hours": 0,
"days": 0
}
}

Update a configurationโ€‹

Update an Am I Attacking configuration of your organization

ips and alarm_expiration are required and replace the current values: send the complete list of addresses to keep, not only the ones to add. name is optional; when it is omitted, the configuration keeps its current name.

The API returns 404 Not Found for an unknown id, and the same 400, 429 and 409 errors as Create a configuration.

SH
curl -i -H "x-api-key: ${KEY}" -X PATCH -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/am-i-attacking/${CONFIG_ID} \
-d '{ "name": "My web servers", "ips": ["1.2.3.4", "5.6.7.0/24", "8.9.10.11"], "alarm_expiration": { "days": 0, "hours": 6, "minutes": 0 } }'
answer on success
JSON
{
"id": "string",
"name": "My web servers",
"ips": [
"1.2.3.4",
"5.6.7.0/24",
"8.9.10.11"
],
"alarm_expiration": {
"minutes": 0,
"hours": 6,
"days": 0
}
}

Delete a configurationโ€‹

Delete an Am I Attacking configuration of your organization

Monitoring of its addresses stops at once. Events already recorded are kept. The API returns 404 Not Found for an unknown id, and 409 Conflict when another change to your configurations is in progress.

SH
curl -i -H "x-api-key: ${KEY}" -X DELETE -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/am-i-attacking/${CONFIG_ID}
answer on success (200 OK, empty object)
JSON
{}

Get Am I Attacking eventsโ€‹

List the Am I Attacking events detected for your organization, most recent first

This endpoint requires the am-i-attacking-events scope. Every filter is optional and they combine:

Query parameterDescription
sinceOnly events with an event_timestamp greater than or equal to this date (ISO 8601), e.g. 2024-01-01T00:00:00+00:00
source_ipOnly events from this source IP address
config_idOnly events triggered by this configuration
scenarioOnly events of this attack scenario, e.g. crowdsecurity/http-probing
behaviorOnly events with this attack behavior name, e.g. http:scan
targeted_rangeOnly events against this targeted /24 range, e.g. 10.0.0.0/24
min_scenario_confidenceOnly events with a scenario confidence greater than or equal to this value (0 or more)
pagePage number, starting at 1 (default 1)
sizePage size, from 1 to 100 (default 50)

config_id is absent from an event that cannot be traced back to one of your configurations. attack.targeted_range is the attacked IP, truncated to its /24 range.

SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
"https://admin.api.crowdsec.net/v1/am-i-attacking-events?config_id=${CONFIG_ID}&min_scenario_confidence=3&page=1&size=50"
answer on success
JSON
{
"items": [
{
"event_id": "c6d468d4f1084ebca84165c33f97fbc4",
"config_id": "string",
"organization_id": "string",
"event_timestamp": "2019-08-24T14:15:22Z",
"event_type": "am_i_attacking",
"source_ip": "1.2.3.4",
"attack": {
"scenario": "crowdsecurity/http-probing",
"behaviors": [
{
"name": "http:scan",
"description": "string",
"label": "string"
}
],
"start_at": "2019-08-24T14:15:22Z",
"stop_at": "2019-08-24T14:15:22Z",
"targeted_range": "10.0.0.0/24",
"is_manual_decision": false,
"scenario_confidence": 0
}
}
],
"total": 0,
"page": 1,
"size": 1,
"pages": 0,
"links": {
"first": "/api/v1/users?limit=1&offset1",
"last": "/api/v1/users?limit=1&offset1",
"self": "/api/v1/users?limit=1&offset1",
"next": "/api/v1/users?limit=1&offset1",
"prev": "/api/v1/users?limit=1&offset1"
}
}

Events are delivered to people through notification rules carrying the Am I Attacking event; see Get notified.

CrowdSec Docs
We use cookies

This site uses cookies to help us improve your experience. You can accept or decline below.