> ## 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.

# Initialize Orchestrator First Reply

> Adds CC email information to a thread and activates the thread for scheduling.

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

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

## Try it

Use the following request to initialize the orchestrator first reply:

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.revreply.com/v1/orchestrator/firstreply" \
      -H "Authorization: Bearer <YOUR_JWT>" \
      -H "Accept: application/json" \
      -H "Content-Type: application/json" \
      -d '{
        "lead_id": 12345,
        "cc_emails": [
          {
            "sender": {
              "first_name": "John",
              "last_name": "Smith"
            },
            "email": "john.smith@example.com"
          }
        ]
      }'
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch(
      "https://api.revreply.com/v1/orchestrator/firstreply",
      {
        method: "POST",
        headers: {
          "Authorization": "Bearer <YOUR_JWT>",
          "Accept": "application/json",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          lead_id: 12345,
          cc_emails: [
            {
              sender: {
                first_name: "John",
                last_name: "Smith"
              },
              email: "john.smith@example.com"
            }
          ]
        })
      }
    );
    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/orchestrator/firstreply",
        headers={
            "Authorization": "Bearer <YOUR_JWT>",
            "Accept": "application/json",
            "Content-Type": "application/json",
        },
        json={
            "lead_id": 12345,
            "cc_emails": [
                {
                    "sender": {
                        "first_name": "John",
                        "last_name": "Smith",
                    },
                    "email": "john.smith@example.com",
                }
            ],
        },
    )
    data = response.json()
    print(data)
    ```
  </Tab>

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

    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer <YOUR_JWT>",
            "Accept: application/json",
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "lead_id" => 12345,
            "cc_emails" => [
                [
                    "sender" => [
                        "first_name" => "John",
                        "last_name" => "Smith",
                    ],
                    "email" => "john.smith@example.com",
                ],
            ],
        ]),
        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(`{
          "lead_id": 12345,
          "cc_emails": [
            {
              "sender": {
                "first_name": "John",
                "last_name": "Smith"
              },
              "email": "john.smith@example.com"
            }
          ]
        }`)

        req, _ := http.NewRequest(
            "POST",
            "https://api.revreply.com/v1/orchestrator/firstreply",
            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 `FirstReplyRequest` schema.

| Field       | Type                    | Required | Description                                                                                         | Example                                                                                   |
| ----------- | ----------------------- | -------- | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `lead_id`   | `integer`               | Yes      | ThreadState ID of the thread to activate.                                                           | `12345`                                                                                   |
| `cc_emails` | `array[object] \| null` | No       | CC email information to add to the thread. When provided, the array must contain at least one item. | `[{"sender":{"first_name":"John","last_name":"Smith"},"email":"john.smith@example.com"}]` |

### `cc_emails` item

Each CC email object contains:

| Field               | Type     | Required | Description             | Example                  |
| ------------------- | -------- | -------- | ----------------------- | ------------------------ |
| `sender.first_name` | `string` | Yes      | Sender's first name.    | `John`                   |
| `sender.last_name`  | `string` | Yes      | Sender's last name.     | `Smith`                  |
| `email`             | `string` | Yes      | Sender's email address. | `john.smith@example.com` |

The `sender` object requires both `first_name` and `last_name`, while `email` is required and uses email format validation.

### Request structure

```json theme={null}
{
  "lead_id": 12345,
  "cc_emails": [
    {
      "sender": {
        "first_name": "John",
        "last_name": "Smith"
      },
      "email": "john.smith@example.com"
    }
  ]
}
```

### Request examples

The request is a `POST` request to:

```text theme={null}
https://api.revreply.com/v1/orchestrator/firstreply
```

## Response

### Response structure

A successful request returns confirmation that the thread was activated, along with the `lead_id`.

| Field     | Type      | Required | Description                                     |
| --------- | --------- | -------- | ----------------------------------------------- |
| `success` | `integer` | Yes      | Indicates whether the operation was successful. |
| `lead_id` | `integer` | Yes      | ThreadState ID of the activated thread.         |

### Response example

```json theme={null}
{
  "success": 1,
  "lead_id": 12345
}
```

## Errors

### 422 — Validation error

Returned when one or more request fields fail validation.

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

### 500 — Orchestration failed

Returned when the orchestrator cannot activate the thread.

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