# SystemsX

Documentation and Guides for SystemsX Products.

<https://systemsx.co.uk/>


# API Create Job

## <https://systemsx.co.uk/products/bridge>

## Create a Booking Job

<mark style="color:green;">`POST`</mark> `/external/deploy/booking`

This endpoint allows the creation of a booking job. Either the `username` **or** the `email_address` parameter is required, but **only one** should be provided.

**Body**

<table><thead><tr><th width="350">Name</th><th width="92">Type</th><th>Required</th></tr></thead><tbody><tr><td><code>api_key</code></td><td>string</td><td>true</td></tr><tr><td><code>type</code></td><td>string</td><td><code>po,msc,tui</code></td></tr><tr><td><code>bookingReference</code></td><td>string</td><td>true</td></tr><tr><td><code>return_url</code></td><td>url</td><td>false</td></tr><tr><td><code>organisationName</code></td><td>string</td><td>required</td></tr><tr><td><code>agentName</code></td><td>string</td><td>required</td></tr><tr><td><code>bookingFields[]</code></td><td>array</td><td>true</td></tr><tr><td><code>bookingFields[username]</code></td><td>string</td><td>[username OR email_address]</td></tr><tr><td><code>bookingFields[email_address]</code></td><td>email</td><td>[username OR email_address]</td></tr><tr><td><code>bookingFields[password]</code></td><td>string</td><td>true</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "hash": "XXXXXXXXXXXXXXXXXXXXX"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "hash": "XXXXXXXXXXXXXXXXXXXXX",
  "errors": [
    "X field is Missing or Empty."
  ]
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="return\_url Response" %}

```json
{
  "hash": "XXXXXXXX",
  "ImportDetail": {
      "importRequest": {
          "sourceReference": "",
          "bookingReference" : "",
          "bookingFields": [],
          "returnUrl": "",
          "api_key": "",
          "type": ""
      }
  }
}
```

{% endtab %}
{% endtabs %}


# API Billing Usage


# API - Query Builder

<https://systemsx.co.uk/products/sense>

Production API URL:

The API is focused towards POST requests however these can be GET requests also.

Ensure you are using `x-www-form-urlencoded` or `json` when sending requests.

## Query a table

<mark style="color:green;">`POST`</mark> `https://api.sense-ai.co.uk/v4/{tableName?}`

Leave table empty to view all available tables and columns for selection.

**Body**

| Name         | Type              | Description                             |
| ------------ | ----------------- | --------------------------------------- |
| `api_key`    | string (required) | API Key for account                     |
| `per_page`   | number            | Default: 20, Max: 100                   |
| `page`       | number            | Default: 1                              |
| `type`       | string            | `first` (One) or `get` (Many - Default) |
| `select`     | array (required)  | Array of columns to select              |
| `conditions` | array             | Array of conditions (see below)         |

## Conditions

Conditions are how a query is built, for example a list of Calls made, but only ones that have a duration above 60 seconds would be;

```
['type' => 'where', 'column' => 'duration', 'operator' => '>', 'value' => 60]
```

Conditions are provided as an array allowing you to apply multiple conditions to a query.

Operators Supported: (=, !=, >, >=, <, <=)

<pre><code>// Basic conditions
['type' => 'where', 'column' => 'status', 'operator' => '=', 'value' => 'active'],
<strong>
</strong><strong>// IN conditions
</strong>['type' => 'where_in', 'column' => 'category_id', 'value' => [1, 2, 3, 4]],
['type' => 'where_not_in', 'column' => 'status', 'value' => ['deleted', 'banned']],

// BETWEEN conditions
['type' => 'where_between', 'column' => 'age', 'value' => [18, 65]],
['type' => 'where_not_between', 'column' => 'score', 'value' => [0, 10]],

// NULL conditions
['type' => 'where_not_null', 'column' => 'email_verified_at'],
['type' => 'where_null', 'column' => 'deleted_at'],

// LIKE conditions (Contact Support for access)
['type' => 'where_like', 'column' => 'name', 'value' => '%john%'],
['type' => 'where_not_like', 'column' => 'email', 'value' => '%temp%'],

