# Welcome

Valtt Developer Documentation

### Getting Started

&#x20;Welcome to Valtt's Developer Documentation.\
\
Within these docs you will find an overview of how Valtt works, how to use our valtt.js / website code, and how to use our REST API. If at any point you need help, please reach out to us at [Support@Valtt.com](mailto:support@valtt.com)

### Overview

The Valtt system is based around Agreements and Clickwraps. An Agreement is comprised of the following: a name or title, a version, the actual text of the agreement, and some specific settings that define how the agreement will be presented. A Clickwrap is the set of data that together proves that your user agreed to your Agreement at a specific time and date.\
\
At a high level, it works like this: create an Agreement, lock the Agreement, set the Agreement as active, paste the code on to your website or use the API, and start collecting clickwraps. Under the definitions below we will go in to detail on how this process works.

### Definitions

**Active Agreement** a setting on an Agreement that allows it to start accepting Clickwraps, and causes the Agreement to count towards your allowed active agreement total.\
\
**Agreement Button Class** the CSS class that determines how the "Agree" button looks when it is presented on your website. This only applies to the valtt.js / Website Code. If you use the API this setting is ignored.\
\
**Agreement Callback Element ID** this is a hidden input field that is initially set to "n" and updated to "y" once a Clickwrap has been successfully recorded. You can use this to check before allowing your user to move forward to ensure that they have clicked agree and agreed to your agreement.\
\
**Agreement Certificate** the certificate that explains and proves that an Agreement was locked at a certain time and date.\
\
**Agreement Link Class** the CSS class that determines how the link to the text of your Agreement will look when it is presented on your website. This only applies to the valtt.js / Website Code. If you use the API this setting is ignored.\
\
**Agreement Text Class** the CSS class that determines how the text will look when it is presented on your website. This only applies to the valtt.js / Website Code. If you use the API this setting is ignored.\
\
**Clickwrap Certificate** the completed certificate that shows proof that your user has agreed to a certain Agreement at a certain time and date.\
\
**Fingerprint (Agreement or Clickwrap)** this is a 64 digit code that uniquely represents an Agreement or a Clickwrap. It is created by taking either the text of the agreement or the data collected for the Clickwrap and creating a one-way hash of the information.\
\
**Locked Agreement** a setting on an Agreement that prevents further editing of the name, version, and text of the agreement. Once an agreement is locked it is fingerprinted and the fingerprint is stored on the Blockchain (except for the Starter (free) Plan). The locking of an Agreement (along with the Agreement Fingerprint and storing that fingerprint on the Blockchain) prove that the Agreement that was agreed to in a Clickwrap has not changed.

### How it Works

