> For the complete documentation index, see [llms.txt](https://docs.adsecure.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adsecure.com/docs/threat-intelligence/violation-weight-map.md).

# Violation Weight Map

## What is the Violation Weight Map?

The `risk` computation of a URL is based on the `weight` of each violation. The `weight` is a decimal number between `0` and `1`. A `weight` of `0` completely discards the violation from the `risk` calculation, and a weight of `1` gives the violation the most importance.

While AdSecure provides a [default violation weight map](#default-violation-weight-map), this endpoint allows you to set your own weights and thus customize the calculus of the `risk` to your own needs.

## Setting a custom Violation Weight Map

You need to be [authenticated](/docs/threat-intelligence/authentication.md) to use this method.

**Method:** `POST`

**Path:** `/violation-weight-map`

**Body:**

```json
[
  { "login": "adware", "weight": 0 },
  { "login": "ssl-non-compliant", "weight": 0.9 }
]
```

**cURL:**

```bash
curl --request POST \
  -H "Content-Type: application/json" \
  -H 'Authorization: YOUR_API_KEY' \
  -d '[{"login":"adware","weight":0}]' \
  -v https://api.adsecure.com/threat-intelligence/v1/violation-weight-map
```

This method is an operation that updates your currently defined Violation Weight Map. Any value already present will be overwritten, and values that are absent will be inserted.

> At any point, you may completely clear your user-defined Violation Weight Map by sending an empty array (`[]`) as the body instead. AdSecure will then rely on the [default Violation Weight Map](#default-violation-weight-map) to compute the risk.

This method returns the [standard response shape](#response-shape).

## Fetching your Violation Weight Map

You need to be [authenticated](/docs/threat-intelligence/authentication.md) to use this method.

**Method:** `GET`

**Path:** `/violation-weight-map`

**cURL:**

```bash
curl --request GET \
  -H 'Authorization: YOUR_API_KEY' \
  -v https://api.adsecure.com/threat-intelligence/v1/violation-weight-map
```

This method returns the [standard response shape](#response-shape).

## Response shape

```json
{
  "violationWeightMap": [
    {
      "login": "adware",
      "lastUpdatedAt": "2019-10-04T13:59:10Z",
      "weight": 0
    },
    {
      "login": "auto-click",
      "lastUpdatedAt": "",
      "weight": 0.2
    }
  ]
}
```

Both methods return the same response shape. It is an alphabetically sorted list of the user-defined weights for each violations, which was merged with the default violation weights.

In this example, the weight for `adware` was user defined as the time at which it was last updated is included. However, the weight for the `auto-click` violation was provided by default.

> Please note that the `violationWeightMap` array in the example response shape has been truncated for readability. The actual array will contain an entry for each violation defined in the [default violation weight map](#default-violation-weight-map).

## Default Violation Weight Map

AdSecure defines its default violation weight map as follow:

```json
{
  "adware": 1,
  "auto-download": 1,
  "auto-sound": 0.8,
  "auto-redirect": 0.8,
  "auto-redirect-app-market": 0.8,
  "auto-vibrate": 0.8,
  "back-button-hijack": 0.8,
  "blacklist": 0.8,
  "browser-locker": 1,
  "cryptocurrency-miner": 1,
  "javascript-dialog-on-entry": 0.2,
  "javascript-dialog-on-exit": 0.2,
  "landing-page-error": 0.5,
  "malicious-url": 1,
  "malware": 1,
  "potentially-unwanted-programs": 1,
  "phishing-url": 1,
  "ransomware": 1,
  "scareware": 1,
  "ssl-non-compliant": 0.8,
  "uncommon-protocols": 0.8
}
```

## Response status codes

| Status code | Meaning                                                                     |
| ----------- | --------------------------------------------------------------------------- |
| 200         | Successful request, response payload with mentioned shape will be attached. |

## Troubleshooting

| Status code | Error message | Solution                                                                    |
| ----------- | ------------- | --------------------------------------------------------------------------- |
| 400         | Bad Request   | The body of the request is not a valid JSON format.                         |
| 401         | Unauthorized  | Either the `Authorization` header is not sent or it has an incorrect value. |
| 403         | Forbidden     | API key doesn't have the correct permissions for the endpoint.              |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.adsecure.com/docs/threat-intelligence/violation-weight-map.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