// Date conditions
['type' => 'where_date', 'column' => 'created_at', 'operator' => '>=', 'value' => '2024-01-01'],
['type' => 'where_month', 'column' => 'created_at', 'value' => 12],
['type' => 'where_year', 'column' => 'created_at', 'value' => 2024],

// JSON conditions (if using JSON columns)
['type' => 'where_json_contains', 'column' => 'meta->tags', 'value' => 'booking'],
['type' => 'where_json_length', 'column' => 'meta->tags', 'operator' => '>', 'value' => 2],
</code></pre>

## Example Request

Within this request are are selecting the uuid, agent\_id and duration of calls within call\_history and returning only calls where the duration is ≥ (greater or equal to) 60 seconds

Example GET request:

```url
/v4/call_history
?api_key=APIKEY
&select[]=uuid
&select[]=agent_id
&select[]=duration
&conditions[0][type]=where
&conditions[0][column]=duration
&conditions[0][operator]=%3E=
&conditions[0][value]=60
```

Example POST request:

```powershell
curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "APIKEY",
    "select": ["uuid", "agent_id", "duration"],
    "conditions": [
      {
        "type": "where",
        "column": "duration",
        "operator": ">",
        "value": 60
      }
    ]
  }' \
  "/v4/call_history"
```

## Data Understanding

| Table          | Column           | Details                                 |
| -------------- | ---------------- | --------------------------------------- |
| `call_history` | `has_transcript` | <p>2 = Completed<br>30 = No Metrics</p> |

## Data Recommendations

| Type  | Description                                                                                                                   |
| ----- | ----------------------------------------------------------------------------------------------------------------------------- |
| Calls | We always recommend using `call_history` for polling calls and using `uuid` to pair with the `uuid` within `call_transcripts` |


# API Agents - List

## List Agents

<mark style="color:green;">`POST`</mark> `/v2/agents/list`

**Body**

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| `api_key` | string |             |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "success": true,
    "agents": [
        {
            "id": 1234,
            "name": "Example",
            "phone_extension": "1000",
            "department": "Sales"
        }
    ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# API Call - Manual Upload

## Upload a call to be Reviewed Manually

<mark style="color:green;">`POST`</mark> `/v2/call/upload`

Multipart Form Data]\
File must be in `mp4` format.\
Maximum file size is 10MB.

**Headers**

| Name         | Value                 |
| ------------ | --------------------- |
| Content-Type | `multipart/form-data` |

**Body**

| Name      | Type       | Required | Description                                                                                                 |
| --------- | ---------- | -------- | ----------------------------------------------------------------------------------------------------------- |
| `api_key` | String     | Yes      |                                                                                                             |
| `file`    | File (mp4) | Yes      | <p>The file to be uploaded (multipart form data).<br><br>File Name Example: <br>"Inbound - JohnDoe.mp4"</p> |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "reply": true
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# API Call - History

## Search Calls History

<mark style="color:green;">`POST`</mark> `/v2/call/search`

**Body**

