Disco Docs
DiscoDashboardGithubDiscordIRLCampaigns
  • Welcome
    • โšชWelcome to Disco
      • ๐ŸŽ’Data Backpacks
      • ๐ŸงฑAbout DIDs and VCs
      • โ™ป๏ธLifecycle of Credentials
    • โšก๏ธ Quickstart Guide
  • Getting Started
    • ๐Ÿ–Œ๏ธCustomize Credential Branding
    • ๐Ÿ”‘Generate an API Key
    • ๐Ÿ“ŠDashboard
    • โ›“๏ธOnchain Data
    • ๐Ÿ“ Select a Credential Schema
    • ๐Ÿš€Build & Issue Credentials
    • ๐Ÿ“–Credential Data Model
    • โš™๏ธDisco APIs
      • Programmatically Issue a Credential
      • Retrieve a Credential
      • Verify a Credential
      • Personas
    • โš™๏ธDisco SDK: Selective Disclosure
      • Implementation
  • Learn more
    • ๐Ÿ‘‹Data Backpacks for Holders
      • โ™ป๏ธThe 3-Sided Marketplace of Verifiable Data
      • ๐ŸŽ’Create a Data Backpack
      • ๐Ÿ“งSend a Credential to Another Person
      • โš™๏ธLinked Accounts
        • X (Twitter) Account
        • Lens, ENS or .box Domains and Data Backpacks (coming soon)
    • ๐Ÿ“‘DIDs and VCs Explained
    • ๐Ÿ”“Wallets
    • โ“FAQs
    • ๐Ÿ“’Glossary
      • Detailed Glossary
  • Demos
    • ๐Ÿ’…Chipped Nails by Kiki.World x Gossip Protocol
    • ๐Ÿ’งProgrammatic Issuance: Campaigns
Powered by GitBook
On this page
  1. Getting Started
  2. Disco APIs

Programmatically Issue a Credential

General steps to implement based on events in applications and onchain

PreviousDisco APIsNextRetrieve a Credential

Last updated 1 year ago

Programmatically Issue Verifiable Credentials (VCs)

Issue Verifiable Credentials (VCs) programmatically when certain events occur, such as when a user completes specific actions, swaps a token, completes a level in a game, or mints an NFT. VCs can be issued to a user's ETH address or DID. The options are endless and only bound by your imagination!

Prerequisite

Generate a to ensure credentials are signed with keys that you control

How it works

  1. Select event(s) that will result in credential issuance

  2. Leverage our API endpoint and set up logic in your platform to issue credentials

    • Determine conditions for issuing credentials to a users

    • Send POST requests to the API to issue the credentials

  3. User receives credentials

API Endpoint

Usage example

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));

โš™๏ธ
did:web
Drawing
  • Prerequisite
  • How it works
  • API Endpoint
  • POSTProgrammatically issue one verifiable credential
  • Usage example

Programmatically issue one verifiable credential

post

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.

Authorizations
Body
schemaUrlstringOptional

The URL of the verifiable crednetial schema. Available schemas can be found at https://github.com/discoxyz/disco-schemas

Example: https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json
recipientDIDstringOptional

The DID address of the credential's claimant

Example: did:3:Example987xyz
subjectDataobject ยท subjectDataOptional

The fields and values for the credential (based on its schema)

Example: { "memberId": "Goldstar Member", "membershipDescription": "Demo membership to showcase Disco API", "membershipLevel": "Permanent", "membershipType": "Developer", "organization": "Disco.xyz" }
expirationDatestringOptional

The date for the credential to expire for the claimant. Leave empty if there's no expiration.

suitestringOptional

Optional - supported values are "JWT" and "712".

issuerstringOptional

The DID address of the credential's issuer.

Example: did:web:api.disco.xyz/v1/disco
skipSignbooleanOptional

To sign or not to sign - hint you should sign! Either leave out or assign false.

Example: false
Responses
200
Success
application/json
401
Unauthorized
application/json
500
Credential not created function captureStackTrace() { [native code] }
application/json
post
POST /v1/credential HTTP/1.1
Host: 
Authorization: YOUR_API_KEY
Content-Type: application/json
Accept: */*
Content-Length: 499

{
  "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"
}
{
  "_id": "text",
  "vc": "See https://www.w3.org/TR/vc-data-model/#example-a-simple-example-of-a-verifiable-credential",
  "jwt": "eyJhbGciOiJIUzI1N........",
  "isPublic": "true",
  "issuer": "",
  "recipient": "text",
  "subject": "text",
  "schema": "https://raw.githubusercontent.com/discoxyz/disco-schemas/main/json/MembershipCredential/1-0-0.json",
  "genId": "text",
  "updatedAt": "text",
  "isDeleted": true,
  "history": []
}