Disco Docs - outdated
Ask or search…
K

🔨 Build & Issue Credentials

Construct, and then Issue (Sign and Store) Credentials

Process Flow for Issuance

Process Flow

Disco's API End-point

GET/POST
Host: https://api.disco.xyz/v1/<API>
Authorization: Bearer <your API key>

Single Credential Issuance

post
/v1/credential
Programmatically issue one verifiable credential

Generate and return a signed Credential. This will also write the Credential the recipient's data backpack in Disco's Verifiable Data Registry. The JSON body should contain required Credential values for the schema type used. Available schemas and their specifications can be found at https://github.com/discoxyz/disco-schemas.

Parameters
No parameters
Body
Example
Schema
{
"schemaUrl": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
"recipientDID": "did:3:Example987xyz",
"subjectData": "{\n \"memberId\": \"Goldstar Member\",\n \"membershipDescription\": \"Demo membership to showcase Disco API\",\n \"membershipLevel\": \"Permanent\",\n \"membershipType\": \"Developer\",\n \"organization\": \"Disco.xyz\"\n }",
"expirationDate": "",
"suite": "",
"issuer": "did:web:api.disco.xyz/v1/disco",
"skipSign": "false"
}
Responses
200: OK
Success
401: Unauthorized
Unauthorized
500: Internal Server Error
Credential not created function captureStackTrace() { [native code] }

Usage example

Curl
JavaScript
curl --location 'https://api.disco.xyz/v1/credential' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Authorization: Bearer <your Disco API key>' \
--data '{
"issuer": "did:3:123abcexample",
"schemaUrl": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
"recipientDID": "did:3:456defexample",
"subjectData": {
"memberId": "123XYZ",
"membershipDescription": "Demo membership to showcase Disco API",
"membershipLevel": "Permanent",
"membershipType": "Developer",
"organization": "Disco.xyz"
},
"expirationDate": ""
}'
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "*/*");
myHeaders.append("Authorization", "Bearer <your Disco API key>");
var raw = JSON.stringify({
"issuer": "did:3:123abcexample",
"schemaUrl": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
"recipientDID": "did:3:456defexample",
"subjectData": {
"memberId": "123XYZ",
"membershipDescription": "Demo membership to showcase Disco API",
"membershipLevel": "Permanent",
"membershipType": "Developer",
"organization": "Disco.xyz"
},
"expirationDate": ""
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.disco.xyz/v1/credential", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Successful Response

{
"vc": {
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential",
"MembershipCredential"
],
"issuer": {
"id": "did:3:123abcexample"
},
"issuanceDate": "2023-10-10T12:53:15.718Z",
"id": "https://api.disco.xyz/credential/5c7cca5e-56ab-4e08-87f6-817e9f89f507",
"credentialSubject": {
"id": "did:3:456defexample",
"memberId": "123XYZ",
"membershipDescription": "Demo membership to showcase Disco API",
"membershipLevel": "Permanent",
"membershipType": "Developer",
"organization": "Disco.xyz"
},
"credentialSchema": {
"id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
"type": "JsonSchemaValidator2018"
},
"proof": {
"verificationMethod": "did:3:kjzl6cwe1jw14a7u9sx3thx9gg9uh7u5tqjkzcnr5pi5zzkap7kiztgsfhzayzt#controller",
"created": "2023-10-10T12:53:15.745Z",
"proofPurpose": "assertionMethod",
"type": "EthereumEip712Signature2021",
"proofValue": "0x487aa8ad7c90aa34a108b52cd7e23c5ef6cf9cfbdc01d7741d70d6b8f79763dc65df429e558af4c2d7a54c7f4040cf874ecffa95f17d87d8dc07823b23324bfe1b",
"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"
},
{
"name": "organization",
"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"
}
}
},
"isPublic": false,
"issuer": "did:3:123abcexample",
"recipient": "did:3:456defexample",
"subject": "did:3:456defexample",
"schema": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
"isDeleted": false,
"genId": "a4282add-ed1f-429d-a80d-abdd675b2eef",
"updatedAt": "2023-10-10T12:53:15.748Z",
"history": [],
"_id": "6525493bb8ffec6244182e03"
}