<table><thead><tr><th width="225">Param</th><th width="121">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>api_key</code></td><td>string</td><td><mark style="color:red;">required</mark></td></tr><tr><td><code>page</code></td><td>int</td><td></td></tr><tr><td><code>per_page</code></td><td>int</td><td>Default: 20, Min: 1, Max: 250</td></tr><tr><td><code>uuid</code></td><td>string</td><td>Return Single Call</td></tr><tr><td><code>transcript</code></td><td>boolean</td><td>Returns Transcripts</td></tr><tr><td><code>agents</code></td><td>array</td><td>[1,2,3,4]</td></tr><tr><td><code>direction</code></td><td>string</td><td><p>[inbound,outbound,inbound_voicemail,</p><p>outbound_voicemail]</p></td></tr><tr><td><code>phone_number</code></td><td>string</td><td></td></tr><tr><td><code>score</code></td><td>int</td><td>[Returns ===]</td></tr><tr><td><code>duration</code></td><td>int</td><td>[Returns ===]</td></tr><tr><td><code>start_date</code></td><td>date</td><td>YYYY-MM-DD</td></tr><tr><td><code>end_date</code></td><td>date</td><td>YYYY-MM-DD</td></tr><tr><td><code>show_all</code></td><td>boolean</td><td>(Default: false) Return both scored and unscored</td></tr><tr><td><code>show_unscored</code></td><td>boolean</td><td>(Default: false) Return only unscored</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "current_page": 1,
  "per_page": 20,
  "total": 3408,
  "data": [
    {
      "agent_id": 1,
      "provider": "file",
      "uuid": "000000-000000-000000-000000-000000",
      "call_type": "inbound",
      "phone_number": "+44777777777",
      "duration": 332,
      "review_score": 0,
      "time_started": "2024-08-22 16:25:16",
      "updated_at": "2024-08-22T21:01:19.000000Z",
      "agent": {
        "id": 11,
        "name": "Agent",
        "department": "Sales",
        "phone_extension": "1000",
        "email_address": null
      },
      "speakers": {
        "A": "AGENT",
        "B": "CLIENT"
      },
      "metrics": [
        {
          "metric": "overall",
          "score": 0,
          "total_possible": 0,
          "good": [],
          "bad": [],
          "improve": []
        }
      ],
      "summary": "",
      "actions": [],
      "conversation": [
        {
          "speaker": "A",
          "text": ""
        },
        {
          "speaker": "B",
          "text": ""
        }
      ],
      "fillers": [
        {
          "A": {
            "well": 1,
            "right": 2
          },
          "B": []
        }
      ],
      "highlights": [
        {
          "text": "Highlight",
          "category": "Company Names",
          "total": 2
        }
      ],
      "talking": {
        "A": {
          "seconds": 155.96485200000006,
          "percentage": 84.41
        },
        "B": {
          "seconds": 28.809985000000005,
          "percentage": 15.59
        },
        "Silence": {
          "seconds": 115.51000000000002,
          "instances": 7
        }
      }
    }
  ]
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# API Call - Review Prompt

## View Call Review Prompt

<mark style="color:green;">`POST`</mark> `/v2/call/prompt`

**Body**

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| `api_key` | string |             |
| `uuid`    | string | Call UUID   |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "content": "CONTENT"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# API Call - Metrics

## View Call Metrics

<mark style="color:green;">`POST`</mark> `/v2/call/metrics`

**Body**

| Name      | Type   | Description      |
| --------- | ------ | ---------------- |
| `api_key` | string | Name of the user |

**Response**

{% tabs %}
{% tab title="200" %}

```json
[
  {
    "agent_type": [
      "SALES",
      "ADMIN"
    ],
    "direction": "BOTH",
    "name": "example",
    "weight": 0,
    "tags": "none",
    "content": "Example Content"
  }
]
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# Assist - Integration

## Authenticating an Agent

<mark style="color:green;">`POST`</mark> `/v2/assist/authenticate`

Used on load of the Sense page to gain an access\_token for the Javascript to load.

**Body**

| Name       | Type   | Description     |
| ---------- | ------ | --------------- |
| `api_key`  | string | Account API Key |
| `agent_id` | int    | View API Agents |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "access_token": "",
    "expires_at": "2029-01-01T18:39:59.707469Z"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## HTML Setup

```
divs
assist_client_name
assist_client_email_address
assist_client_phone_number
assist_client_location
assist_client_date_of_birth
assist_client_created_at
assist_client_source
assist_client_holder
assist_client_tags
assist_buttons
assist_response_loading [innerHTML required]
assist_response
assist_mistakes
assist_actions

products
assist_product_calls
assist_product_communication
assist_recent_communication

modal
assist_modal
assist_modal_title
assist_modal_body
assist_modal_alert
assist_modal_label_subject
assist_modal_textarea_subject
assist_modal_label
assist_modal_textarea
assist_modal_templates
assist_modal_buttons
assist_modal_footer
assist_modal_send

textareas
assist_jotter

inputs
assist_ask_input

