Skip to main content

POST /vc-templates

Create a new Verifiable Credential Template.

{{baseUrl}}/vc-templates

Headers

HeaderTypeDescription
x-api-keystringThe API key required for authentication.

Request Body Parameters

ParameterTypeDescription
templateNamestringThe name of the template (e.g., "DegreeSample").
descriptionstringA description of the template.
issuerstringThe DID of the issuer authorized to issue credentials.
attributesarrayAn array of attributes that define the credential.
attributeNamestringThe name of each attribute (e.g., "degree").
typestringThe data type of each attribute (e.g., "string").
expirationobjectThe expiration settings of the credential template.
expiration.valuenumberThe number of units for expiration (e.g., 5).
expiration.unitstringThe unit of time for expiration (e.g., "years").

Sample Request Body:

{
"templateName": "DegreeSample",
"description": "Schema for degree certificate template",
"issuer": "did:earthid:testnet:7QFmnthxqyJVmdBC8WbMtVrfEfenMbVAw3JWYC4kmkYu",
"attributes": [
{
"attributeName": "degree",
"type": "string",
"description": "Degree Name"
},
{
"attributeName": "dateOfBirth",
"type": "string",
"description": "Date of Birth"
},
{
"attributeName": "city",
"type": "string",
"description": "City of University"
}
],
"expiration": {
"value": 5,
"unit": "years"
}
}

Click Send and wait for the response.

Response (Success - 201)

ParameterTypeDescription
templateIdstringThe unique identifier for the Verifiable Credential template.
namestringThe name of the Verifiable Credential template.
descriptionstringA description of the Verifiable Credential template.
contextarrayAn array that defines the JSON-LD context for the template.
typearrayThe type of Verifiable Credential.
issuerstringThe DID of the issuer authorized to issue the credential.
issuanceDatestringThe date when the credential was issued.
expirationDatestringThe date when the credential expires.
credentialSubjectarrayAn array of attributes that define the credential subject.
_idstringThe unique ID of the template in the system.
__vnumberThe version key for the document.

Sample Response Body:

{
"templateId": "a752d4e1-7279-44f1-baa9-cce36995ad7e",
"name": "DegreeSample",
"description": "Schema for degree certificate template",
"context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential",
"DegreeSample"
],
"issuer": "did:earthid:testnet:7QFmnthxqyJVmdBC8WbMtVrfEfenMbVAw3JWYC4kmkYu",
"issuanceDate": "2024-10-19T07:22:43.740Z",
"expirationDate": "2029-10-19T07:22:43.740Z",
"credentialSubject": [
{
"attributeName": "degree",
"type": "string",
"description": "Degree Name"
},
{
"attributeName": "dateOfBirth",
"type": "string",
"description": "Date of Birth"
},
{
"attributeName": "city",
"type": "string",
"description": "City of University"
}
],
"_id": "67135e43904a633605cca093",
"__v": 0
}

Response (Server Error - 500)

ParameterTypeDescription
errorstringDescribes the error that occurred.

Sample Response Body:

{
"error": "Server error"
}