> ## 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 a User

> Creates a new user with the specified profile and timezone.

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

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

## Try it

Use the following request to create a user:

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.revreply.com/v1/users" \
      -H "Authorization: Bearer <YOUR_JWT>" \
      -H "Accept: application/json" \
      -H "Content-Type: application/json" \
      -d '{
        "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/users",
      {
        method: "POST",
        headers: {
          "Authorization": "Bearer <YOUR_JWT>",
          "Accept": "application/json",
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          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/users",
        headers={
            "Authorization": "Bearer <YOUR_JWT>",
            "Accept": "application/json",
            "Content-Type": "application/json",
        },
        json={
            "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/users");

    curl_setopt_array($ch, [
        CURLOPT_POST => true,
        CURLOPT_HTTPHEADER => [
            "Authorization: Bearer <YOUR_JWT>",
            "Accept: application/json",
            "Content-Type: application/json",
        ],
        CURLOPT_POSTFIELDS => json_encode([
            "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(`{
          "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/users",
            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 accepts the following fields:

| Field        | Type     | Required | Description                                                                           | Example            |
| ------------ | -------- | -------- | ------------------------------------------------------------------------------------- | ------------------ |
| `first_name` | `string` | Yes      | User's first name. Maximum length: 255 characters.                                    | `John`             |
| `last_name`  | `string` | Yes      | User's last name. Maximum length: 255 characters.                                     | `Doe`              |
| `email`      | `string` | Yes      | User's email address. Must be a valid email address and is limited to 255 characters. | `john@example.com` |
| `company`    | `string` | Yes      | User's company name. Maximum length: 255 characters.                                  | `Acme Inc.`        |
| `timezone`   | `string` | Yes      | User's timezone identifier. Maximum length: 100 characters.                           | `America/New_York` |

### Request structure

```json theme={null}
{
  "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/users
```

## Response

### Response structure

A successful request returns an object indicating that the user was created successfully.

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

### Response example

```json theme={null}
{
  "success": 1,
  "message": "Operation completed successfully"
}
```

## Errors

### 422 — Validation error

Returned when one or more request fields fail validation.

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