Batch Credential Issuance

post
/v1/credentials
Programmatically issue multiple Verifiable Credentials, aka batch issuance

Generate and return multiple signed Credentials. This will also write the Credentials to the recipient's data backpacks in Disco's Verifiable Data Registry. The JSON body should contain required Credentials and their values for the schema type used. Available schemas and their specifications can be found at https://github.com/discoxyz/disco-schemas.

Parameters
No parameters
Body
Example
Schema
{
"issuer": "did:web:api.disco.xyz/v1/disco",
"schema": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"suite": "jwt",
"subjects": "[\n { \"subject\": { \"id\": \"did:3:abc123\" },\n \"recipient\": \"did:3:abc123\",\n \"expirationDate\": \"\" }\n ]"
}
Responses
200: OK
Returns and store a collection of Verifiable Credential Documents
400: Bad Request
Bad Request

Usage example

Curl
JavaScript
curl --location 'https://api.disco.xyz/v1/credentials' \
--header 'Content-Type: application/json' \
--header 'Accept: */*' \
--header 'Authorization: Bearer <your Disco API key>' \
--data '{
"issuer": "did:3:123abcexample",
"schema": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"suite": "jwt",
"subjects": [
{
"subject": {
"id": "did:3:456defexample"
},
"recipient": "did:3:456defexample",
"expirationDate": ""
},
{
"subject": {
"id": "did:3:789ghiexample"
},
"recipient": "789ghiexample",
"expirationDate": ""
}
]
}'
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "*/*");
myHeaders.append("Authorization", "Bearer <your Disco API key>");
var raw = JSON.stringify({
"issuer": "did:3:123abcexample",
"schema": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"suite": "jwt",
"subjects": [
{
"subject": {
"id": "did:3:456defexample"
},
"recipient": "did:3:456defexample",
"expirationDate": ""
},
{
"subject": {
"id": "did:3:789ghiexample"
},
"recipient": "did:3:789ghiexample",
"expirationDate": ""
}
]
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.disco.xyz/v1/credentials", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));

Successful Response

[
{
"vc": {
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential",
"GmCredential"
],
"issuer": {
"id": "did:3:123abcexample"
},
"issuanceDate": "2023-10-10T14:11:38.056Z",
"id": "https://api.disco.xyz/credential/9c65e3d4-4232-4129-9681-3004b94ceaa1",
"credentialSubject": {
"id": "did:3:456defexample"
},
"credentialSchema": {
"id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"type": "JsonSchemaValidator2018"
}
},
"isPublic": false,
"issuer": "did:3:123abcexample",
"recipient": "did:3:456defexample",
"subject": "did:3:456defexample",
"schema": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"isDeleted": false,
"genId": "64ca2748-2f19-42c2-9108-b392b9861d8e",
"updatedAt": "2023-10-10T14:11:38.056Z",
"history": [],
"jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2Y ... 3kA7BMNbns6vA",
"_id": "65255b9ab8ffec6244182e04"
},
{
"vc": {
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential",
"GmCredential"
],
"issuer": {
"id": "did:3:123abcexample"
},
"issuanceDate": "2023-10-10T14:11:38.063Z",
"id": "https://api.disco.xyz/credential/28facd33-f7cf-45f9-b1da-da9d08a45f20",
"credentialSubject": {
"id": "did:3:789ghiexample"
},
"credentialSchema": {
"id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"type": "JsonSchemaValidator2018"
}
},
"isPublic": false,
"issuer": "did:3:123abcexample",
"recipient": "did:3:789ghiexample",
"subject": "did:3:789ghiexample",
"schema": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/GMCredential/1-0-0.json",
"isDeleted": false,
"genId": "84748837-7f5d-4b6c-9267-b75a3155c145",
"updatedAt": "2023-10-10T14:11:38.063Z",
"history": [],
"jwt": "eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1 ... EVVcpKy4Hrrx-3_jcnzteLqFPIO7xA",
"_id": "65255b9ab8ffec6244182e05"
}
]