Skip to main content

Overview

The 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.

Get

Retrieve a single Verifiable Credential by its ID.
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)

Parameters

ParameterTypeRequiredDescription
credentialIDstringYesThe unique credential identifier.

Response (VerifiableCredential)

FieldTypeDescription
IDstringUnique credential identifier.
Type[]stringCredential types (always includes "VerifiableCredential").
IssuerstringDID of the credential issuer.
SubjectstringDID of the credential subject (the holder).
IssuanceDatestringISO 8601 timestamp when the credential was issued.
ExpirationDate*stringISO 8601 expiration timestamp, or nil if no expiry.
StatusstringCurrent status: "active", "revoked", or "expired".
JWTstringThe credential in compact JWT format.
Claimsmap[string]anyThe credential subject claims.

List

List Verifiable Credentials with optional filters.
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)
}

Parameters

ParameterTypeRequiredDescription
PrincipalID*stringNoFilter credentials by principal (subject) ID.
Type*stringNoFilter by credential type (e.g., "IdentityCredential").
Status*stringNoFilter by status: "active", "revoked", "expired".
Page*intNoPage number for pagination (default: 1).
PageSize*intNoResults per page (default: 20, max: 100).

Response (ListCredentialsResponse)

FieldTypeDescription
Credentials[]VerifiableCredentialSlice of Verifiable Credential objects.
TotalintTotal number of matching credentials.

Verify

Verify a Verifiable Credential JWT. Checks signature, expiration, revocation status, and issuer trust chain.
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)
}

Parameters

ParameterTypeRequiredDescription
vcJWTstringYesThe Verifiable Credential in compact JWT format.

Response (VerifyCredentialResponse)

FieldTypeDescription
ValidboolWhether the credential is valid.
Issuer*stringDID of the issuer (if valid).
Subject*stringDID of the subject (if valid).
Claimsmap[string]anyCredential subject claims (if valid).
ExpiresAt*stringISO 8601 expiration timestamp.
Reason*stringReason for invalidity: "expired", "revoked", "invalid_signature", "untrusted_issuer".

Present

Create a selective-disclosure presentation from an SD-JWT. Only the specified claims are disclosed.
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)

Parameters

ParameterTypeRequiredDescription
SDJWTstringYesThe SD-JWT credential to create a presentation from.
DisclosedClaims[]stringYesClaim names to disclose. All others remain hidden.
Audience*stringNoIntended verifier DID or URL for the holder binding.
Nonce*stringNoNonce for replay protection in the holder binding.

Response (PresentCredentialResponse)

FieldTypeDescription
PresentationJWTstringThe SD-JWT presentation with only the disclosed claims.
DisclosedClaims[]stringThe claim names that were disclosed.
HolderBindingstringThe key binding JWT proving holder possession.