buttons
assist_ask_button
```

## Javascript Setup

| Param                    | Description                                                       |
| ------------------------ | ----------------------------------------------------------------- |
| `accessToken`            | Provided by [Broken mention](broken://pages/QAxDgqFKAs1xWqDQlDNH) |
| `jotter`                 | eg: Previous jotter notes saved                                   |
| `details[unique_id]`     | Used by CRMs for Sync                                             |
| `details[ip_address]`    | eg: 123.456.789.0                                                 |
| `details[name]`          | eg: John Doe                                                      |
| `details[email_address]` | eg: <example@example.com>                                         |
| `details[phone_number]`  | eg: +447377357971                                                 |
| `details[date_of_birth]` | eg: 01/05/2000                                                    |
| `details[location]`      | eg: Cardiff, United Kingdom                                       |
| `details[biography]`     | Summary of the Customer                                           |
| `details[tags]`          | eg: vip,member,business                                           |

```html
<script type="module">

    const senseConfiguration = {
        accessToken: "ACCESS_TOKEN_HERE",
        disableProducts: [], // calls, communication
        contact: {
            jotter: "2 adults, Costa Del Sol, CWL or BRS, 7 nights, all inclusive", // Overrides Jotter default value.
            details: {
                // unique_id, ip_address, name, email_address, phone_number, date_of_birth, location, biography, tags (vip,example_tax)
                name: "",
                email_address: "",
                phone_number: "",
                location: ""
            },
            preferences: {
                vip: true
            }
        },
        classes: {
            hidden: 'hidden',
            assist: {
                output: {
                    ul: 'list-group sx-fs-16 mb-2',
                    li: 'list-group-item sx-lh'
                },
                rating: {
                    like: 'btn btn-default',
                    dislike: 'btn btn-default'
                }
            },
            contact: {
                tags: {
                    "default": 'badge badge-outline badge-light',
                    "Vip": 'badge badge-outline badge-gold'
                }
            },
            actions: {
                div: 'col',
                buttons: {
                    default: 'btn btn-primary btn-block mb-2',
                    send_email: 'btn btn-primary btn-block mb-2',
                    send_meeting: 'btn btn-primary btn-block mb-2',
                    send_sms: 'btn btn-light btn-block',
                    send_whatsapp: 'btn btn-light btn-block',
                }
            },
            jotter: {
                buttons: {
                    default: 'btn btn-primary mr-2',
                    narrow_down: 'btn btn-primary mr-2',
                    recommend: 'btn btn-primary'
                }
            },
            products: {
                calls: {
                    score: {
                        circle_color: "avatar-",
                        circle_span: "initial-wrap"
                    },
                    summary: {
                        button: "btn btn-primary btn-sm btn-block"
                    },
                    tasks: {
                        li_header: "list-group-item sx-lh sx-text-dark",
                        li_task: "list-group-item d-flex justify-content-between align-items-center",
                        li_footer: "list-group-item sx-lh sx-text-dark",
                        li_button: "btn btn-primary btn-sm btn-block"
                    },
                    feedback: {
                        li_header: "list-group-item sx-lh sx-text-dark",
                        li_good: "list-group-item sx-lh list-group-item-success",
                        li_bad: "list-group-item sx-lh list-group-item-danger",
                        li_improve: "list-group-item sx-lh list-group-item-warning"
                    }
                }
            }
        },
        lang: {
            assist: {
                mistakes: "*Sense Assist can make mistakes. Always check important info."
            },
            actions: {
                buttons: {
                    email: 'Send Email',
                    meeting: 'Send Meeting',
                    sms: 'Send SMS',
                    whatsapp: 'Send WhatsApp',
                }
            },
            jotter: {
                buttons: {
                    narrow_down: 'Narrow Down',
                    recommend: 'Recommend'
                }
            },
            products: {
                calls: {
                    summary: {
                        title: "Call Summary",
                        button: "Add to Notes"
                    },
                    score: {
                        description: "Your last call was rated [X]"
                    },
                    tasks: {
                        title: "Call Tasks",
                        button: "Add To Tasks",
                    },
                    feedback: {
                        title: "Call Feedback"
                    }
                }
            }
        }
    };

    // Importing from a remote URL
    import('https://api.sense-ai.co.uk/js/assist/core.js').then(module => {
        // Run the load function from the core.js with the configuration
        module.senseAssist.load(senseConfiguration);
    }).catch(error => console.error('Error loading the module:', error));

</script>

