# Get Rating-based Alerts
source: https://developer.mastercard.com/riskrecon-api/documentation/testing/alerting-samples/rcv-rtng-alrts-smpl/index.md

Allows you to fetch rating or score changes from new scans of your portfolio as per your rating-based alert policies.

## Pre-requisites {#pre-requisites}

Refer to the [Retrieve Rating-based alerts](https://developer.mastercard.com/riskrecon-api/documentation/use-cases/risk-mgmt-issue-rmdfn/alerting/rate-based-alerting/index.md) use case.

## Request URL for Sandbox environment {#request-url-for-sandbox-environment}

```bash
GET https://api.sandbox.riskrecon.com/v1/alerting/rating_changes
```

## Request URL for Production environment {#request-url-for-production-environment}

```bash
GET https://api.riskrecon.com/v1/alerting/rating_changes
```

## Test Cases {#test-cases}

### Test Case: Success - Retrieve rating-based alerts {#test-case-success---retrieve-rating-based-alerts}

**Request**

Here is an example of a request made using a `curl` command.

```bash
curl -X 'GET' \
  'https://api.sandbox.riskrecon.com/v1/alerting/rating_changes?page=1&per_page=20&sort_method=DESC&start_date=2023-07-08&end_date=2023-08-06&alert_types%5B%5D=rating_improved&sort_attribute=company' \
  -H 'accept: application/json'
  -H 'Authorization: valid_JWT_token'
```

**Response**

get:

```json
{
  "meta": {
    "current_page": 1,
    "next_page": null,
    "prev_page": null,
    "total_count": 1,
    "total_new": 0,
    "total_pages": 1
  },
  "rating_change_alerts": []
}
```

### Test Case: Fail - Incorrect Sort Attribute {#test-case-fail---incorrect-sort-attribute}

**Request**

Here is an example of a request made with an incorrect sort attribute using a `curl` command.

```bash
curl -X 'GET' \
  'https://api.sandbox.riskrecon.com/v1/alerting/rating_changes?page=1&per_page=20&sort_method=DESC&start_date=2023-07-08&end_date=2023-08-06&priorities[]=5&priorities[]=2&sort_attribute=dat
  -H 'accept: application/json'
  -H 'Authorization: valid_JWT_token' 
```

**Response**

HTTP Error response 400

```json
{
    "Errors": {
        "Error": [
            {
                "Description": "Bad Request",
                "Details": "sort_attribute: is invalid",
                "ReasonCode": "BAD_REQUEST",
                "Recoverable": false,
                "Source": "RISKRECON_API"
            }
        ]
    }
}
```

### Test Case: Fail - Incorrect per page value {#test-case-fail---incorrect-per-page-value}

**Request**

Here is an example of a request made using a `curl` command where the per page value exceeds the maximum value allowed.

```bash
curl -X 'GET' \
  'https://api.sandbox.riskrecon.com/v1/alerting/rating_changes?per_page=31
  -H 'accept: application/json'
  -H 'Authorization: valid_JWT_token' 
```

**Response**

HTTP Error response 400

```json
{
    "Errors": {
        "Error": [
            {
                "Description": "Bad Request",
                "Details": "per_page: must be less than or equal to 20",
                "ReasonCode": "BAD_REQUEST",
                "Recoverable": false,
                "Source": "RISKRECON_API"
            }
        ]
    }
}
```

