# Create Verifiable Credentials

This creates a verifiable credentails using following method. The weightage for this API is 10

## API Specification

## Create Verifiable Credentials

<mark style="color:green;">`POST`</mark> `https://api.krypcore.com/api/v0/did/createVC`

Creates a new Verifiable Credentials under the given instance.&#x20;

#### Headers

| Name                                            | Type   | Description                      |
| ----------------------------------------------- | ------ | -------------------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | User Auth Key obtained from Dash |
| DappId<mark style="color:red;">\*</mark>        | String | DappId                           |

#### Request Body

| Name                                         | Type   | Description    |
| -------------------------------------------- | ------ | -------------- |
| subjectDid<mark style="color:red;">\*</mark> | String | Subject DID    |
| issuerDid<mark style="color:red;">\*</mark>  | String | Issuer DID     |
| proofType<mark style="color:red;">\*</mark>  | String | Type Of proof  |
| statusType<mark style="color:red;">\*</mark> | String | Type Of status |
| templateId<mark style="color:red;">\*</mark> | String | template id    |

{% tabs %}
{% tab title="200: OK Verifiable Credential successfully created" %}

```javascript
{
    "Data": {
        "@context": ["https://www.w3.org/2018/credentials/v1", "https://w3id.org/security/suites/jws-2020/v1"],
        "config": {
            "issuerDid": "did:key:z6MkhNjTaHAmf1fx9JuWXHUqGU7k4tX6RKCHkvHnXdrxZqGa",
            "proofType": "LD_PROOF",
            "statusType": "StatusList2021Entry",
            "subjectDid": "did:key:z6MkjcRg1BFymuFVcZdHp2f7m6ZchZsqhGVQXnQckucCAACQ"
        },
        "credentialData": {},
        "credentialStatus": {
            "id": "http://127.0.0.1:7001/v1/credentials/status/revocation#1",
            "statusListCredential": "http://127.0.0.1:7001/v1/credentials/status/revocation",
            "statusListIndex": "1",
            "statusPurpose": "revocation",
            "type": "StatusList2021Entry"
        },
        "credentialSubject": {
            "additionalProp1": {},
            "id": "did:key:z6MkjcRg1BFymuFVcZdHp2f7m6ZchZsqhGVQXnQckucCAACQ"
        },
        "id": "urn:uuid:3d58a9a7-cd75-4e1b-90c9-97da654daf9d",
        "issuanceDate": "2023-09-21T07:11:47Z",
        "issued": "2023-09-21T07:11:47Z",
        "issuer": "did:key:z6MkhNjTaHAmf1fx9JuWXHUqGU7k4tX6RKCHkvHnXdrxZqGa",
        "proof": {
            "created": "2023-09-21T07:11:47Z",
            "creator": "did:key:z6MkhNjTaHAmf1fx9JuWXHUqGU7k4tX6RKCHkvHnXdrxZqGa",
            "jws": "eyJiNjQiOmZhbHNlLCJjcml0IjpbImI2NCJdLCJhbGciOiJFZERTQSJ9..SZbcEn7l_UyX9PPai3RcedNuwu4xOTWnJxvuK0obSr-jeWp-8PumgeMlxhajgjPJol3XN8In3qH8aOmn2nQwBg",
            "type": "JsonWebSignature2020",
            "verificationMethod": "did:key:z6MkhNjTaHAmf1fx9JuWXHUqGU7k4tX6RKCHkvHnXdrxZqGa#z6MkhNjTaHAmf1fx9JuWXHUqGU7k4tX6RKCHkvHnXdrxZqGa"
        },
        "templateId": "PermanentResidentCard",
        "type": ["VerifiableCredential"],
        "validFrom": "2023-09-21T07:11:47Z"
    },
    "Message": "VC Created",
    "Status": "SUCCESS"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Wrong TemplateID" %}

```javascript
{
    "Data": null,
    "Message": "Invalid Template Id",
    "Status": "FAILURE"
}
```

{% endtab %}

{% tab title="500: Internal Server Error mandatory params missing" %}

```javascript
{
    "Data": null,
    "Message": "mandatory params missing",
    "Status": "FAILURE"
}
```

{% endtab %}
{% endtabs %}

Take a look at how you might call this method using our official libraries, or via `curl`:

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

```bash
curl --location --request POST 'https://api.krypcore.com/api/v0/did/createVC' \
--header 'Authorization: xxxxxxxxxxx' \
--header 'DappId: xxxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
  "config": {
    "issuerDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n",
    "proofType": "LD_PROOF",
    "statusType": "StatusList2021Entry",
    "subjectDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n"
  },
  "credentialData": {
    "credentialSubject": {
      "additionalProp1": {}
    }
  },
  "templateId": "VerifiableId"
}'
```

{% endtab %}

{% tab title="Node.js (Fetch)" %}

```javascript
var axios = require('axios');
var data = JSON.stringify({
  "config": {
    "issuerDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n",
    "proofType": "LD_PROOF",
    "statusType": "StatusList2021Entry",
    "subjectDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n"
  },
  "credentialData": {
    "credentialSubject": {
      "additionalProp1": {}
    }
  },
  "templateId": "VerifiableId"
});

var config = {
  method: 'post',
  url: 'https://api.krypcore.com/api/v0/did/createVC',
  headers: { 
    'Authorization': 'xxxxxxxxxxx', 
    'DappId': 'xxxxxxxxxxx', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python " %}

```python
import requests
import json

url = "https://api.krypcore.com/api/v0/did/createVC"

payload = json.dumps({
  "config": {
    "issuerDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n",
    "proofType": "LD_PROOF",
    "statusType": "StatusList2021Entry",
    "subjectDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n"
  },
  "credentialData": {
    "credentialSubject": {
      "additionalProp1": {}
    }
  },
  "templateId": "VerifiableId"
})
headers = {
  'Authorization': 'xxxxxxxxxxx',
  'DappId': 'xxxxxxxxxxx',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://api.krypcore.com/api/v0/did/createVC"
  method := "POST"

  payload := strings.NewReader(`{
  "config": {
    "issuerDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n",
    "proofType": "LD_PROOF",
    "statusType": "StatusList2021Entry",
    "subjectDid": "did:key:z6MkqXwdB44PL2W5xHABsMR5MeXFq2Z2xhdBoT2VuvDdow3n"
  },
  "credentialData": {
    "credentialSubject": {
      "additionalProp1": {}
    }
  },
  "templateId": "VerifiableId"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Authorization", "xxxxxxxxxxx")
  req.Header.Add("DappId", "xxxxxxxxxxx")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}