```


# API Assist - Load

## Load Assist Data for Client and Agent

<mark style="color:green;">`POST`</mark> `/v2/assist/load`

**Provide as much of Contact array as possible.**

**Body**

<table><thead><tr><th width="293">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>access_token</code></td><td>string</td><td>Access Token for Agent</td></tr><tr><td><code>contact[unique_id]</code></td><td>string</td><td></td></tr><tr><td><code>contact[name]</code></td><td>string</td><td></td></tr><tr><td><code>contact[email_address]</code></td><td>email</td><td></td></tr><tr><td><code>contact[phone_number]</code></td><td>phone</td><td></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "companyName": "CompanyCo",
    "agent": {
        "id": 1234,
        "name": "Agent",
        "department": "Sales",
        "email_address": "agent@example.com"
    },
    "products": [
        "assist",
        "calls",
        "communication"
    ],
    "communication": [],
    "invalidProducts": [],
    "contact": {
        "id": 1234,
        "unique_id": null,
        "name": "Example",
        "email_address": null,
        "phone_number": "123456789",
        "date_of_birth": null,
        "location": null,
        "biography": null,
        "tags": null,
        "created_at": "2024-10-01T10:52:30.000000Z"
    },
    "buttons": [
        "narrow_down",
        "recommend"
    ],
    "actions": [
        "email",
        "meeting",
        "sms",
        "whatsapp"
    ],
    "subActions": [
        "email_follow_up_email",
        "email_rewrite_email",
        "email_shorten_email",
        "sms_follow_up_sms",
        "sms_rewrite_sms",
        "sms_shorten_sms"
    ],
    "templates": {
        "sms": [
            "Welcome Client",
            "We tried to call you..."
        ],
        "whatsapp": [
            "Welcome Client",
            "We tried to call you..."
        ]
    },
    "calls": []
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# API Assist - Functions

## Start a Function

<mark style="color:green;">`POST`</mark> `/v2/assist/start`

| Type   | Function                               |
| ------ | -------------------------------------- |
| button |                                        |
|        | narrow\_down                           |
|        | recommend                              |
|        | \[List in "buttons" from /assist/load] |
| ask    |                                        |
|        | ask                                    |

**Body**

<table><thead><tr><th width="236">Name</th><th>Type</th></tr></thead><tbody><tr><td><code>access_token</code></td><td>string</td></tr><tr><td><code>type</code></td><td>string</td></tr><tr><td><code>function</code></td><td>string</td></tr><tr><td><code>context[]</code></td><td>Example: <code>How hot is it in Spain?</code></td></tr><tr><td><code>context[]</code></td><td>Example: <code>2 Adults going from Spain to London</code></td></tr><tr><td><code>context[]</code></td><td>Example: <code>Client Name: John Doe</code></td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "pollingUrl": "check?session=SESSIONID&type=ask&function=ask",
    "type": "ask",
    "function": "ask"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## Check Status of Request

<mark style="color:green;">`POST`</mark> `/v2/assist/check`

Check the status of a Start Function

**Body**

| Name           | Type   | Description                |
| -------------- | ------ | -------------------------- |
| `access_token` | string |                            |
| `session`      | string | Pulled from Start Function |
| `type`         | string | Pulled from Start Function |
| `function`     | string | Pulled from Start Function |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "running": true, // Will only show when AI is still running.
  "complete" true, // Will only show when AI is complete.
  "content": "" // JSON as String. "text" for ASK and Buttons will provide multiple keys.
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# API Email - History

## Search Emails History

<mark style="color:green;">`POST`</mark> `/v2/email/search`

**Body**

<table><thead><tr><th width="225">Param</th><th width="121">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>api_key</code></td><td>string</td><td><mark style="color:red;">required</mark></td></tr><tr><td><code>email_address</code></td><td>string</td><td>Email Address lookup <mark style="color:red;">required</mark></td></tr><tr><td><code>page</code></td><td>int</td><td></td></tr><tr><td><code>uuid</code></td><td>string</td><td>Return Single Email From UUID</td></tr><tr><td><code>eid</code></td><td>string</td><td>Return Emails from eid [Chain]</td></tr></tbody></table>

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "current_page": 1,
    "from": 1,
    "to": 1,
    "total": 4,
    "data": [
        {
            "id": 1,
            "uuid": "14e60762992ef2aeb13038a8fb08ffd5",
            "user_id": 1,
            "agent_id": 1000,
            "hidden": 0,
            "provider": "outlook", // outlook, gmail or smtp
            "folder": "Inbox",
            "type": "inbound", // inbound or outbound
            "eid": "EMAIL_CHAIN_ID_HERE",
            "uid": "UNIWUE_EMAIL_ID_HERE",
            "from_email": "from@email.com",
            "to_email": [
                {
                    "name": "John Doe",
                    "email_address": "to@email.com"
                }
            ],
            "subject": "Sending Email Eample",
            "text_body": "BASE_64_ENCODED_STRING",
            "html_body": "BASE_64_ENCODED_STRING",
            "headers": [
                { // Possible outputs, custom to whats sent.
                    "sense_customer_id": 123456,
                    "sense_order_id": 123456
                    // ...
                }
            ],
            "cc": [
                {
                    "name": "Another Person",
                    "email_address": "cc1@email.com"
                }
            ],
            "bcc": [], // Same pattern as CC
            "is_draft": 0, // True/False
            "is_read": 1, // True/False
            "summary": "Summary of the Email Chain here",
            "actions": [
                {
                    "type": "email",
                    "task": "Example task here",
                    "period": "ASAP" // TODAY, ASAP, THIS_WEEK, NEXT_WEEK or Specific Date [YYYY-MM-DD H:i:s]
                }
            ],
            "spam": 0, // 0-100
            "scam": 0, // 0-100
            "junk": 0, // 0-100
            "tags": [
                "technical",
                "b2b",
                "internal",
                "follow_up",
                "product_update"
            ],
            "priority": "medium", // low, medium, high
            "date": "2024-11-21 18:51:03", // Date the email landed
            "created_at": "2024-11-21T23:15:33.000000Z",
            "updated_at": "2024-11-21T23:15:48.000000Z"
        },
    ],
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# API Email - Create

## Create Emails New/Reply

<mark style="color:green;">`POST`</mark> `/v2/email/create`

**Body**

<table><thead><tr><th width="225">Param</th><th width="121">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>api_key</code></td><td>string</td><td><mark style="color:red;">required</mark></td></tr><tr><td><code>from_address</code></td><td>string</td><td><mark style="color:red;">required</mark></td></tr><tr><td><code>uid</code></td><td>string</td><td>Email uid being responded to</td></tr><tr><td><code>subject</code></td><td>string</td><td>Subject if no uid is provided [New Email]</td></tr><tr><td><code>body</code></td><td>string</td><td>HTML or Plain Text <mark style="color:red;">required</mark></td></tr><tr><td><code>to_address</code></td><td>string</td><td>To Address if no uid is provided [New Email]</td></tr><tr><td><code>cc</code></td><td>array</td><td>Email Addresses</td></tr><tr><td><code>bcc</code></td><td>array</td><td>Email Addresses</td></tr><tr><td><code>headers</code></td><td>array</td><td>Key must start with <code>sense_</code></td></tr></tbody></table>

**Example Payload**

{% tabs %}
{% tab title="New Email" %}

```json
{
  "api_key": "",
  "from_address": "staffmember@email.com",
  "to_address": "client@email.com",
  "cc": [
    "another@email.com"
  ],
  "subject": "Example Subjext",
  "body": "HTML or Plain Text here",
  "headers": [
    "sense_client_id": 123456
  ]
}
```

{% endtab %}

{% tab title="Reply Email" %}

```json
{
  "api_key": "",
  "from_address": "staffmember@email.com",
  "uid": "UNIQUE_ID_HERE",
  "body": "HTML or Plain Text here"
}
```

{% endtab %}
{% endtabs %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "status": "success"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}


# Common - Encode

## Encode Lat/Lng to GeoHash

<mark style="color:green;">`POST`</mark> `/api/common`

Returns the GeoHash for the lat/lng provided. If precision is auto, the result will be max 12 char length.\
The max precision of a GeoHash is based on the decimals of the initial Lat/Lng, for more precision ensure the Lat/Lng is the most accurate as possible.

**Body**

| Param     | Value/Type | Description |
| --------- | ---------- | ----------- |
| function  | 'encode'   | Static      |
| latitude  | float      |             |
| precision | int        | 0 = Auto    |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "geo_hash": "gbuw6fyprdsg"
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Error Message Here"
}
```

