Programmatic Issuance
Describes how to issue a credential programmatically, via the API
You will need:
- any HTTP library, curl, or Postman
- the schema URL to issue
- fields and descriptions for your schemas to issue.
Determine your schema you'd like to issue by visiting our schemas repo (If you'd like a custom schema not here already, please reach out to us).
Save this link, you'll need to reference this later.
Remember that we use Bearer Auth. This should be in the Auth header as follows:
Authorization: Bearer <your-token-here>
post
https://api.disco.xyz/v1/credential
Generate and return a signed credential programmatically.
Here are some example code snippets:
curl --location 'http://api.disco.xyz/v1/credential/' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <redacted>' \
--data '{
"schemaUrl": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"subjectData":{},
"recipientDID":"did:3:kjzl6cwe1jw147pkworv5ff70zkwjne15b4ww4xwyof4cdgvgsw8xl1srg287wj"
}'
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer <redacted>");
var raw = JSON.stringify({
"schemaUrl": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"subjectData": {},
"recipientDID": "did:3:kjzl6cwe1jw147pkworv5ff70zkwjne15b4ww4xwyof4cdgvgsw8xl1srg287wj"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("http://api.disco.xyz/v1/credential/", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
```
{
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential",
"GmCredential"
],
"issuer": {
"id": "did:3:kjzl6cwe1jw145l0eotzxw28znn1zcis2khwa1rf56ss5a8e55ffhqht25fmk66"
},
"issuanceDate": "2023-05-08T15:54:56.431Z",
"id": "did:3:kjzl6cwe1jw145l0eotzxw28znn1zcis2khwa1rf56ss5a8e55ffhqht25fmk66#fe0b5bab-a850-40ac-a5bc-46d779feda41",
"credentialSubject": {
"id": "did:3:kjzl6cwe1jw147pkworv5ff70zkwjne15b4ww4xwyof4cdgvgsw8xl1srg287wj"
},
"credentialSchema": {
"id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"type": "JsonSchemaValidator2018"
},
"proof": {
"verificationMethod": "did:3:kjzl6cwe1jw145l0eotzxw28znn1zcis2khwa1rf56ss5a8e55ffhqht25fmk66#controller",
"created": "2023-05-08T15:54:56.538Z",
"proofPurpose": "assertionMethod",
"type": "EthereumEip712Signature2021",
"proofValue": "0x8808c6ed2f471e2d8bfbde026ce787e39b638959e9174b88d8a14d9742fe3840079345cea7c120c71f3b50689806f9c4ab25d5bbc2722018f35ba9d22b913a551c",
"eip712Domain": {
"domain": {
"chainId": 1,
"name": "Disco Verifiable Credential",
"version": "1"
},
"messageSchema": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
}
],
"Proof": [
{
"name": "created",
"type": "string"
},
{
"name": "proofPurpose",
"type": "string"
},
{
"name": "type",
"type": "string"
},
{
"name": "verificationMethod",
"type": "string"
}
],
"Issuer": [
{
"name": "id",
"type": "string"
}
],
"CredentialSubject": [
{
"name": "id",
"type": "string"
}
],
"VerifiableCredential": [
{
"name": "@context",
"type": "string[]"
},
{
"name": "credentialSubject",
"type": "CredentialSubject"
},
{
"name": "id",
"type": "string"
},
{
"name": "issuanceDate",
"type": "string"
},
{
"name": "issuer",
"type": "Issuer"
},
{
"name": "proof",
"type": "Proof"
},
{
"name": "type",
"type": "string[]"
}
]
},
"primaryType": "VerifiableCredential"
}
}
}
Last modified 2mo ago