openapi: 3.0.0 info: title: Swagger CrowdSec description: CrowdSec local API version: 1.0.0 contact: email: contact@crowdsec.net x-api-status-urls: false servers: - url: https://127.0.0.1/v1 - url: http://127.0.0.1/v1 tags: - description: 'Operations about watchers : cscli & crowdsec' name: watchers - description: 'Operations about decisions : bans, captcha, rate-limit etc.' name: Remediation component paths: /decisions/stream: get: tags: - Remediation component summary: getDecisionsStream operationId: Bouncers_getDecisionsStream security: - APIKeyAuthorizer: [] description: >- Returns a list of new/expired decisions. Intended for remediation component that need to "stream" decisions parameters: - description: >- If true, means that the remediation component is starting and a full list must be provided name: startup in: query required: false schema: type: boolean - description: Comma separated scopes of decisions to fetch name: scopes in: query required: false schema: type: string - description: >- Comma separated name of origins. If provided, then only the decisions originating from provided origins would be returned. name: origins in: query required: false schema: type: string - description: >- Comma separated words. If provided, only the decisions created by scenarios containing any of the provided word would be returned. name: scenarios_containing in: query required: false schema: type: string - description: >- Comma separated words. If provided, only the decisions created by scenarios, not containing any of the provided word would be returned. name: scenarios_not_containing in: query required: false schema: type: string responses: '200': description: successful operation headers: {} content: application/json: schema: $ref: '#/components/schemas/DecisionsStreamResponse' '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false head: tags: - Remediation component summary: GetDecisionsStream operationId: Bouncers_getDecisionsStream security: - APIKeyAuthorizer: [] description: >- Returns a list of new/expired decisions. Intended for remediation component that need to "stream" decisions parameters: - description: >- If true, means that the bouncer is starting and a full list must be provided name: startup in: query required: false schema: type: boolean responses: '200': description: successful operation headers: {} '400': description: 400 response deprecated: false /decisions: get: tags: - Remediation component summary: getDecisions operationId: Bouncers_getInformation description: Returns information about existing decisions parameters: - description: >- scope to which the decision applies (ie. IP/Range/Username/Session/...) name: scope in: query required: false schema: type: string - description: the value to match for in the specified scope name: value in: query required: false schema: type: string - description: type of decision name: type in: query required: false schema: type: string - description: IP to search for (shorthand for scope=ip&value=) name: ip in: query required: false schema: type: string - description: range to search for (shorthand for scope=range&value=) name: range in: query required: false schema: type: string - description: >- indicate if you're looking for a decision that contains the value, or that is contained within the value name: contains in: query required: false schema: type: boolean - description: >- Comma separated name of origins. If provided, then only the decisions originating from provided origins would be returned. name: origins in: query required: false schema: type: string - description: >- Comma separated words. If provided, only the decisions created by scenarios containing any of the provided word would be returned. name: scenarios_containing in: query required: false schema: type: string - description: >- Comma separated words. If provided, only the decisions created by scenarios, not containing any of the provided word would be returned. name: scenarios_not_containing in: query required: false schema: type: string responses: '200': description: successful operation content: application/json: schema: $ref: '#/components/schemas/GetDecisionsResponse' '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false head: tags: - Remediation component summary: GetDecisions operationId: Bouncers_getInformation security: - APIKeyAuthorizer: [] description: Returns information about existing decisions parameters: - description: >- scope to which the decision applies (ie. IP/Range/Username/Session/...) name: scope in: query required: false schema: type: string - description: the value to match for in the specified scope name: value in: query required: false schema: type: string - description: type of decision name: type in: query required: false schema: type: string - description: IP to search for (shorthand for scope=ip&value=) name: ip in: query required: false schema: type: string - description: range to search for (shorthand for scope=range&value=) name: range in: query required: false schema: type: string - description: >- indicate if you're looking for a decision that contains the value, or that is contained within the value name: contains in: query required: false schema: type: boolean responses: '200': description: successful operation '400': description: 400 response deprecated: false delete: tags: - watchers summary: deleteDecisions operationId: Watchers_removeDecisions security: - JWTAuthorizer: [] description: Delete decisions(s) for given filters (only from cscli) parameters: - description: >- scope to which the decision applies (ie. IP/Range/Username/Session/...) name: scope in: query required: false schema: type: string - description: the value to match for in the specified scope name: value in: query required: false schema: type: string - description: type of decision name: type in: query required: false schema: type: string - description: IP to search for (shorthand for scope=ip&value=) name: ip in: query required: false schema: type: string - description: range to search for (shorthand for scope=range&value=) name: range in: query required: false schema: type: string - description: scenario to search name: scenario in: query required: false schema: type: string responses: '200': description: successful operation headers: {} content: application/json: schema: $ref: '#/components/schemas/DeleteDecisionResponse' '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false /decisions/{decision_id}: delete: tags: - watchers summary: DeleteDecision operationId: Watchers_removeDecisionById security: - JWTAuthorizer: [] description: Delete decision for given decision ID (only from cscli) parameters: - description: '' name: decision_id in: path required: true schema: type: string responses: '200': description: successful operation headers: {} content: application/json: schema: $ref: '#/components/schemas/DeleteDecisionResponse' '404': description: 404 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false /watchers: post: tags: - watchers summary: RegisterWatcher operationId: Watchers_registerWatcher description: This method is used when installing crowdsec (cscli->APIL) requestBody: description: Information about the watcher to be registered content: application/json: schema: $ref: '#/components/schemas/WatcherRegistrationRequest' required: true responses: '201': description: Watcher Created headers: {} '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false /watchers/login: post: tags: - watchers summary: AuthenticateWatcher operationId: Watchers_authenticateSession description: Authenticate current to get session ID requestBody: description: Information about the watcher to be reset content: application/json: schema: $ref: '#/components/schemas/WatcherAuthRequest' required: true responses: '200': description: Login successful content: application/json: schema: $ref: '#/components/schemas/WatcherAuthResponse' '403': description: 403 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false /alerts: post: tags: - watchers summary: pushAlerts operationId: Watchers_createAlerts security: - JWTAuthorizer: [] description: Push alerts to API requestBody: description: Push alerts to the API content: application/json: schema: $ref: '#/components/schemas/AddAlertsRequest' required: true responses: '201': description: Alert(s) created headers: {} content: application/json: schema: $ref: '#/components/schemas/AddAlertsResponse' '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false get: tags: - watchers summary: searchAlerts operationId: Watchers_listAlerts security: - JWTAuthorizer: [] description: Allows to search for alerts parameters: - description: show alerts for this scope name: scope in: query required: false schema: type: string - description: show alerts for this value (used with scope) name: value in: query required: false schema: type: string - description: show alerts for this scenario name: scenario in: query required: false schema: type: string - description: IP to search for (shorthand for scope=ip&value=) name: ip in: query required: false schema: type: string - description: range to search for (shorthand for scope=range&value=) name: range in: query required: false schema: type: string - description: >- search alerts newer than delay (format must be compatible with time.ParseDuration) name: since in: query required: false schema: type: string format: date-time - description: >- search alerts older than delay (format must be compatible with time.ParseDuration) name: until in: query required: false schema: type: string format: date-time - description: >- if set to true, decisions in simulation mode will be returned as well name: simulated in: query required: false schema: type: boolean - description: only return alerts with decisions not expired yet name: has_active_decision in: query required: false schema: type: boolean - description: restrict results to alerts with decisions matching given type name: decision_type in: query required: false schema: type: string - description: number of alerts to return name: limit in: query required: false schema: type: number - description: restrict results to this origin (ie. lists,CAPI,cscli) name: origin in: query required: false schema: type: string responses: '200': description: successful operation headers: {} content: application/json: schema: $ref: '#/components/schemas/GetAlertsResponse' '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false head: tags: - watchers summary: searchAlerts operationId: Watchers_searchAlerts security: - JWTAuthorizer: [] description: Allows to search for alerts parameters: - description: show alerts for this scope name: scope in: query required: false schema: type: string - description: show alerts for this value (used with scope) name: value in: query required: false schema: type: string - description: show alerts for this scenario name: scenario in: query required: false schema: type: string - description: IP to search for (shorthand for scope=ip&value=) name: ip in: query required: false schema: type: string - description: range to search for (shorthand for scope=range&value=) name: range in: query required: false schema: type: string - description: >- search alerts newer than delay (format must be compatible with time.ParseDuration) name: since in: query required: false schema: type: string format: date-time - description: >- search alerts older than delay (format must be compatible with time.ParseDuration) name: until in: query required: false schema: type: string format: date-time - description: >- if set to true, decisions in simulation mode will be returned as well name: simulated in: query required: false schema: type: boolean - description: only return alerts with decisions not expired yet name: has_active_decision in: query required: false schema: type: boolean - description: restrict results to alerts with decisions matching given type name: decision_type in: query required: false schema: type: string - description: number of alerts to return name: limit in: query required: false schema: type: number - description: restrict results to this origin (ie. lists,CAPI,cscli) name: origin in: query required: false schema: type: string responses: '200': description: successful operation headers: {} '400': description: 400 response deprecated: false delete: tags: - watchers summary: deleteAlerts operationId: Watchers_removeAlerts security: - JWTAuthorizer: [] description: Allows to delete alerts parameters: - description: delete alerts for this scope name: scope in: query required: false schema: type: string - description: delete alerts for this value (used with scope) name: value in: query required: false schema: type: string - description: delete alerts for this scenario name: scenario in: query required: false schema: type: string - description: delete Alerts with IP (shorthand for scope=ip&value=) name: ip in: query required: false schema: type: string - description: delete alerts concerned by range (shorthand for scope=range&value=) name: range in: query required: false schema: type: string - description: delete alerts added after YYYY-mm-DD-HH:MM:SS name: since in: query required: false schema: type: string format: date-time - description: delete alerts added before YYYY-mm-DD-HH:MM:SS name: until in: query required: false schema: type: string format: date-time - description: delete only alerts with decisions not expired yet name: has_active_decision in: query required: false schema: type: boolean - description: delete only alerts with matching source (ie. cscli/crowdsec) name: alert_source in: query required: false schema: type: string responses: '200': description: successful operation headers: {} content: application/json: schema: $ref: '#/components/schemas/DeleteAlertsResponse' '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false /alerts/{alert_id}: get: tags: - watchers summary: GetAlertByID operationId: Watchers_getAlertById security: - JWTAuthorizer: [] description: Get alert by ID parameters: - description: '' name: alert_id in: path required: true schema: type: string responses: '200': description: successful operation headers: {} content: application/json: schema: $ref: '#/components/schemas/Alert' '400': description: 400 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false head: tags: - watchers summary: GetAlertByID operationId: Watchers_getAlertById security: - JWTAuthorizer: [] description: Get alert by ID parameters: - description: '' name: alert_id in: path required: true schema: type: string responses: '200': description: successful operation headers: {} '400': description: 400 response deprecated: false delete: tags: - watchers summary: DeleteAlert operationId: Watchers_deleteAlertById security: - JWTAuthorizer: [] description: Delete alert for given alert ID (only from cscli) parameters: - description: '' name: alert_id in: path required: true schema: type: string responses: '200': description: successful operation headers: {} content: application/json: schema: $ref: '#/components/schemas/DeleteAlertsResponse' '404': description: 404 response content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' deprecated: false components: securitySchemes: JWTAuthorizer: type: apiKey name: 'Authorization: Bearer' in: header APIKeyAuthorizer: type: apiKey name: X-Api-Key in: header schemas: WatcherRegistrationRequest: title: WatcherRegistrationRequest type: object properties: machine_id: type: string password: type: string format: password required: - machine_id - password WatcherAuthRequest: title: WatcherAuthRequest type: object properties: machine_id: type: string password: type: string format: password scenarios: description: the list of scenarios enabled on the watcher type: array items: type: string required: - machine_id - password WatcherAuthResponse: title: WatcherAuthResponse description: the response of a successful authentication type: object properties: code: type: integer expire: type: string token: type: string Alert: title: Alert type: object properties: id: description: only relevant for GET, ignored in POST requests type: integer readOnly: true uuid: description: >- only relevant for LAPI->CAPI, ignored for cscli->LAPI and crowdsec->LAPI type: string readOnly: true machine_id: description: >- only relevant for LAPI->CAPI, ignored for cscli->LAPI and crowdsec->LAPI type: string readOnly: true created_at: description: only relevant for GET, ignored in POST requests type: string readOnly: true scenario: type: string scenario_hash: type: string scenario_version: type: string message: description: a human readable message type: string events_count: type: integer format: int32 start_at: type: string stop_at: type: string capacity: type: integer format: int32 leakspeed: type: string simulated: type: boolean events: description: the Meta of the events leading to overflow type: array items: $ref: '#/components/schemas/Event' remediation: type: boolean decisions: type: array items: $ref: '#/components/schemas/Decision' source: $ref: '#/components/schemas/Source' meta: $ref: '#/components/schemas/Meta' labels: type: array items: type: string required: - scenario - scenario_hash - scenario_version - message - events_count - start_at - stop_at - capacity - leakspeed - simulated - events - source Source: title: Source type: object properties: scope: description: 'the scope of a source : ip,range,username,etc' type: string value: description: 'the value of a source : the ip, the range, the username,etc' type: string ip: description: provided as a convenience when the source is an IP type: string range: description: provided as a convenience when the source is an IP type: string as_number: description: provided as a convenience when the source is an IP type: string as_name: description: provided as a convenience when the source is an IP type: string cn: type: string latitude: type: number format: float longitude: type: number format: float required: - scope - value Metrics: title: Metrics type: object properties: apil_version: description: the local version of crowdsec/apil type: string bouncers: type: array items: $ref: '#/components/schemas/MetricsBouncerInfo' machines: type: array items: $ref: '#/components/schemas/MetricsAgentInfo' required: - apil_version - bouncers - machines MetricsBouncerInfo: title: MetricsBouncerInfo description: >- Software version info (so we can warn users about out-of-date software). The software name and the version are "guessed" from the user-agent type: object properties: version: description: software version type: string custom_name: description: name of the component type: string name: description: bouncer type (firewall, php ...) type: string last_pull: description: last bouncer pull date type: string MetricsAgentInfo: title: MetricsAgentInfo description: >- Software version info (so we can warn users about out-of-date software). The software name and the version are "guessed" from the user-agent type: object properties: version: description: software version type: string name: description: name of the component type: string last_update: description: last agent update date type: string last_push: description: last agent push date type: string Decision: title: Decision type: object properties: id: description: (only relevant for GET ops) the unique id type: integer readOnly: true uuid: description: >- only relevant for LAPI->CAPI, ignored for cscli->LAPI and crowdsec->LAPI type: string readOnly: true origin: description: 'the origin of the decision : cscli, crowdsec' type: string type: description: >- the type of decision, might be 'ban', 'captcha' or something custom. Ignored when watcher (cscli/crowdsec) is pushing to APIL. type: string scope: description: >- the scope of decision : does it apply to an IP, a range, a username, etc type: string value: description: 'the value of the decision scope : an IP, a range, a username, etc' type: string duration: description: the duration of the decisions type: string until: description: the date until the decisions must be active type: string scenario: type: string simulated: description: true if the decision result from a scenario in simulation mode type: boolean readOnly: true required: - origin - type - scope - value - duration - scenario DeleteDecisionResponse: title: DeleteDecisionResponse type: object properties: nbDeleted: description: number of deleted decisions type: string AddAlertsRequest: title: AddAlertsRequest type: array items: $ref: '#/components/schemas/Alert' AddAlertsResponse: title: AddAlertsResponse type: array items: description: alert_id type: string GetAlertsResponse: title: AlertsResponse type: array items: $ref: '#/components/schemas/Alert' DeleteAlertsResponse: title: DeleteAlertsResponse type: object properties: nbDeleted: description: number of deleted alerts type: string DecisionsStreamResponse: title: DecisionsStreamResponse type: object properties: new: $ref: '#/components/schemas/GetDecisionsResponse' deleted: $ref: '#/components/schemas/GetDecisionsResponse' Event: title: Event type: object properties: timestamp: type: string meta: $ref: '#/components/schemas/Meta' required: - timestamp - meta GetDecisionsResponse: title: GetDecisionsResponse type: array items: $ref: '#/components/schemas/Decision' Meta: title: Meta description: the Meta data of the Alert itself type: array items: type: object properties: key: type: string value: type: string ErrorResponse: title: error response description: error response return by the API type: object required: - message properties: message: description: Error message type: string errors: description: more detail on individual errors type: string externalDocs: description: Find out more about CrowdSec url: https://github.com/crowdsecurity/crowdsec