# Making Requests

## Create a Certificate Authority

```javascript
const payload = {
    wa : "wallet_address", 
    admin_email : "admin_email" 
}

createCA(payload)
  .then(response => console.log('CA Created:', response))
  .catch(error => console.error('Error creating CA:', error));
```

**Payload elements**

| Name          | Type   | Description                                   |
| ------------- | ------ | --------------------------------------------- |
| `wa`          | string | wallet address                                |
| `admin_email` | string | registered email address of the account admin |

## Create Certificate Templates

```javascript
const payload = {
  cid: 'cid_value', 
  name: 'template_name',
  waAdmin: 'waAdmin_value', 
  frontendProps: {
    components: [
      {
        id: 'component_id'
        ...
        type: 'text',
      }
    ],
    currentLayout: 'current_layout'
  }
}

createTemplate(payload)
  .then(response => console.log('Template Created:', response))
  .catch(error => console.error('Error creating template:', error));
```

**Payload Elements**

| Name            | Type   | Description                                                                                                         |
| --------------- | ------ | ------------------------------------------------------------------------------------------------------------------- |
| `cid`           | string | CA identifier                                                                                                       |
| `name`          | string | Name of the Template                                                                                                |
| `wa`            | string | CA wallet address                                                                                                   |
| `frontendProps` | object | frontend elements and attributes of the certificate schema. Contains `components` object and `current_layout` array |
| `components`    | object | contains all the visual and atribute elements of the certificate                                                    |
| `CurrentLayout` | string | type of certificate visual format (card, badge, vertical A4, horizontal H4)                                         |

**Component Object Elements**

| Name            | Type                     | Description |
| --------------- | ------------------------ | ----------- |
| `id`            | string                   |             |
| `type`          | string                   |             |
| `inputType`     | string                   |             |
| `content`       | string                   |             |
| `styles`        | object                   |             |
| `className`     | string                   |             |
| `placeholder`   | string                   |             |
| `src`           | string                   |             |
| `text`          | string                   |             |
| `name`          | string                   |             |
| `value`         | string                   |             |
| `isActive`      | boolean                  |             |
| `isDraggable`   | boolean                  |             |
| `x`             | number                   |             |
| `y`             | number                   |             |
| `baseText`      | (string \| undefined)\[] |             |
| `originalText`  | string                   |             |
| `maxCharacters` | string                   |             |
| `minCharacters` | string                   |             |
| `isMandatory`   | boolean                  |             |

**Styles Object Elements:**

<table><thead><tr><th width="249">Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>width</code></td><td>string</td><td></td></tr><tr><td><code>height</code></td><td>string</td><td></td></tr><tr><td><code>color</code></td><td>string</td><td></td></tr><tr><td><code>backgroundColor</code></td><td>string</td><td></td></tr><tr><td><code>fontSize</code></td><td>string | number</td><td></td></tr><tr><td><code>fontWeight</code></td><td>string</td><td></td></tr><tr><td><code>textAlign</code></td><td>string</td><td></td></tr><tr><td><code>fontFamily</code></td><td>string</td><td></td></tr><tr><td><code>isItalic</code></td><td>boolean</td><td></td></tr><tr><td><code>isBold</code></td><td>boolean</td><td></td></tr><tr><td><code>isUnderlined</code></td><td>boolean</td><td></td></tr><tr><td><code>letterSpacing</code></td><td>string</td><td></td></tr><tr><td><code>previousWidth</code></td><td>number</td><td></td></tr><tr><td><code>warp</code></td><td>number</td><td></td></tr><tr><td><code>cursor</code></td><td>string</td><td></td></tr></tbody></table>

## Issue Certificates

```javascript
const payload = {
  cid: 'cid_value', 
  tid: 'tid_value', 
  waAdmin: 'waAdmin_value', 
  data: [{ key: 'value' }], 
  email: 'user@domain.com', 
};
createCredentials(payload)
  .then(response => console.log('Credentials Created:', response))
  .catch(error => console.error('Error creating credentials:', error));
```

**Payload Elements**

| Name      | Type       | Description                                                                                       |
| --------- | ---------- | ------------------------------------------------------------------------------------------------- |
| `cid`     | string     | CA identifier                                                                                     |
| `tid`     | string     | Template identifier                                                                               |
| `waAdmin` | string     | CA wallet address                                                                                 |
| `data`    | dictionary | object with data to be stored in the credential (in the format of a list of "key": "value" pairs) |
| `email`   | string     | recipient person email address                                                                    |

## Verify Certificates

```javascript
const payload = {
  tid: 'tid_value', 
  id: 'id_value', 
  guid: 'guid_value', 
};

verifyCredentials(payload)
  .then(response => console.log('Verification URL:', response))
  .catch(error => console.error('Error verifying credentials:', error));
```

**Payload Body**

| Name   | Type   | Description                                                                         |
| ------ | ------ | ----------------------------------------------------------------------------------- |
| `id`   | string | Certificate identifier                                                              |
| `tid`  | string | Template identifier                                                                 |
| `guid` | string | a unique identifier for the verification session and is returned in the init method |
