Overview
TheCredentials service manages W3C Verifiable Credentials and SD-JWT selective disclosures. Retrieve individual credentials, list with filters, verify credential JWTs, and create selective-disclosure presentations.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Retrieve, verify, and present W3C Verifiable Credentials and SD-JWT selective disclosures
Credentials service manages W3C Verifiable Credentials and SD-JWT selective disclosures. Retrieve individual credentials, list with filters, verify credential JWTs, and create selective-disclosure presentations.
vc, err := client.Credentials.Get(ctx, "vc_01HXYZ...")
if err != nil {
log.Fatal(err)
}
fmt.Printf("ID: %s\n", vc.ID)
fmt.Printf("Type: %v\n", vc.Type)
fmt.Printf("Issuer: %s\n", vc.Issuer)
fmt.Printf("Subject: %s\n", vc.Subject)
fmt.Printf("Status: %s\n", vc.Status)
| Parameter | Type | Required | Description |
|---|---|---|---|
credentialID | string | Yes | The unique credential identifier. |
VerifiableCredential)| Field | Type | Description |
|---|---|---|
ID | string | Unique credential identifier. |
Type | []string | Credential types (always includes "VerifiableCredential"). |
Issuer | string | DID of the credential issuer. |
Subject | string | DID of the credential subject (the holder). |
IssuanceDate | string | ISO 8601 timestamp when the credential was issued. |
ExpirationDate | *string | ISO 8601 expiration timestamp, or nil if no expiry. |
Status | string | Current status: "active", "revoked", or "expired". |
JWT | string | The credential in compact JWT format. |
Claims | map[string]any | The credential subject claims. |
result, err := client.Credentials.List(ctx, grantex.ListCredentialsParams{
PrincipalID: grantex.String("user_abc123"),
Type: grantex.String("IdentityCredential"),
Status: grantex.String("active"),
Page: grantex.Int(1),
PageSize: grantex.Int(20),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total: %d\n", result.Total)
for _, vc := range result.Credentials {
fmt.Printf(" %s: %v\n", vc.ID, vc.Type)
}
| Parameter | Type | Required | Description |
|---|---|---|---|
PrincipalID | *string | No | Filter credentials by principal (subject) ID. |
Type | *string | No | Filter by credential type (e.g., "IdentityCredential"). |
Status | *string | No | Filter by status: "active", "revoked", "expired". |
Page | *int | No | Page number for pagination (default: 1). |
PageSize | *int | No | Results per page (default: 20, max: 100). |
ListCredentialsResponse)| Field | Type | Description |
|---|---|---|
Credentials | []VerifiableCredential | Slice of Verifiable Credential objects. |
Total | int | Total number of matching credentials. |
result, err := client.Credentials.Verify(ctx, vcJWT)
if err != nil {
log.Fatal(err)
}
if result.Valid {
fmt.Printf("Issuer: %s\n", *result.Issuer)
fmt.Printf("Subject: %s\n", *result.Subject)
fmt.Printf("Claims: %v\n", result.Claims)
} else {
fmt.Printf("Invalid: %s\n", *result.Reason)
}
| Parameter | Type | Required | Description |
|---|---|---|---|
vcJWT | string | Yes | The Verifiable Credential in compact JWT format. |
VerifyCredentialResponse)| Field | Type | Description |
|---|---|---|
Valid | bool | Whether the credential is valid. |
Issuer | *string | DID of the issuer (if valid). |
Subject | *string | DID of the subject (if valid). |
Claims | map[string]any | Credential subject claims (if valid). |
ExpiresAt | *string | ISO 8601 expiration timestamp. |
Reason | *string | Reason for invalidity: "expired", "revoked", "invalid_signature", "untrusted_issuer". |
presentation, err := client.Credentials.Present(ctx, grantex.PresentCredentialParams{
SDJWT: "eyJ0eXAiOiJ2YytzZC1qd3QiLC...",
DisclosedClaims: []string{"name", "email"},
Audience: grantex.String("did:web:verifier.example.com"),
Nonce: grantex.String("unique-request-nonce"),
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Presentation JWT: %s\n", presentation.PresentationJWT)
fmt.Printf("Disclosed: %v\n", presentation.DisclosedClaims)
| Parameter | Type | Required | Description |
|---|---|---|---|
SDJWT | string | Yes | The SD-JWT credential to create a presentation from. |
DisclosedClaims | []string | Yes | Claim names to disclose. All others remain hidden. |
Audience | *string | No | Intended verifier DID or URL for the holder binding. |
Nonce | *string | No | Nonce for replay protection in the holder binding. |
PresentCredentialResponse)| Field | Type | Description |
|---|---|---|
PresentationJWT | string | The SD-JWT presentation with only the disclosed claims. |
DisclosedClaims | []string | The claim names that were disclosed. |
HolderBinding | string | The key binding JWT proving holder possession. |