Comment on page
🗂️ Select a Credential Schema
How to use existing credential schemas with Disco.
A schema is central to Verifiable Credentials as it defines the structure and content. Specifically, schemas are are representation of a particular type of Credential. See more details on the credential data model hereverifiable-credentials.
Credential schemas generally have these components:
$id
- the URL where the schema is locateddescription
- a long description of the Credential type that this schema was defined forcredentialSubject
- this section is unique to the Credential and hold the fields relevant for creating a particular Credential type, see detailed examples belowexpirationDate
- the expiration date of the Credential, if applicableissuanceDate
the date and time the Credential was issuedtitle
- the short description of the Credential type A schema enables you to have a consistent structure that can be easily verified by a third-party (ie. data verification)
Schemas per W3C Verifiable Credential spec includes a vast amount of metadata. With that in mind we will be focusing on pieces relevant to most developers -
credentialSubject
. The
credentialSubject
is the entity like person or organization which the credential makes claims about such as their name, age, or contributions. I'm going to use the Membership Schema, found in our Repo, as a Usage example
Curl
Javascript
Organization field Required
1
curl --location 'https://api.disco.xyz/v1/credential' \
2
--header 'Content-Type: application/json' \
3
--header 'Accept: */*' \
4
--header 'Authorization: Bearer <your Disco API key>' \
5
--data '{
6
"issuer": "did:3:123abcexample",
7
"schemaUrl": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
8
"recipientDID": "did:3:456defexample",
9
"subjectData": {
10
"memberId": "123XYZ",
11
"membershipDescription": "Demo membership to showcase Disco API",
12
"membershipLevel": "Permanent",
13
"membershipType": "Developer",
14
"organization": "Disco.xyz"
15
},
16
"expirationDate": ""
17
}'
1
var myHeaders = new Headers();
2
myHeaders.append("Content-Type", "application/json");
3
myHeaders.append("Accept", "*/*");
4
myHeaders.append("Authorization", "Bearer <your Disco API key>");
5
6
var raw = JSON.stringify({
7
"issuer": "did:3:123abcexample",
8
"schemaUrl": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
9
"recipientDID": "did:3:456defexample",
10
"subjectData": {
11
"memberId": "123XYZ",
12
"membershipDescription": "Demo membership to showcase Disco API",
13
"membershipLevel": "Permanent",
14
"membershipType": "Developer",
15
"organization": "Disco.xyz"
16
},
17
"expirationDate": ""
18
});
19
20
var requestOptions = {
21
method: 'POST',
22
headers: myHeaders,
23
body: raw,
24
redirect: 'follow'
25
};
26
27
fetch("https://api.disco.xyz/v1/credential", requestOptions)
28
.then(response => response.text())
29
.then(result => console.log(result))
30
.catch(error => console.log('error', error));
1
{
2
"$id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
3
"$schema": "http://json-schema.org/draft-07/schema#",
4
"description": "General Membership attests that the subject is a member in good standing of the issuing organization or group.",
5
"properties": {
6
"@context": {
7
"anyOf": [
8
{
9
"type": "string"
10
},
11
{
12
"type": "array"
13
},
14
{
15
"type": "object"
16
}
17
]
18
},
19
"credentialSchema": {
20
"properties": {
21
"id": {
22
"format": "uri",
23
"type": "string"
24
},
25
"type": {
26
"type": "string"
27
}
28
},
29
"required": [
30
"id",
31
"type"
32
],
33
"type": "object"
34
},
35
"credentialSubject": {
36
"properties": {
37
"expiration": {
38
"format": "date",
39
"title": "Expiration",
40
"type": "string"
41
},
42
"id": {
43
"format": "uri",
44
"title": "Member DID",
45
"type": "string"
46
},
47
"memberId": {
48
"title": "Member ID",
49
"type": "string"
50
},
51
"membershipDescription": {
52
"title": "Membership Description",
53
"type": "string"
54
},
55
"membershipLevel": {
56
"title": "Membership Level",
57
"type": "string"
58
},
59
"membershipType": {
60
"title": "Membership Type",
61
"type": "string"
62
},
63
"organization": {
64
"title": "Organization Name",
65
"type": "string"
66
}
67
},
68
"required": [
69
"id",
70
"organization"
71
],
72
"type": "object"
73
},
74
"expirationDate": {
75
"format": "date-time",
76
"type": "string"
77
},
78
"id": {
79
"format": "uri",
80
"type": "string"
81
},
82
"issuanceDate": {
83
"format": "date-time",
84
"type": "string"
85
},
86
"issuer": {
87
"anyOf": [
88
{
89
"format": "uri",
90
"type": "string"
91
},
92
{
93
"properties": {
94
"id": {
95
"format": "uri",
96
"type": "string"
97
}
98
},
99
"required": [
100
"id"
101
],
102
"type": "object"
103
}
104
]
105
},
106
"type": {
107
"anyOf": [
108
{
109
"type": "string"
110
},
111
{
112
"items": {
113
"type": "string"
114
},
115
"type": "array"
116
}
117
]
118
}
119
},
120
"required": [
121
"@context",
122
"type",
123
"issuer",
124
"issuanceDate",
125
"credentialSubject"
126
],
127
"title": "Membership Credential",
128
"type": "object"
129
}
1
{
2
...
3
"credentialSubject": { // The Verifiable Credential payload object. This is where all fields pertaining to the specific credential type resides.
4
"properties": {
5
"expiration": { // Standard to the W3C VC protocol - an optional expiration date for the Credential.
6
"format": "date",
7
"title": "Expiration",
8
"type": "string"
9
},
10
"id": ... , // Standard to the W3C VC protocol - a unique credential identifier assigned by the system. As a developer you do NOT include this in API calls for creating your Credential.
11
"memberId": { // Optional and unique to this particular schema - use whatever membership ID you want to refer to - or may be left out if not used.
12
"title": "Member ID",
13
"type": "string"
14
},
15
"membershipDescription": { // Optional and unique to this particular schema - describe what the membership is for to the recipient and verifiers - or may be left out if not used.
16
"title": "Membership Description",
17
"type": "string"
18
},
19
"membershipLevel": { // Optional and unique to this particular schema - if your membership is hierarchical you can use this to indicate the level - or may be left out if not used.
20
"title": "Membership Level",
21
"type": "string"
22
},
23
"membershipType": { // Optional and unique to this particular schema - can be used to describe the membership type issued- or may be left out if not used.
24
"title": "Membership Type",
25
"type": "string"
26
},
27
"organization": { // Required and unique to this particular schema - the name of the organization for which this membership is issued for.
28
"title": "Organization Name",
29
"type": "string"
30
}
31
},
32
"required": [ // Required fields Unique to this particular schema
33
"id", // ALWAYS system generated
34
"organization" // Provided by you, the developer
35
],
36
"type": "object"
37
},
38
...
39
}
As mentioned above, much of this is boilerplate per W3C specification, what is unique to MembershipCredential (and any other schemas for that matter) is in the
credentialSubject
object. Note that the last object, named required
in the credentialSubject
list the fields which must be provided for this particular schema.The payload object to use in API calls for Proof of Mint Credentials - the rest is boilerplate.
1
"credentialSubject": {
2
"properties": {
3
"chain": { // Optional Proof of Mint field for Credential creation
4
"title": "Chain",
5
"type": "string"
6
},
7
"contractAddress": { // Optional Proof of Mint field for Credential creation
8
"title": "Contract address",
9
"type": "string"
10
},
11
"dateOfMint": { // Optional Proof of Mint field for Credential creation
12
"format": "date",
13
"title": "Date of Mint",
14
"type": "string"
15
},
16
"id": { // DO NOT INCLUDE - a unique credential identifier assigned by the system. As a developer you do NOT include this in API calls for creating your Credential.
17
"format": "uri",
18
"title": "Recipient DID",
19
"type": "string"
20
},
21
"tokenStandard": { // Optional Proof of Mint field for Credential creation
22
"title": "Token Standard",
23
"type": "string"
24
}
25
},
26
"required": [ // Note that no Proof of Mint specific fields are required
27
"id"
28
],
29
"type": "object"
30
},
1
{
2
"$id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/ProofOfMintCredential/1-0-0.json",
3
"$schema": "http://json-schema.org/draft-07/schema#",
4
"description": "Proof of Mint proves/recognizes the holder is an original minter of this NFT drop.",
5
"properties": {
6
"@context": {
7
"anyOf": [
8
{
9
"type": "string"
10
},
11
{
12
"type": "array"
13
},
14
{
15
"type": "object"
16
}
17
]
18
},
19
"credentialSchema": {
20
"properties": {
21
"id": {
22
"format": "uri",
23
"type": "string"
24
},
25
"type": {
26
"type": "string"
27
}
28
},
29
"required": [
30
"id",
31
"type"
32
],
33
"type": "object"
34
},
35
"credentialSubject": {
36
"properties": {
37
"chain": {
38
"title": "Chain",
39
"type": "string"
40
},
41
"contractAddress": {
42
"title": "Contract address",
43
"type": "string"
44
},
45
"dateOfMint": {
46
"format": "date",
47
"title": "Date of Mint",
48
"type": "string"
49
},
50
"id": {
51
"format": "uri",
52
"title": "Recipient DID",
53
"type": "string"
54
},
55
"tokenStandard": {
56
"title": "Token Standard",
57
"type": "string"
58
}
59
},
60
"required": [
61
"id"
62
],
63
"type": "object"
64
},
65
"expirationDate": {
66
"format": "date-time",
67
"type": "string"
68
},
69
"id": {
70
"format": "uri",
71
"type": "string"
72
},
73
"issuanceDate": {
74
"format": "date-time",
75
"type": "string"
76
},
77
"issuer": {
78
"anyOf": [
79
{
80
"format": "uri",
81
"type": "string"
82
},
83
{
84
"properties": {
85
"id": {
86
"format": "uri",
87
"type": "string"
88
}
89
},
90
"required": [
91
"id"
92
],
93
"type": "object"
94
}
95
]
96
},
97
"type": {
98
"anyOf": [
99
{
100
"type": "string"
101
},
102
{
103
"items": {
104
"type": "string"
105
},
106
"type": "array"
107
}
108
]
109
}
110
},
111
"required": [
112
"@context",
113
"type",
114
"issuer",
115
"issuanceDate",
116
"credentialSubject"
117
],
118
"title": "Proof of Mint Credential",
119
"type": "object"
120
}
The payload object to use in API calls for Beta User Credentials - the rest is boilerplate.
1
"credentialSubject": {
2
"properties": {
3
"id": {{ // DO NOT INCLUDE - a unique credential identifier assigned by the system. As a developer you do NOT include this in API calls for creating your Credential.
4
"title": "Recipient DID",
5
"type": "string"
6
},
7
"name": { // Optional Beta User field for Credential creation
8
"title": "Name",
9
"type": "string"
10
}
11
},
12
"required": [
13
"id"
14
],
15
"type": "object"
16
},
1
{
2
"$id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/BetaUserCredential/1-0-0.json",
3
"$schema": "http://json-schema.org/draft-07/schema#",
4
"description": "This credential is for our early beta users or testers who are testing our product before official launch. Thank you for your support and coninued patience!",
5
"properties": {
6
"@context": {
7
"anyOf": [
8
{
9
"type": "string"
10
},
11
{
12
"type": "array"
13
},
14
{
15
"type": "object"
16
}
17
]
18
},
19
"credentialSchema": {
20
"properties": {
21
"id": {
22
"format": "uri",
23
"type": "string"
24
},
25
"type": {
26
"type": "string"
27
}
28
},
29
"required": [
30
"id",
31
"type"
32
],
33
"type": "object"
34
},
35
"credentialSubject": {
36
"properties": {
37
"id": {
38
"title": "Recipient DID",
39
"type": "string"
40
},
41
"name": {
42
"title": "Name",
43
"type": "string"
44
}
45
},
46
"required": [
47
"id"
48
],
49
"type": "object"
50
},
51
"expirationDate": {
52
"format": "date-time",
53
"type": "string"
54
},
55
"id": {
56
"format": "uri",
57
"type": "string"
58
},
59
"issuanceDate": {
60
"format": "date-time",
61
"type": "string"
62
},
63
"issuer": {
64
"anyOf": [
65
{
66
"format": "uri",
67
"type": "string"
68
},
69
{
70
"properties": {
71
"id": {
72
"format": "uri",
73
"type": "string"
74
}
75
},
76
"required": [
77
"id"
78
],
79
"type": "object"
80
}
81
]
82
},
83
"type": {
84
"anyOf": [
85
{
86
"type": "string"
87
},
88
{
89
"items": {
90
"type": "string"
91
},
92
"type": "array"
93
}
94
]
95
}
96
},
97
"required": [
98
"@context",
99
"type",
100
"issuer",
101
"issuanceDate",
102
"credentialSubject"
103
],
104
"title": "Beta User Credential",
105
"type": "object"
106
}
The payload object to use in API calls for Contribution Credentials - the rest is boilerplate.
1
"credentialSubject": {
2
"properties": {
3
"category": { // Required enum for Contribution Credential creation
4
"enum": [
5
"Content Creation",
6
"Improved process",
7
"Pull Request",
8
"Reviewed code",
9
"Research",
10
"Discourse",
11
"Financial Contribution",
12
"Other"
13
],
14
"title": "Category",
15
"type": "string"
16
},
17
"description": { // Required field for Contribution Credential creation
18
"title": "Description",
19
"type": "string"
20
},
21
"id": { // DO NOT INCLUDE - a unique credential identifier assigned by the system. As a developer you do NOT include this in API calls for creating your Credential.
22
"title": "Recipient DID",
23
"type": "string"
24
},
25
"name": { // Required field for Contribution Credential creation
26
"title": "Organization Name",
27
"type": "string"
28
},
29
"url": { // Optional field for Contribution Credential creation
30
"title": "Contribution URL",
31
"type": "string"
32
}
33
},
34
"required": [
35
"id",
36
"name",
37
"category",
38
"description"
39
],
40
"type": "object"
41
},
1
{
2
"$id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/ContributionCredential/1-0-0.json",
3
"$schema": "http://json-schema.org/draft-07/schema#",
4
"description": "Enables you to capture and contextualize contributions made by a person",
5
"properties": {
6
"@context": {
7
"anyOf": [
8
{
9
"type": "string"
10
},
11
{
12
"type": "array"
13
},
14
{
15
"type": "object"
16
}
17
]
18
},
19
"credentialSchema": {
20
"properties": {
21
"id": {
22
"format": "uri",
23
"type": "string"
24
},
25
"type": {
26
"type": "string"
27
}
28
},
29
"required": [
30
"id",
31
"type"
32
],
33
"type": "object"
34
},
35
"credentialSubject": {
36
"properties": {
37
"category": {
38
"enum": [
39
"Content Creation",
40
"Improved process",
41
"Pull Request",
42
"Reviewed code",
43
"Research",
44
"Discourse",
45
"Financial Contribution",
46
"Other"
47
],
48
"title": "Category",
49
"type": "string"
50
},
51
"description": {
52
"title": "Description",
53
"type": "string"
54
},
55
"id": {
56
"title": "Recipient DID",
57
"type": "string"
58
},
59
"name": {
60
"title": "Organization Name",
61
"type": "string"
62
},
63
"url": {
64
"title": "Contribution URL",
65
"type": "string"
66
}
67
},
68
"required": [
69
"id",
70
"name",
71
"category",
72
"description"
73
],
74
"type": "object"
75
},
76
"expirationDate": {
77
"format": "date-time",
78
"type": "string"
79
},
80
"id": {
81
"format": "uri",
82
"type": "string"
83
},
84
"issuanceDate": {
85
"format": "date-time",
86
"type": "string"
87
},
88
"issuer": {
89
"anyOf": [
90
{
91
"format": "uri",
92
"type": "string"
93
},
94
{
95
"properties": {
96
"id": {
97
"format": "uri",
98
"type": "string"
99
}
100
},
101
"required": [
102
"id"
103
],
104
"type": "object"
105
}
106
]
107
},
108
"type": {
109
"anyOf": [
110
{
111
"type": "string"
112
},
113
{
114
"items": {
115
"type": "string"
116
},
117
"type": "array"
118
}
119
]
120
}
121
},
122
"required": [
123
"@context",
124
"type",
125
"issuer",
126
"issuanceDate",
127
"credentialSubject"
128
],
129
"title": "Contribution Credential",
130
"type": "object"
131
}
The payload object to use in API calls for Snaps Credentials - the rest is boilerplate.
1
"credentialSubject": {
2
"properties": {
3
"id": { // DO NOT INCLUDE - a unique credential identifier assigned by the system. As a developer you do NOT include this in API calls for creating your Credential.
4
"title": "Recipient DID",
5
"type": "string"
6
},
7
"snapsType": { // Required enum for Snaps Credential creation
8
"enum": [
9
"Immaculate Vibes: Thank you for your awesome energy",
10
"Problem Solver: Thank you for working with me to solve a tough challenge together",
11
"Miracle Worker: Thank you for unexpectedly and proactively doing something awesome that impacted my day for the better!"
12
],
13
"title": "Snaps Type",
14
"type": "string"
15
}
16
},
17
"required": [
18
"id",
19
"snapsType"
20
],
21
"type": "object"
22
},
1
{
2
"$id": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/SnapsCredential/1-0-0.json",
3
"$schema": "http://json-schema.org/draft-07/schema#",
4
"description": "Send snaps to celebrate a friend or colleague doing something positive and helpful.",
5
"properties": {
6
"@context": {
7
"anyOf": [
8
{
9
"type": "string"
10
},
11
{
12
"type": "array"
13
},
14
{
15
"type": "object"
16
}
17
]
18
},
19
"credentialSchema": {
20
"properties": {
21
"id": {
22
"format": "uri",
23
"type": "string"
24
},
25
"type": {
26
"type": "string"
27
}
28
},
29
"required": [
30
"id",
31
"type"
32
],
33
"type": "object"
34
},
35
"credentialSubject": {
36
"properties": {
37
"id": {
38
"title": "Recipient DID",
39
"type": "string"
40
},
41
"snapsType": {
42
"enum": [
43
"Immaculate Vibes: Thank you for your awesome energy",
44
"Problem Solver: Thank you for working with me to solve a tough challenge together",
45
"Miracle Worker: Thank you for unexpectedly and proactively doing something awesome that impacted my day for the better!"
46
],
47
"title": "Snaps Type",
48
"type": "string"
49
}
50
},
51
"required": [
52
"id",
53
"snapsType"
54
],
55
"type": "object"
56
},
57
"expirationDate": {
58
"format": "date-time",
59
"type": "string"
60
},
61
"id": {
62
"format": "uri",
63
"type": "string"
64
},
65
"issuanceDate": {
66
"format": "date-time",
67
"type": "string"
68
},
69
"issuer": {
70
"anyOf": [
71
{
72
"format": "uri",
73
"type": "string"
74
},
75
{
76
"properties": {
77
"id": {
78
"format": "uri",
79
"type": "string"
80
}
81
},
82
"required": [
83
"id"
84
],
85
"type": "object"
86
}
87
]
88
},
89
"type": {
90
"anyOf": [
91
{
92
"type": "string"
93
},
94
{
95
"items": {
96
"type": "string"
97
},
98
"type": "array"
99
}
100
]
101
}
102
},
103
"required": [
104
"@context",
105
"type",
106
"issuer",
107
"issuanceDate",
108
"credentialSubject"
109
],
110
"title": "Snaps Credential",
111
"type": "object"
112
}