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

# Create an Agent

> Creates a new agent.

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

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

## Try it

Use the following request to create an agent:

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.revreply.com/v1/agent" \
      -H "Authorization: Bearer <YOUR_JWT>" \
      -H "Accept: application/json" \
      -H "Content-Type: application/json" \
      -d '{
        "agent_name": "Sales Agent",
        "first_name": "John",
        "last_name": "Doe",
        "email": "john@example.com",
        "company": "Acme Inc.",
        "timezone": "America/New_York"
      }'
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const response = await fetch("https://api.revreply.com/v1/agent", {
      method: "POST",
      headers: {
        "Authorization": "Bearer <YOUR_JWT>",
        "Accept": "application/json",
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        agent_name: "Sales Agent",
        first_name: "John",
        last_name: "Doe",
        email: "john@example.com",
        company: "Acme Inc.",
        timezone: "America/New_York"
      })
    });
    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/agent",
        headers={
            "Authorization": "Bearer <YOUR_JWT>",
            "Accept": "application/json",
            "Content-Type": "application/json",
        },
        json={
            "agent_name": "Sales Agent",
            "first_name": "John",
            "last_name": "Doe",
            "email": "john@example.com",
            "company": "Acme Inc.",
            "timezone": "America/New_York",
        },
    )
    data = response.json()
    print(data)
    ```
  </Tab>

  <Tab title="PHP">
    ```php theme={null}
    <?php
    $ch = curl_init("https://api.revreply.com/v1/agent");
    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer <YOUR_JWT>",
            "Accept: application/json",
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "agent_name" => "Sales Agent",
            "first_name" => "John",
            "last_name" => "Doe",
            "email" => "john@example.com",
            "company" => "Acme Inc.",
            "timezone" => "America/New_York",
        ]),
        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(`{"agent_name":"Sales Agent","first_name":"John","last_name":"Doe","email":"john@example.com","company":"Acme Inc.","timezone":"America/New_York"}`)
        req, _ := http.NewRequest("POST", "https://api.revreply.com/v1/agent", 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 `CreateAgentRequest` schema. The only required field is `agent_name`; the remaining fields are optional.

| Field                | Type      | Required | Description                                                 |
| -------------------- | --------- | -------- | ----------------------------------------------------------- |
| `agent_name`         | `string`  | Yes      | Agent name. Maximum 25 characters.                          |
| `first_name`         | `string`  | No       | Agent's first name. Maximum 25 characters.                  |
| `last_name`          | `string`  | No       | Agent's last name. Maximum 25 characters.                   |
| `email`              | `string`  | No       | Agent email address. Maximum 100 characters.                |
| `company`            | `string`  | No       | Company name. Maximum 75 characters.                        |
| `company_website`    | `string`  | No       | Company website. Maximum 100 characters.                    |
| `generate_profile`   | `boolean` | No       | Whether to generate the agent profile. Defaults to `false`. |
| `company_overview`   | `string`  | No       | Company overview.                                           |
| `context`            | `string`  | No       | Additional company or product context.                      |
| `tone`               | `integer` | No       | Agent tone, from `0` to `6`.                                |
| `agent_objective`    | `integer` | No       | `1` for Schedule Meeting or `2` for Other. Defaults to `1`. |
| `timezone`           | `string`  | No       | Agent timezone.                                             |
| `office_hours_from`  | `string`  | No       | Office-hours start time in `HH:MM` format.                  |
| `office_hours_to`    | `string`  | No       | Office-hours end time in `HH:MM` format.                    |
| `exclude_weekends`   | `boolean` | No       | Whether weekends are excluded.                              |
| `objective`          | `string`  | No       | Agent objective. Maximum 500 characters.                    |
| `soft_no`            | `boolean` | No       | Enables soft-no handling. Defaults to `false`.              |
| `soft_no_response`   | `string`  | No       | Soft-no response. Maximum 200 characters.                   |
| `meeting_link`       | `string`  | No       | Meeting URL. Maximum 100 characters.                        |
| `calendar_link`      | `string`  | No       | Calendar URL. Maximum 100 characters.                       |
| `status`             | `integer` | No       | Agent status, from `0` to `1`. Defaults to `0`.             |
| `followup_days1`     | `integer` | No       | Days before the first follow-up.                            |
| `followup_days2`     | `integer` | No       | Days before the second follow-up.                           |
| `followup_days3`     | `integer` | No       | Days before the third follow-up.                            |
| `followup_intervals` | `array`   | No       | Follow-up interval configuration; maximum 5 items.          |
| `google`             | `object`  | No       | Google calendar credentials.                                |
| `outlook`            | `object`  | No       | Outlook calendar credentials.                               |
| `calendly`           | `object`  | No       | Calendly credentials.                                       |

### Request structure

```json theme={null}
{
  "agent_name": "Sales Agent",
  "first_name": "John",
  "last_name": "Doe",
  "email": "john@example.com",
  "company": "Acme Inc.",
  "timezone": "America/New_York"
}
```

### Request examples

The request is a `POST` request to:

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

## Response

### Response structure

A successful request returns an object containing the created agent.

| Field     | Type      | Required | Description                                     |
| --------- | --------- | -------- | ----------------------------------------------- |
| `success` | `integer` | Yes      | Indicates whether the operation was successful. |
| `data`    | `object`  | Yes      | The created agent.                              |

### Response example

```json theme={null}
{
  "success": 1,
  "data": {
    "id": 123,
    "name": "Sales Agent",
    "status": 1,
    "agent_objective": "Schedule Meeting",
    "timezone": "America/New_York"
  }
}
```

## Errors

### 422 — Validation error

Returned when one or more request fields fail validation.

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

### 500 — Server or integration error

Returned when the agent cannot be created because of a server or integration failure.

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