Engines
info
- We're assuming your API key is set in the environment variable
$KEYwith the necessary permissions. - The
enginesendpoints require a key with engines scope, otherwise the api returns403 Forbidden.
An engine exposes the informations related to Security Engines enrolled to your Organization.
Get Enginesโ
info
- Refer to the Security Engines section for context.
cURL
Python
SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/engines
PY
import os
KEY = os.getenv('KEY')
from crowdsec_service_api import (
Engines,
Server,
ApiKeyAuth,
)
from httpx import HTTPStatusError
auth = ApiKeyAuth(api_key=KEY)
client = Engines(base_url=Server.production_server.value, auth=auth)
try:
response = client.get_engines(
tag=None,
page=1,
size=50,
)
print(response.model_dump_json())
except HTTPStatusError as e:
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
answer on success
JSON
{
"items": [
{
"id": "string",
"organization_id": "string",
"created_at": "2019-08-24T14:15:22Z",
"entity_type": "engine",
"blocklists": [],
"allowlists": [],
"version": "string",
"enrolled_at": "2019-08-24T14:15:22Z",
"os": {
"name": "string",
"version": "string",
"family": "string"
},
"meta": {},
"last_pull": "2019-08-24T14:15:22Z",
"last_push": "2019-08-24T14:15:22Z",
"last_login": "2019-08-24T14:15:22Z",
"tags": [],
"scenarios": [
"string"
]
}
],
"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"
}
}
Get Engineโ
Retrieve a single Security Engine, using the
idreturned by Get Engines
cURL
Python
SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/engines/${ENGINE_ID}
PY
import os
KEY = os.getenv('KEY')
ENGINE_ID = os.getenv('ENGINE_ID')
from crowdsec_service_api import (
Engines,
Server,
ApiKeyAuth,
)
from httpx import HTTPStatusError
auth = ApiKeyAuth(api_key=KEY)
client = Engines(base_url=Server.production_server.value, auth=auth)
try:
response = client.get_engine(engine_id=ENGINE_ID)
print(response.model_dump_json())
except HTTPStatusError as e:
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
answer on success
JSON
{
"id": "string",
"organization_id": "string",
"created_at": "2019-08-24T14:15:22Z",
"entity_type": "engine",
"blocklists": [
{
"id": "string",
"remediation": "string"
}
],
"allowlists": [
{
"id": "string"
}
],
"version": "string",
"enrolled_at": "2019-08-24T14:15:22Z",
"os": {
"name": "string",
"version": "string",
"family": "string"
},
"meta": {},
"last_pull": "2019-08-24T14:15:22Z",
"last_push": "2019-08-24T14:15:22Z",
"last_login": "2019-08-24T14:15:22Z",
"last_ip": "string",
"tags": [
"string"
],
"scenarios": [
"string"
]
}
Associate Tags With Engineโ
Associate one or more tags with a Security Engine
cURL
Python
SH
curl -i -H "x-api-key: ${KEY}" -X POST -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/engines/${ENGINE_ID}/tags \
-d '{ "tags": ["production", "eu-west"] }'
PY
import os
KEY = os.getenv('KEY')
ENGINE_ID = os.getenv('ENGINE_ID')
from crowdsec_service_api import (
Engines,
Server,
ApiKeyAuth,
)
from crowdsec_service_api.models import EngineAssociateTagsRequest
from httpx import HTTPStatusError
auth = ApiKeyAuth(api_key=KEY)
client = Engines(base_url=Server.production_server.value, auth=auth)
request = EngineAssociateTagsRequest(tags=["production", "eu-west"])
try:
response = client.associate_tags_with_engine(engine_id=ENGINE_ID, request=request)
print(response.model_dump_json())
except HTTPStatusError as e:
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
answer on success (201 Created)
JSON
{
"modified_count": 1,
"errors": {}
}
Disassociate Tag From Engineโ
Remove a tag from a Security Engine. The tag itself is not deleted, only its association with the engine.
cURL
Python
SH
curl -i -H "x-api-key: ${KEY}" -X DELETE -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/engines/${ENGINE_ID}/tags/production
PY
import os
KEY = os.getenv('KEY')
ENGINE_ID = os.getenv('ENGINE_ID')
from crowdsec_service_api import (
Engines,
Server,
ApiKeyAuth,
)
from httpx import HTTPStatusError
auth = ApiKeyAuth(api_key=KEY)
client = Engines(base_url=Server.production_server.value, auth=auth)
try:
client.disassociate_tags_with_engine(engine_id=ENGINE_ID, tag_name="production")
except HTTPStatusError as e:
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
info
On success the API returns 204 No Content with an empty body.
Get Engine Log Processorsโ
List the Log Processors attached to a Security Engine
cURL
Python
SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
"https://admin.api.crowdsec.net/v1/engines/${ENGINE_ID}/log_processors?page=1&size=50"
PY
import os
KEY = os.getenv('KEY')
ENGINE_ID = os.getenv('ENGINE_ID')
from crowdsec_service_api import (
Engines,
Server,
ApiKeyAuth,
)
from httpx import HTTPStatusError
auth = ApiKeyAuth(api_key=KEY)
client = Engines(base_url=Server.production_server.value, auth=auth)
try:
response = client.get_engine_log_processors(
engine_id=ENGINE_ID,
page=1,
size=50,
)
print(response.model_dump_json())
except HTTPStatusError as e:
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
answer on success
JSON
{
"items": [
{
"id": "string",
"organization_id": "string",
"created_at": "2019-08-24T14:15:22Z",
"entity_type": "log_processor",
"name": "string",
"version": "string",
"last_push": "2019-08-24T14:15:22Z",
"last_update": "2019-08-24T14:15:22Z",
"last_heartbeat": "2019-08-24T14:15:22Z",
"feature_flags": [
"string"
],
"hub_items": {
"scenarios": [
{
"name": "string",
"version": "string",
"status": "string"
}
],
"parsers": [],
"postoverflows": [],
"appsec-configs": [],
"appsec-rules": [],
"collections": [],
"contexts": []
},
"os": {
"name": "string",
"version": "string",
"family": "string"
},
"datasources": {}
}
],
"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"
}
}
Get Engine Remediation Componentsโ
List the Remediation Components (bouncers) attached to a Security Engine
cURL
Python
SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
"https://admin.api.crowdsec.net/v1/engines/${ENGINE_ID}/remediation_components?page=1&size=50"
PY
import os
KEY = os.getenv('KEY')
ENGINE_ID = os.getenv('ENGINE_ID')
from crowdsec_service_api import (
Engines,
Server,
ApiKeyAuth,
)
from httpx import HTTPStatusError
auth = ApiKeyAuth(api_key=KEY)
client = Engines(base_url=Server.production_server.value, auth=auth)
try:
response = client.get_engine_remediation_components(
engine_id=ENGINE_ID,
page=1,
size=50,
)
print(response.model_dump_json())
except HTTPStatusError as e:
print(f"An error occurred: {e.response.status_code} - {e.response.text}")
answer on success
JSON
{
"items": [
{
"id": "string",
"organization_id": "string",
"created_at": "2019-08-24T14:15:22Z",
"entity_type": "remediation_component",
"name": "string",
"version": "string",
"type": "string",
"last_pull": "2019-08-24T14:15:22Z",
"os": {
"name": "string",
"version": "string",
"family": "string"
}
}
],
"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"
}
}