**Step 1** Create an account at Valtt.\
\
**Step 2** Login to the Valtt [Dashboard](https://dashboard.valtt.com) and click Create Agreement on the main Dashboard page.\
\
**Step 3** Fill in all the details for your Agreement. Fill in the CSS class details if you know them, otherwise they can be left blank.\
\
**Step 4** Once you are done editing your Agreement details, click on the lock switch at the bottom of the Agreement edit page. Then click Update Agreement.\
\
**NOTE:** Skip step 5 if you are using the Valtt API to connect.\
\
**Step 5** Once the agreement is locked you can click on the "Get Code" button on the bottom of the page when editing an Agreement. You will need to dynamically update the hidden text field called "valtt-unique-user-id". This field uniquely identifies which user agreed to your agreement. Copy this code on to your website, and add additional code that updates the unique user ID field and checks the clickwrap-complete hidden field for the value of "y" before allowing your user to continue.\
\
**Step 6** Click on Clickwraps on the left menu in the Valtt Dashboard to see or search for users who have agreed to your agreement.


# How to Implement valtt.js

Below you will find the details of the code to implement Valtt on your website using our valtt.js code snippet.

```
<!-- VALTT CODE START -->
<!-- START Required One Time -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://app.valtt.com/v1.2/valtt.js"></script>
<input type="hidden" id="valtt-unique-user-id" value="">
<!-- END Required One Time -->
<div id="valtt-clickwrap1"></div>
<script>
  valtt1 = new valtt(
    'Environment',
    'Organization-ID',
    'Agreement-ID',
    'AgreementName',
    'AgreementVersion',
    'AgreementStatement',
    'AgreementCompleteText',
    'valtt-clickwrap1',
    'Text-Class',
    'Button-Class',
    'Link-Class',
    'Callback-Element',
    'Clickwrap-Number',
    'Show-Agreement-Text',
    'Agreement-Text-Rows',
    'Agreement-Text-Cols',
    'Agreement-Text-CSS');
</script>
<div id="valtt-error-message-c1" class="small"></div>
<input type="hidden" id="Callback-Element" value="n" class="Callback-Element">
<!-- VALTT CODE END -->
```

**The code above is auto-generated for you after you lock an agreement.** When an agreement is locked you will see a "**Get Code**" button on the Edit Agreement Page near the bottom. Clicking this reveals the exact code needed for the Agreement you are editing.

The code above in its entirety is required on your website page in order for the Clickwrap to be successfully captured.

**#jQuery** is required. If you already include it in another location on your page, you can remove it from the "Required One Time" section of the code snippet.

### Switching: Test and Live

To switch between saving live data and test data, change Environment passed in as "live" or "test". See below.

### Elements Explained

**Environment** \[required] designates the environment to save the clickwrap data, "live" or "test".

**Organization ID** \[required] is populated for you, represents your specific organization, and is required.

**Agreement ID** \[required] is the specific ID for the agreement your user is agreeing to, and is required.

**Agreement Name, Agreement Version, and Agreement Text** \[required] cannot be updated once the agreement is locked, and all are required.

**Agreement Statement** \[required] is the text that is shown to ask your user to agree by clicking the button below. You can customize this text.

**Agreement Complete Text** \[required] is the text that is displayed to your user once they have clicked the "Agree" button.

**valtt-clickwrap1** \[required] is the element, noted in the DIV at the top of the code, that the Valtt system will place the agree request.

**Text, Button, and Link Classes** \[required, but can be passed in as blank] are the CSS classes that determine the look and feel of the agree request. These are optional, but must be included in the code as at least blank.

**Callback Element** \[required] is the hidden form field is updated once the clickwrap is complete. In your code, you can check this field for a "y" before allowing your users to continue in your process.

**Clickwrap Number** \[required] is the number of the clickwrap on the page, should start with "c" and be followed by a number. Example: "c1".

**Agreement Text** \[required, 'y' or 'n'] when set to 'y' will show the Agreement text above the button, or 'n' to not show.

**Agreement Text Rows** \[required, but can be passed in as blank] is the number of rows (height) to show for the Agreement text.

**Agreement Text Cols** \[required, but can be passed in as blank] is the number of columns (width) to show for the Agreement text.

**Agreement Text CSS** \[required, but can be passed in as blank] is the CSS class of the Agreement Text textarea element.


# How to Add Multiple Clickwraps on the Same Page

To place multiple clickwraps on the same page copy the part of the code snippet **under** the "Required One Time" section.

Be sure to do the following:\
1\. Change "valtt1 = new valtt" to "valtt# = new valtt" - where # would be the number of the clickwrap on your page.\
2\. Update the valtt-clickwrap# div ID, the callback element #, and the clickwrap #.

```
<div id="valtt-clickwrap1"></div>
<script>
  valtt1 = new valtt(
    'Environment',
    'Organization-ID',
    'Agreement-ID',
    'AgreementName',
    'AgreementVersion',
    'AgreementStatement',
    'AgreementCompleteText',
    'valtt-clickwrap1',
    'Text-Class',
    'Button-Class',
    'Link-Class',
    'Callback-Element',
    'Clickwrap-Number',
    'n',
    '',
    '',
    '');
</script>
<div id="valtt-error-message-c1" class="small"></div>
<input type="hidden" id="Callback-Element" value="n" class="Callback-Element">
```

Here is an example of what a second clickwrap on a page might look like.

```
<div id="valtt-clickwrap2"></div>
<script>
  valtt2 = new valtt(
    'live',
    'Organization-ID',
    'Agreement-ID',
    'Test Agreement',
    'v1',
    'By clicking the button below, I agree to:',
    'Completed: Terms of Service. Thank you.',
    'valtt-clickwrap2',
    'Text-Class',
    'Button-Class',
    'Link-Class',
    'clickwrap-complete2',
    'c2',
    'n',
    '',
    '',
    '');
  valtt2.displayClickwrap();
</script>
<div id="valtt-error-message-c2" class="small"></div>
<input type="hidden" id="clickwrap-complete2" value="n" class="clickwrap-complete2">
```


# Change Log

Here you will find changes made to the valtt.js code and any changes in how to use it.

## 1.2 - 2020-09-06

### Added

* Ability to have show the Agreement text in a box above the Agree button.
* Added four new arguments to the main Valtt object creation:
  * Show Agreement: "y" or "n"
  * Agreement Rows: # of rows for the textarea height
  * Agreement Columns: # of columns for the textarea width
  * Agreement CSS: CSS to use in the textarea tag

### Changed

* Updated URL for the valtt.js file > <https://app.valtt.com/v1.2/valtt.js>

## 1.0.2 - 2020-08-11

### Added

* Ability to have multiple clickwraps on the same page.

### Changed

* Updated URL for the valtt.js file > <https://app.valtt.com/v1/valtt.js>
* To save test or live data, simply pass in the environment "test" or "live" when valtt is instantiated. See the code snippet.
* jQuery is now required as a JavaScript source tag at the top of the code snippet. Before it was added automatically by the valtt.js code. If your page already includes it, you can remove this line.

## 1.0.1 - 2020-07-23

### Added

* Ability to save to test or live data.&#x20;

## 1.0.0 - 2020-07-18

### Initial Deployment


# Getting Started

Guide to getting started and using the Valtt API.

The Valtt API is a REST API that provides specific endpoints, receives form-data, and returns JSON encoded responses. Errors are sent using standard HTTP response codes and easy to read and understand JSON encoded error messages.\
\
The API can be used in test or live mode. The API key that is used determines which mode is being used. The same type and method of authentication is used in test and live mode.

### Getting Started

In order to use the Valtt API you will need an API Key and API Secret. In the Valtt [Dashboard](https://dashboard.valtt.com), under Account on the left menu, select API Keys, and create a new test or live API Key set.

### Authentication

The Valtt API uses Basic Auth with the API Key and API Secret that are generated in the Valtt [Dashboard](https://dashboard.valtt.com). Authentication is required for all requests except for the Status API endpoint.\
\
All API requests must be made using **HTTPS**.


# Status

Returns the current status of the Valtt API.

## Status

<mark style="color:blue;">`GET`</mark> `https://app.valtt.com/api/status/`

This endpoint requires no request parameters or authentication and responds with the status of the Valtt API.

{% tabs %}
{% tab title="200 Status successfully retrieved." %}

```
{
    "api_name": "Valtt Clickwrap API",
    "api_version": "1.0",
    "status": "available",
    "time_gmt": "2020-07-21 16:24:53"
}
```

{% endtab %}
{% endtabs %}

### Example cURL Request

```
curl --location --request GET 'https://app.valtt.com/api/status'
```


# Create Clickwrap

Creates a new test or live Clickwrap in the Valtt system.

## Create Clickwrap

<mark style="color:green;">`POST`</mark> `https://app.valtt.com/api/create/`

This endpoint accepts clickwrap data, creates a clickwrap fingerprint, and stores the clickwrap fingerprint and data. After it is recorded a backend process starts and records the clickwraps on the Blockchain. The Blockchain recording process does not happen for test data or clickwraps created by Starter Plan accounts.\
\
To save **test data**, use a TEST API Key. To save **live data**, use a LIVE API Key. A success response will indicate the type of data that was stored.

#### Headers

| Name           | Type   | Description                                                                                                                                                |
| -------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Authentication | string | Basic Auth, API Key and API Secret. To save test data, use a test API Key, to save live data use a live API Key. See Getting Started > API Authentication. |

#### Request Body

| Name            | Type   | Description                                                                                                                                                                                                                                       |
| --------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Unique-User-ID  | string | An email address or other unique identifier for your user.                                                                                                                                                                                        |
| Agreement-ID    | string | This can be found in the Valtt Dashboard, click Agreements on left menu, choose your Agreement, click on the name. At the top of the edit page you will find "Agreement: long-string-agreement-id". The Agreement ID is the part after the colon. |
| User-Agent-Info | string | Specific information about the device that your user is using to agree to the agreement. In a website it is comprised of browser type, browser version, screen height and width, etc.                                                             |
| IP-Address      | string | The IP Address of your user, the IP they used to access your agreement form.                                                                                                                                                                      |
| Form-Location   | string | The location, website URL, or other location information you have about your user when they filled out the agreement form.                                                                                                                        |

{% tabs %}
{% tab title="200 Clickwrap successfully saved." %}

```
{
    "status": "success",
    "unique-user-id": "someone@gmail.com",
    "clickwrap-fingerprint": "2c4ba2bbdj322sdsdf323asa3ls0lad034ldss26b5d22f583ff33712ad4b9dbda",
    "test-data": "n",
    "time_gmt": "2020-07-21 22:49:28"
}
```

{% endtab %}

{% tab title="404 If an error occurred the response will always indicate as below with a specific error message." %}

```
{
    "status": "error",
    "error_message": "Missing or blank required data: Unique User ID.",
    "time_gmt": "2020-07-21 23:17:39"
}
```

{% endtab %}
{% endtabs %}

### Example cURL Request

```
curl --location --request POST 'https://app.valtt.com/api/clickwrap/create/' \
--header 'Authorization: Basic dmtfdGVzdF8xYjFhNGRjODE6OWJmNmU3YTM1ODgyOGQ2YTZiZWUyNWNmMmNmMjBlMjJiZjU2MjQ2ZDAwMmM0ODZiZTE0M2IyYTkwNTU2MmUwMTc4MjI3ODNkNTM1ZjYw' \
--form 'Unique-User-ID=someone@gmail.com' \
--form 'Agreement-ID=4EE12385FBF002722150959733C50176DD33F3584590223332DB27AEFC44DCEF7' \
--form 'User-Agent-Info=Mac;Chrome v17;' \
--form 'IP-Address=127.0.0.1' \
--form 'Form-Location=my-website.com/signup-form'
```


# Change Log

## 1.0.1 - 2020-07-23

### Added

* Ability to save test or live data. Changing the type of API Key changes the type of data stored.

### Changed

* API Key and Secret required in same manner as before. But now, type of key will change type of data stored.

## 1.0.0 - 2020-07-18

### Initial Deployment


