Skip to main content

Service API: tags

info
  • We're assuming your API key is set in the environment variable $KEY with the necessary permissions.
  • The tags endpoints require a key with tags scope; GET needs read access, POST/PATCH/DELETE need write access, otherwise the API returns 403 Forbidden.

A tag is a label owned by your Organization that groups Security Engines and integrations, the same tags you see in the Console. Once linked, a tag can be used to filter engines, or as a target when you subscribe a blocklist or create a decision.

Tag names are stored in lowercase and are unique within your Organization. In the paths below, ${TAG_ID} is the tag name (for example production).

Create Tagโ€‹

Create a tag for your Organization

SH
curl -i -H "x-api-key: ${KEY}" -X POST -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/tags \
-d '{ "name": "production", "description": "Production servers" }'

If a tag with the same name already exists, the API returns 409 Conflict.

answer on success (201 Created)
JSON
{
"id": "string",
"name": "string",
"description": "string",
"created_at": "2019-08-24T14:15:22Z",
"organization_id": "string"
}

Get Tagsโ€‹

List the tags of your Organization

Optional query parameters:

  • name_starts_with: only return tags whose name starts with this value (e.g. prod)
  • page: page number, default 1
  • size: page size, default 50
SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
"https://admin.api.crowdsec.net/v1/tags?page=1&size=50"
answer on success
JSON
{
"items": [
{
"id": "string",
"name": "string",
"description": "string",
"created_at": "2019-08-24T14:15:22Z",
"organization_id": "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 Tagโ€‹

Retrieve a single tag by its name

SH
curl -i -H "x-api-key: ${KEY}" -X GET -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/tags/${TAG_ID}

If the tag does not exist, the API returns 404 Not Found.

answer on success
JSON
{
"id": "string",
"name": "string",
"description": "string",
"created_at": "2019-08-24T14:15:22Z",
"organization_id": "string"
}

Update Tagโ€‹

Update the description of a tag. The name of a tag cannot be changed.

SH
curl -i -H "x-api-key: ${KEY}" -X PATCH -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/tags/${TAG_ID} \
-d '{ "description": "Production servers, EU region" }'
answer on success
JSON
{
"id": "string",
"name": "string",
"description": "string",
"created_at": "2019-08-24T14:15:22Z",
"organization_id": "string"
}

Link one or more Security Engines or integrations to a tag

entities takes the ids returned by Get Engines or by the integrations endpoints. The tag must already exist.

SH
curl -i -H "x-api-key: ${KEY}" -X POST -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/tags/${TAG_ID}/entities \
-d '{ "entities": ["'"${ENGINE_ID}"'", "'"${INTEGRATION_ID}"'"] }'

Each id is checked on its own: modified_count counts the entities that were linked, and errors lists the ids that could not be linked (unknown id, or an entity that is neither an engine nor an integration).

answer on success (201 Created)
JSON
{
"modified_count": 1,
"errors": {
"string": "Entity not found or not of supported type"
}
}

Remove a tag from a Security Engine or an integration. The tag itself is not deleted.

SH
curl -i -H "x-api-key: ${KEY}" -X DELETE -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/tags/${TAG_ID}/entities/${ENGINE_ID}
info

On success the API returns 204 No Content with an empty body.

Delete Tagโ€‹

Delete a tag of your Organization. The tag is first removed from every engine and integration it is linked to.

SH
curl -i -H "x-api-key: ${KEY}" -X DELETE -H "Content-Type: application/json" \
https://admin.api.crowdsec.net/v1/tags/${TAG_ID}
info

On success the API returns 204 No Content with an empty body.

CrowdSec Docs
We use cookies

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