# API Reference

## Create a Certificate Authority

Creates a Certificate Authority (CA) identifier (DID) and a new wallet address.

<mark style="color:green;">`POST`</mark> '<https://demo.eidcmp.wallid.io/api/v1/ca/&#x20>;

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Request Body**

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

**Example Request**

```javascript
{
    wa : "0x12b...bcD, 
    admin_email : "alice@example.com" 
}
```

**Example Response**

```javascript
{
  "message": {
      "name": "CA Name",
      "admin_email": "test@test.io",
      "creatorWA": "0x4289128eb6e3b298140845364fbec0f7344ffe8b",
      "contract_address": "0x99999999",
      "admin": [
          "0x4289128eb6e3b298140845364fbec0f7344ffe8b"
      ],
      "issuerKey": {
          "type": "jwk",
          "jwk": {
              "kty": "OKP",
              "d": "Ho_2n9eidSDnKwKrw3pfxl_QYvBf-iLcIysR3ttsDlE",
              "crv": "Ed25519",
              "kid": "nDVD3o4MUzwPddZim_AQIkybSo3gc9pPsS06Ff3A0xU",
              "x": "slQ0XLMtyvETG9GDZz_89ytjspNRsn7fNBcWvtWRsS8"
          }
      },
      "issuerDid": "did:jwk:eyJrdHkiOiJPS1AiLCJjcnYiOiJFZDI1NTE5Iiwia2lkIjoibkRWRDNvNE1VendQZGRaaW1fQVFJa3liU28zZ2M5cFBzUzA2RmYzQTB4VSIsIngiOiJzbFEwWExNdHl2RVRHOUdEWnpfODl5dGpzcE5Sc243Zk5CY1d2dFdSc1M4In0",
      "_id": "670fb05a77d3b449d9e3b69f",
      "code": "0x172fde1d5fd586411af4939b776693e93235b1791d17a5d9d935c3886183b16d",
      "createdAt": "2024-10-16T12:23:54.517Z",
      "updatedAt": "2024-10-16T12:23:54.517Z",
      "cid": "670fb05a77d3b449d9e3b69f",
      "id": "670fb05a77d3b449d9e3b69f"
  }
}
```

## Create a Template

Creates a Certificate template as achema with fixed attributes and corresponding dynamic attestations.

<mark style="color:green;">`POST`</mark> '<https://demo.eidcmp.wallid.io/api/v1/template/&#x20>;

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Request Body**

| 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)                                         |

**Example Request**

```javascript
{
  cid: 'cid_value', 
  name: 'template_name',
  waAdmin: 'waAdmin_value', 
  frontendProps: {
    components: [
      {
        id: 'component_id'
        type: string
        inputType: string
        content: string
        styles: [TemplateElementStyles]
        className: string
        placeholder: string
        src: string
        text: string
        name: string
        value: string
        isActive: boolean
        isDraggable: boolean
        isEditable: boolean
        x: number
        y: number
        baseText: (string | undefined)[]
        originalText: string
        maxCharacters: string
        minCharacters: string
        isMandatory: boolean
      }
    ],
    currentLayout: '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>

**Example Response**

```javascript
{
    "cid": "66fd767cbd536ca460f33be4",
    "name": "Card",
    "creatorWa": "0x4289128eb6e3b298140845364fbec0f7344ffe8b",
    "frontendProps": {
        "name": "Card",
        "repeatedAttributes": false,
        "currentLayout": "Card",
        "design": "Card",
    },
    "lang": "en",
    "template_chain": {
        "sig": []
    },
    "status": "active",
    "admin": [
        "0x4289128eb6e3b298140845364fbec0f7344ffe8b"
    ],
    "tid": "670fb92e77d3b449d9e3b6fe"
}
```

## Other Template Related Requests

#### Get Template

Returns the certificate template json file

<mark style="color:orange;">`GET`</mark> '<https://demo.eidcmp.wallid.io/api/v1/template/:tid>

#### Get Template File

Returns a the certificate template file in the specified file format (eg. .csv or .xls)

<mark style="color:orange;">`GET`</mark> '<https://demo.eidcmp.wallid.io/api/v1/template/:tid/download/:fileFormat>

#### Delete Template

Deletes Template from the API

<mark style="color:red;">`DELETE`</mark> '<https://demo.eidcmp.wallid.io/api/v1/template/:tid>

## Issue Certificates

Issues new certificate to and sends it to the a recipient email address.

<mark style="color:green;">`POST`</mark> '<https://demo.eidcmp.wallid.io/api/v1/credential/create&#x20>;

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Request Body**

| 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                                                                    |

**Example Request**

```javascript
{
   "cid": "cid_value", // Certificate Authority (CA) id
   "tid": "tid_value", // Template id
   "waAdmin": "waAdmin_value", // wallet address of the admin creating the credential
   "data": [{ "key": "value" }], // data to be stored in the credential (in the format of a list of key value pairs)
   "email": "user@domain.com",
}
```

**Example Response**

```javascript
{
 "data": {
     "mgs": "The invite 670fb0d577d3b449d9e3b6a7 was sent!",
     "inviteId": "670fb0d577d3b449d9e3b6a7"
 },
 "credentialUrl": "openid-credential-offer://issuer.portal.walt.id/?credential_offer_uri=https%3A%2F%2Fissuer.portal.walt.id%2Fopenid4vc%2FcredentialOffer%3Fid%3Dc4d7f3f6-a8fb-4f89-8ca7-c2e9932dc3e4"
}
```

## Verify Certificates

Creates a verification URL to get and display certificate and verification data.

<mark style="color:green;">`POST`</mark> '<https://demo.eidcmp.wallid.io/api/v1/credential/create-verify-url>

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Request 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 |

**Example Request**

```javascript
{
   "id": "id_value", 
   "tid": "tid_value", 
   "guid": "guid_value",
}
```

**Example Response**

```javascript
{
 "verificationUrl": "openid4vp://authorize?response_type=vp_token&client_id=https%3A%2F%2Fverifier.portal.walt.id%2Fopenid4vc%2Fverify&response_mode=direct_post&state=ClJIRQQu8FBr&presentation_definition_uri=https%3A%2F%2Fverifier.portal.walt.id%2Fopenid4vc%2Fpd%2FClJIRQQu8FBr&client_id_scheme=redirect_uri&client_metadata=%7B%22authorization_encrypted_response_alg%22%3A%22ECDH-ES%22%2C%22authorization_encrypted_response_enc%22%3A%22A256GCM%22%7D&nonce=f9ce4c7d-2804-4804-bc21-6e1fe199da60&response_uri=https%3A%2F%2Fverifier.portal.walt.id%2Fopenid4vc%2Fverify%2FClJIRQQu8FBr"
}
```

## Other Verification Related Requests

#### Redirect Verification Session

Triggers socket io event in the Verify page session

<mark style="color:orange;">`GET`</mark> '<https://demo.eidcmp.wallid.io/api/v1/credential/redirect/:sessionId>

#### Get Certificate data

Gets certificate data for the session in the OIDC format

<mark style="color:orange;">`GET`</mark> '<https://demo.eidcmp.wallid.io/api/v1/credential/data/:sessionId>


---

# 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://docs.wallid.io/api-reference.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.