{% endtab %}
{% endtabs %}


# Common - Decode

## Decode GeoHash to Lat/Lng

<mark style="color:green;">`POST`</mark> `/api/common`

Returns the Lat/Lng from a GeoHash based on the precision of the GeoHash.

**Body**

| Param     | Value/Type | Description |
| --------- | ---------- | ----------- |
| function  | 'decode'   | Static      |
| geo\_hash | string     |             |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "latitude": float,
  "longitude": float
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Error Message Here"
}
```

{% endtab %}
{% endtabs %}


# Common - Neighbors

## GeoHash Neighbors

<mark style="color:green;">`POST`</mark> `/api/common`

Returns an array of geohash's for all neighbors from a starting neighbor until X radius.

**Body**

| Param     | Value/Type  | Description |
| --------- | ----------- | ----------- |
| function  | 'neighbors' | Static      |
| geo\_hash | string      |             |
| radius    | int         | \[Miles]    |
| precision | int         | 0 = Auto    |

**Response**

{% tabs %}
{% tab title="200" %}

```json
["gbvqs","gbvqu","gbvqv","gbvqt","gbvqm","gbvqk","gbvq7","gbvqe","gbvqg","gbvrh","gbvrj","gbvr5","gbvrn","gbvqy","gbvqw","gbvqq","gbvqn","gbvqj","gbvqh","gbvq5","gbvq4","gbvq6","gbvqd","gbvqf","gbvr4","gbvrp","gbvqz","gbvqx","gbvqr","gbvqp","gbvmz","gbvmy","gbvmv","gbvmu","gbvmg","gbvmf","gbvmc","gbvq1","gbvq3","gbvq9","gbvqc","gbvr1","gbvwb","gbvw8","gbvw2","gbvw0","gbvq0","gbvq2","gbvq8","gbvqb","gbvw9","gbvw3"]
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Error Message Here"
}
```

{% endtab %}
{% endtabs %}


# Common - Inside Polygon

## Location Inside Poly

<mark style="color:green;">`POST`</mark> `/api/common`

Returns results on if a location is inside a polygon or not. Recommended to use for high-level checking.

This specific endpoint does not auto-scale geohash precision, ensure your initial polygon points have precision or use another endpoint.

**Body**

| Param     | Value/Type | Description  |
| --------- | ---------- | ------------ |
| function  | 'inside'   | Static       |
| points    | array      |              |
| precision | int        | Default is 6 |
| locations | array      |              |

**Example**

{% tabs %}
{% tab title="Input" %}

```json
{
  .. other params
  "points": [
    [float, float],
    [float, float],
    [float, float],
    [float, float],
    ...
  ],
  "locations": [
    {
      "latitude": float,
      "longitude": float
    }
    ...
  ]
}
```

{% endtab %}
{% endtabs %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
[
  {
    "latitude": float,
    "longitude": float,
    "is_inside": bool
  }
  ...
]
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Error Message Here"
}
```

