> ## Documentation Index
> Fetch the complete documentation index at: https://docs.revreply.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Rate an Email Response

> Saves feedback about a generated email response.

<Badge color="blue">POST</Badge> `https://api.revreply.com/v1/response/rate`

<Note>
  This endpoint requires authentication.
</Note>

## Try it

Use the following request to rate a generated email response:

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.revreply.com/v1/response/rate" \
      -H "Authorization: Bearer <YOUR_JWT>" \
      -H "Accept: application/json" \
      -H "Content-Type: application/json" \
      -d '{"response":"Thanks for getting back to me. Would Tuesday at 10 AM work?","liked":true}'
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch(
      "https://api.revreply.com/v1/response/rate",
      {
        method: "POST",
        headers: {
          "Authorization": "Bearer <YOUR_JWT>",
          "Accept": "application/json",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          response: "Thanks for getting back to me. Would Tuesday at 10 AM work?",
          liked: true
        })
      }
    );
    const data = await response.json();
    console.log(data);
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    response = requests.post(
        "https://api.revreply.com/v1/response/rate",
        headers={
            "Authorization": "Bearer <YOUR_JWT>",
            "Accept": "application/json",
            "Content-Type": "application/json",
        },
        json={
            "response": "Thanks for getting back to me. Would Tuesday at 10 AM work?",
            "liked": True,
        },
    )
    data = response.json()
    print(data)
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    <?php
    $ch = curl_init("https://api.revreply.com/v1/response/rate");

    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer <YOUR_JWT>",
            "Accept: application/json",
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "response" => "Thanks for getting back to me. Would Tuesday at 10 AM work?",
            "liked" => true,
        ]),
        CURLOPT_RETURNTRANSFER => true,
    ]);

    $response = curl_exec($ch);
    curl_close($ch);
    echo $response;
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    package main

    import (
        "bytes"
        "fmt"
        "net/http"
    )

    func main() {
        body := []byte(`{"response":"Thanks for getting back to me. Would Tuesday at 10 AM work?","liked":true}`)

        req, _ := http.NewRequest(
            "POST",
            "https://api.revreply.com/v1/response/rate",
            bytes.NewBuffer(body),
        )

        req.Header.Set("Authorization", "Bearer <YOUR_JWT>")
        req.Header.Set("Accept", "application/json")
        req.Header.Set("Content-Type", "application/json")

        client := &http.Client{}
        response, _ := client.Do(req)
        fmt.Println(response.Status)
    }
    ```
  </Tab>
</Tabs>

## Authentication

This endpoint uses Bearer authentication with a JWT.

## Request

### Headers

| Header          | Type     | Required | Description                                                    |
| --------------- | -------- | -------- | -------------------------------------------------------------- |
| `Authorization` | `string` | Yes      | Bearer token used to authenticate the request.                 |
| `Accept`        | `string` | Yes      | Specifies that the client expects the response in JSON format. |
| `Content-Type`  | `string` | Yes      | Specifies that the request body is formatted as JSON.          |

```http theme={null}
Authorization: Bearer <YOUR_JWT>
Accept: application/json
Content-Type: application/json
```

### Body

The request body uses the `RateResponseRequest` schema.

| Field      | Type      | Required | Description                     | Example                                                       |
| ---------- | --------- | -------- | ------------------------------- | ------------------------------------------------------------- |
| `response` | `string`  | Yes      | The email response to rate.     | `Thanks for getting back to me. Would Tuesday at 10 AM work?` |
| `liked`    | `boolean` | Yes      | Whether the response was liked. | `true`                                                        |

### Request structure

```json theme={null}
{
  "response": "Thanks for getting back to me. Would Tuesday at 10 AM work?",
  "liked": true
}
```

### Request examples

The request is a `POST` request to:

```text theme={null}
https://api.revreply.com/v1/response/rate
```

## Response

### Response structure

A successful request returns a success message indicating that the impression was saved.

| Field     | Type      | Required | Description                                     |
| --------- | --------- | -------- | ----------------------------------------------- |
| `success` | `integer` | Yes      | Indicates whether the operation was successful. |
| `message` | `string`  | Yes      | Message describing the result of the operation. |

### Response example

```json theme={null}
{
  "success": 1,
  "message": "Impression saved"
}
```

## Errors

### 422 — Validation error

Returned when one or more required request fields fail validation.

```json theme={null}
{
  "success": 0,
  "message": "Validation failed",
  "errors": {}
}
```

### 500 — Failed to save impression

Returned when the response rating cannot be saved because of a server or processing failure.

```json theme={null}
{
  "success": 0,
  "message": "Something went wrong"
}
```
