# API Docs

## Get your API Auth Token

Your API requests are authenticated using API keys. Any request that doesn't include an API key will return an error.

You can get your API Auth Token from your partner at Vouch or write to <mark style="color:blue;"><corp@vouch.social></mark>

## Check the AuthToken

To make sure that your AuthToken is valid, you can use this API :

<mark style="color:blue;">`GET`</mark> api.vouch.social/api/corporate/check-auth

#### Options

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

```xml
curl --location 'https://api.vouch.social/api/corporate/check-auth' \
--header 'Authorization: Bearer <AuthToken>'
```

{% endtab %}
{% endtabs %}

#### Response

{% tabs %}
{% tab title="200 | AuthToken Valid" %}

```json
{
    "message": "success",
    "data": [],
    "status": true,
    "meta": null
}
```

{% endtab %}

{% tab title="401 Permission denied" %}

```postman_json
{
    "message": "Unauthorized",
    "error": "Unauthorized",
    "statusCode": 401
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Good to know:** If you believe you have inadvertently received a 401 error or you need any other information, please write to <corp@vouch.social>
{% endhint %}

***

## SaveCustomers

Save your customers on Vouch who can help with lead conversion & share referral bonuses:

<mark style="color:green;">`POST`</mark> `api.vouch.social/api/corporate/save-customer`

Request

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

```json
{
    "customers": [
        {
            "customerId": "CUST001",
            "contactHashedPhone": "d90743216eef2200d6c2ca4231e8b1857ecfe3ee0f8c0d38634c0c35bfd996ff"
        },
        {
            "customerId": "CUST002",
            "contactHashedPhone": "9e999284194d1cafb5bd736b55de4651d5cb4fa0e06743d3dce2ec73f2cd4f04"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

| Name               | Type   | Description                                                                                                                                                                                       |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| customerId         | string | Unique Identifier of the customer at your side                                                                                                                                                    |
| contactHashedPhone | string | The <mark style="background-color:blue;">**<**</mark>*<mark style="background-color:blue;">**hash**</mark>*<mark style="background-color:blue;">**>**</mark> of the phoner number of the customer |

Response

{% tabs %}
{% tab title="200 | Save Customer Successful" %}

```json
{
    "message": "success",
    "data": {
        "corpCustomersData": {
            "totalRecordsRecieved": 2,
            "totalRecordsCreated": 0,
            "totalRecordsUpdated": 2,
            "totalRecordsSkipped": 0
        }
    },
    "status": true,
    "meta": null
}
```

{% endtab %}

{% tab title="4xx | Error" %}

{% endtab %}
{% endtabs %}

|                      |     |                                                                                                                                                |
| -------------------- | --- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| totalRecordsRecieved | int | Number of customers shared in the call                                                                                                         |
| totalRecordsCreated  | int | Number of records ***new*** created on Vouch                                                                                                   |
| totalRecordsUpdated  | int | <p>Number of <em><strong>old</strong></em> records updated on Vouch.<br>PS : CustomerID is updated, customerHashedPhone is unique at Vouch</p> |
| totalRecordsSkipped  | int | Number of records skipped which don't match the format                                                                                         |

{% hint style="info" %}
*<mark style="background-color:blue;">**\<hash>**</mark>***:** Hashing transforms input data into a fixed-size string of characters using a hash function, ensuring data integrity and security.\
Hash is always to be done of the 10-digit Indian Phone Number with 91 at the start

Expected Format : 919076576578
{% endhint %}

{% tabs %}
{% tab title="ManualCheck" %}
Use Input : 9199999999\
OutPut : 5a15bf8887c41bb21f3b33a5bf1a06064711a6495cbbd97ddb92995d5df8b1b5\
Link : <https://codebeautify.org/sha256-hash-generator>
{% endtab %}

{% tab title="Python" %}

```python
import hashlib

hash_object = hashlib.sha256(b'919999999999')
hex_dig = hash_object.hexdigest()

```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const crypto = require('crypto');

const hash = crypto.createHash('sha256').update('919999999999').digest('hex');

```

{% endtab %}
{% endtabs %}

***

## Check Lead

To check the connectivity of a lead, use this API :

<mark style="color:green;">`POST`</mark>` ``https://api.vouch.social/api/corporate/check-lead`

Request

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

```json
{
    "leadHashedPhone": "5a15bf8887c41bb21f3b33a5bf1a06064711a6495cbbd97ddb92995d5df8b1b5"
}
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}

| Name                                              | Type   | Description                                                    |
| ------------------------------------------------- | ------ | -------------------------------------------------------------- |
| leadHashedPhone<mark style="color:red;">\*</mark> | string | The **\<hash>** of the lead which you want to check with Vouch |

Response

{% tabs %}
{% tab title="200 | AuthToken Valid" %}

```json
{
    "message": "success",
    "data": {
        "customerData": [
            {
                "name": "Nirant Ramakuru",
                "hashedPhone": "D90743216EEF2200D6C2CA4231E8B1857ECFE3EE0F8C0D38634C0C35BFD996FF",
                "strength": 3,
                "customerId": "CUST014",
                "isRegistered": true
            },
            {
                "name": "Anushtha Jain",
                "hashedPhone": "8576CC8DB8DFAAF46CCBCD300EBD79F5AB8936CF2AAEDB8DEFDCCADC53F6DF21",
                "strength": 8,
                "customerId": "CUST016",
                "isRegistered": true
            },
            {
                "name": "Ekaa",
                "hashedPhone": "92B5072176E723878B5E06FF3CA61898E4EB74E8C46642A0F2DB800B17364AB0",
                "strength": 20,
                "customerId": "CUST026",
                "isRegistered": true
            },
            {
                "hashedPhone": "9DD515FE4124AD44D2F3E28500F60F8A56F1150F29A22CEAA78AFBE70D5D0B2A",
                "strength": 30,
                "customerId": "CUST007",
                "isRegistered": false
            }
        ]
    },
    "status": true,
    "meta": null
}
```

{% endtab %}

{% tab title="401 Permission denied" %}

{% endtab %}
{% endtabs %}

| Name        | Type   | Description                                                       |
| ----------- | ------ | ----------------------------------------------------------------- |
| name        | string | If Customer is registered on Vouch, then we'll share the name     |
| hashedPhone | string | hashedPhone of the customer who is related to the lead            |
| strength    | int    | The strength of connection between the lead & the customer shared |

{% hint style="info" %}
**Strength :** Strength can range from 1 to :infinity:.. but we see the realistic limit as being \~500. Higher the strength, the better the chance of getting a referral
{% endhint %}

## Save Contacts

To upload the contactList of registered User, use this API :

<mark style="color:green;">`POST`</mark>` ``https://api.vouch.social/api/contacts/saveContacts`

Request

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

```json
{
"hashedPhone": "ce3a598687c8d2e5aa6bedad20e059b4a78cca0adad7e563b07998d5cd226b8c",
    "contacts": [
        {
            "displayName": "Aakansha Antino",
            "phones": [
                {
                    "hashedPhone": "ce3a598687c8d2e5aa6bedad20e059b4a78cca0adad7e563b07998d5cd226b8c"
                }
            ]
        }
    ]
}
```

{% endtab %}
{% endtabs %}

| Name                                          | Type   | Description                                                                |
| --------------------------------------------- | ------ | -------------------------------------------------------------------------- |
| hashedPhone<mark style="color:red;">\*</mark> | string | The **\<hash>** of the registered user whose contactList is being uploaded |
| contacts\*                                    | Array  | The list of contacts of the registered user                                |
| displayName                                   | string | The name of the contact as stored by the registered user in their contacts |
| phones                                        | Array  | The list of phoneNumbers (***hashed***) for the contact                    |
| hashedPhone                                   | string | The **\<hash>** of the contact                                             |

Response

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

```json
{
    "message": "Contacts processed successfully",
    "data": {
        "totalRecordsRecieved": 1,
        "totalRecordsCreated": 0,
        "totalRecordsUpdated": 0,
        "totalRecordsSkipped": 0,
        "lastSync": "11/12/2024"
    },
    "status": true,
    "meta": null
}
```

{% endtab %}

{% tab title="401 Permission denied" %}

{% endtab %}
{% endtabs %}

| Name                 | Type | Description                                                  |
| -------------------- | ---- | ------------------------------------------------------------ |
| totalRecordsRecieved | int  | Total Contacts Received                                      |
| totalRecordsCreated  | int  | Total Contacts Created New                                   |
| totalRecordsUpdated  | int  | Total Contacts Updated for Name                              |
| totalRecordsSkipped  |      | Total Contacts Skipped due to data mismatch or existing data |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vouch.gitbook.io/corporate/api-docs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