{% endtab %}
{% endtabs %}


# Editor

GitBook has a powerful block-based editor that allows you to seamlessly create, update, and enhance your content.

<figure><img src="https://gitbookio.github.io/onboarding-template-images/editor-hero.png" alt=""><figcaption></figcaption></figure>

### Writing content

GitBook offers a range of block types for you to add to your content inline — from simple text and tables, to code blocks and more. These elements will make your pages more useful to readers, and offer extra information and context.

Either start typing below, or press `/` to see a list of the blocks you can insert into your page.


# Markdown

GitBook supports many different types of content, and is backed by Markdown — meaning you can copy and paste any existing Markdown files directly into the editor!

<figure><img src="https://gitbookio.github.io/onboarding-template-images/markdown-hero.png" alt=""><figcaption></figcaption></figure>

Feel free to test it out and copy the Markdown below by hovering over the code block in the upper right, and pasting into a new line underneath.

```markdown
# Heading

This is some paragraph text, with a [link](https://docs.gitbook.com) to our docs. 

## Heading 2
- Point 1
- Point 2
- Point 3
```

{% hint style="info" %}
If you have multiple files, GitBook makes it easy to import full repositories too — allowing you to keep your GitBook content in sync.
{% endhint %}


# Images & media

GitBook allows you to add images and media easily to your docs. Simply drag a file into the editor, or use the file manager in the upper right corner to upload multiple images at once.

<figure><img src="https://gitbookio.github.io/onboarding-template-images/images-hero.png" alt=""><figcaption><p>Add alt text and captions to your images</p></figcaption></figure>

{% hint style="info" %}
You can also add images simply by copying and pasting them directly into the editor — and GitBook will automatically add it to your file manager.
{% endhint %}


# Interactive blocks

In addition to the default Markdown you can write, GitBook has a number of out-of-the-box interactive blocks you can use. You can find interactive blocks by pressing `/` from within the editor.

<figure><img src="https://gitbookio.github.io/onboarding-template-images/interactive-hero.png" alt=""><figcaption></figcaption></figure>

### Tabs

{% tabs %}
{% tab title="First tab" %}
Each tab is like a mini page — it can contain multiple other blocks, of any type. So you can add code blocks, images, integration blocks and more to individual tabs in the same tab block.
{% endtab %}

{% tab title="Second tab" %}
Add images, embedded content, code blocks, and more.

```javascript
const handleFetchEvent = async (request, context) => {
    return new Response({message: "Hello World"});
};
```

{% endtab %}
{% endtabs %}

### Expandable sections

<details>

<summary>Click me to expand</summary>

Expandable blocks are helpful in condensing what could otherwise be a lengthy paragraph. They are also great in step-by-step guides and FAQs.

</details>

### Drawings

<img alt="" class="gitbook-drawing">

### Embedded content

{% embed url="<https://www.youtube.com/watch?v=YILlrDYzAm4>" %}

{% hint style="info" %}
GitBook supports thousands of embedded websites out-of-the-box, simply by pasting their links. Feel free to check out which ones[ are supported natively](https://iframely.com).
{% endhint %}


# OpenAPI

You can sync GitBook pages with an OpenAPI or Swagger file or a URL to include auto-generated API methods in your documentation.

### OpenAPI block

GitBook's OpenAPI block is powered by [Scalar](https://scalar.com/), so you can test your APIs directly from your docs.

{% openapi src="<https://petstore3.swagger.io/api/v3/openapi.json>" path="/pet" method="post" %}
<https://petstore3.swagger.io/api/v3/openapi.json>
{% endopenapi %}


# Integrations

GitBook integrations allow you to connect your GitBook spaces to some of your favorite platforms and services. You can install integrations into your GitBook page from the *Integrations* menu in the top left.

<figure><img src="https://gitbookio.github.io/onboarding-template-images/integrations-hero.png" alt=""><figcaption></figcaption></figure>

### Types of integrations

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden></th></tr></thead><tbody><tr><td><strong>Analytics</strong></td><td>Track analytics from your docs</td><td><a href="https://www.gitbook.com/integrations#analytics">https://www.gitbook.com/integrations#analytics</a></td><td><a href="https://content.gitbook.com/content/ApTBiwKceZrYybclQaQk/blobs/q2UbQRa7Zj2CrL2vlypZ/2.png">2.png</a></td><td></td></tr><tr><td><strong>Support</strong></td><td>Add support widgets to your docs</td><td><a href="https://www.gitbook.com/integrations#support">https://www.gitbook.com/integrations#support</a></td><td><a href="https://content.gitbook.com/content/ApTBiwKceZrYybclQaQk/blobs/ctbhkMezGfNCTpDNmvFZ/3.png">3.png</a></td><td></td></tr><tr><td><strong>Interactive</strong></td><td>Add extra functionality to your docs</td><td><a href="https://www.gitbook.com/integrations#interactive">https://www.gitbook.com/integrations#interactive</a></td><td><a href="https://content.gitbook.com/content/ApTBiwKceZrYybclQaQk/blobs/NaYxj4WRRafUJrnrWL7e/4.png">4.png</a></td><td></td></tr><tr><td><strong>Visitor Authentication</strong></td><td>Protect your docs and require sign-in</td><td><a href="https://www.gitbook.com/integrations#visitor-authentication">https://www.gitbook.com/integrations#visitor-authentication</a></td><td><a href="https://content.gitbook.com/content/ApTBiwKceZrYybclQaQk/blobs/VyjQdAIW0i1GCeSMmfKQ/1.png">1.png</a></td><td></td></tr></tbody></table>


