Credential Templates
Credential templates define reusable structures for issuing verifiable credentials across multiple ecosystems (OpenID, Privado ID, Indicio, Cheqd). These templates support formats such as AnonCreds and JSON-LD, allowing customization of attributes, schemas, and themes. This section covers methods to retrieve, create, update, delete, and import credential templates.
- Get All Credential Templates
- Get Tenant Credential Templates
- Delete Credential Template
- Update Credential Template
- Create Credential Template (JSON-LD)
- Create Credential Template (SD-JWT)
- Create Credential Template (mdoc)
- Create Credential Template (AnonCreds)
- Import Credential Template (JSON-LD)
- Import Credential Template (AnonCreds)
Get All Credential Templates
Retrieves a list of credential templates associated with the authenticated API key, with an optional filter by template ID.
import { OpenIDEcosystem } from '@openid/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const templates = await openid.getAllCredentialTemplates({
tenantId: 'your-tenant-id',
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to query. |
| credentialTemplateId | string (Optional) | The ID of a specific credential template to retrieve (if omitted, returns all templates for the tenant). |
- Use the
credentialTemplateIdfilter to retrieve a single template or omit it for a full list. - Responses may include metadata; check
GetCredentialTemplatesResponsefor full structure.
Get Tenant Credential Templates
Retrieves credential templates specific to a tenant, with an optional filter by template ID.
import { OpenIDEcosystem } from '@openid/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const tenantTemplates = await openid.getTenantCredentialTemplates({
tenantId: 'your-tenant-id',
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to query. |
| credentialTemplateId | string (Optional) | The ID of a specific credential template to retrieve (if omitted, returns all templates for the tenant). |
- Similar to
getAllCredentialTemplates, but scoped to tenant-specific templates.- Use this for tenant-specific auditing or management.
Create Credential Template (JSON-LD)
Creates a new JSON-LD credential template.
import { OpenIDEcosystem } from '@openid/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const template = await openid.createCredentialTemplateJsonld({
tenantId: 'your-tenant-id',
name: 'Employee ID',
version: '1.0.0',
description: 'JSON-LD template for employee IDs',
schemaType: 'EmployeeSchema',
attributes: [
{ name: 'firstName', label: 'First Name', type: 'string', description: 'Given name', required: true },
{ name: 'lastName', label: 'Last Name', type: 'string', description: 'Family name', required: true },
],
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to associate the template with. |
| name | string (Required) | The name of the template. |
| version | string (Required) | The version of the template (e.g., `1.0.0`). |
| description | string (Required) | A description of the template. |
| schemaType | string (Required) | The schema type for the credential (e.g., `EmployeeSchema`). |
| attributes | CredentialTemplateAttribute[] (Required) | Array of attribute definitions. |
| image | string (Optional) | A URL for the template’s image. |
| categoryId | string (Optional) | The ID of a category to associate with the template. |
| credentialTheme | CredentialTheme (Optional) | Custom theme settings. |
| privadoCredentialType | string (Optional) | Specific type for Privado integration. |
schemaTypemust match a supported JSON-LD context.- Use
credentialThemefor custom branding if needed.
Create Credential Template (AnonCreds)
Creates a new AnonCreds credential template.
import { IndicioEcosystem } from '@hovi/core-sdk';
const indicio = new IndicioEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const template = await indicio.createCredentialTemplateAnoncreds({
tenantId: 'your-tenant-id',
name: 'Employee ID',
version: '1.0.0',
description: 'AnonCreds template for employee IDs',
tag: 'emp-id-v1',
attributes: [
{ name: 'firstName', label: 'First Name', type: 'string', description: 'Given name', required: true },
{ name: 'lastName', label: 'Last Name', type: 'string', description: 'Family name', required: true },
],
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to associate the template with. |
| name | string (Required) | The name of the template. |
| version | string (Required) | The version of the template (e.g., `1.0.0`). |
| description | string (Required) | A description of the template. |
| tag | string (Required) | A unique tag for the template. |
| attributes | CredentialTemplateAttribute[] (Required) | Array of attribute definitions. |
| image | string (Optional) | A URL for the template’s image. |
| categoryId | string (Optional) | The ID of a category to associate with the template. |
- The
tagmust be unique within the tenant to avoid conflicts. - Use
attributesto define the schema for AnonCreds credentials.
Create Credential Template (mDoc)
Creates a new mDoc credential template.
import { OpenIDEcosystem } from '@hovi/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const template = await openid.createCredentialTemplateAnoncreds({
tenantId: 'your-tenant-id',
name: 'Employee ID',
version: '1.0.0',
description: 'AnonCreds template for employee IDs',
tag: 'emp-id-v1',
attributes: [
{ name: 'firstName', label: 'First Name', type: 'string', description: 'Given name', required: true },
{ name: 'lastName', label: 'Last Name', type: 'string', description: 'Family name', required: true },
],
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to associate the template with. |
| name | string (Required) | The name of the template. |
| version | string (Required) | The version of the template (e.g., `1.0.0`). |
| description | string (Required) | A description of the template. |
| tag | string (Required) | A unique tag for the template. |
| attributes | CredentialTemplateAttribute[] (Required) | Array of attribute definitions. |
| image | string (Optional) | A URL for the template’s image. |
| categoryId | string (Optional) | The ID of a category to associate with the template. |
- The
tagmust be unique within the tenant to avoid conflicts. - Use
attributesto define the schema for AnonCreds credentials.
Create Credential Template (SD-JWT)
Creates a new mDoc credential template.
import { OpenIDEcosystem } from '@hovi/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const template = await openid.createCredentialTemplateAnoncreds({
tenantId: 'your-tenant-id',
name: 'Employee ID',
version: '1.0.0',
description: 'AnonCreds template for employee IDs',
tag: 'emp-id-v1',
attributes: [
{ name: 'firstName', label: 'First Name', type: 'string', description: 'Given name', required: true },
{ name: 'lastName', label: 'Last Name', type: 'string', description: 'Family name', required: true },
],
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to associate the template with. |
| name | string (Required) | The name of the template. |
| version | string (Required) | The version of the template (e.g., `1.0.0`). |
| description | string (Required) | A description of the template. |
| tag | string (Required) | A unique tag for the template. |
| attributes | CredentialTemplateAttribute[] (Required) | Array of attribute definitions. |
| image | string (Optional) | A URL for the template’s image. |
| categoryId | string (Optional) | The ID of a category to associate with the template. |
- The
tagmust be unique within the tenant to avoid conflicts. - Use
attributesto define the schema for AnonCreds credentials.
Update Credential Template
Updates an existing credential template with new details.
import { OpenIDEcosystem } from '@openid/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const result = await openid.updateCredentialTemplate({
tenantId: 'your-tenant-id',
credentialTemplateId: 'your-credential-template-id',
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant owning the template. |
| credentialTemplateId | string (Required) | The ID of the credential template to update. |
| categoryId | string (Optional) | The ID of a category to associate with the template. |
| image | string (Optional) | A new URL for the template’s image. |
- Only provided fields are updated; others remain unchanged.
- Use this to refresh metadata like images or categories.
Delete Credential Template
Deletes a credential template from a tenant.
import { OpenIDEcosystem } from '@openid/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const result = await openid.deleteCredentialTemplate({
tenantId: 'your-tenant-id',
credentialTemplateId: 'your-credential-template-id',
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant owning the template. |
| credentialTemplateId | string (Required) | The ID of the credential template to delete. |
- This action is irreversible and removes the template and its associated data.
- Ensure no active credentials rely on the template before deletion.
Import Credential Template (JSON-LD)
Imports an existing JSON-LD credential template using a schema URL.
import { OpenIDEcosystem } from '@openid/core-sdk';
const openid = new OpenIDEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const template = await openid.importCredentialTemplateJsonld({
tenantId: 'your-tenant-id',
schemaUrl: 'https://example.com/schemas/employee-schema.jsonld',
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to associate the template with. |
| schemaUrl | string (Required) | The URL of the existing JSON-LD schema. |
| categoryId | string (Optional) | The ID of a category to associate with the template. |
| image | string (Optional) | A URL for the template’s image. |
- Requires a valid
schemaUrlpointing to a JSON-LD context. - Use this to integrate external JSON-LD schemas into your tenant.
Import Credential Template (AnonCreds)
Imports an existing AnonCreds credential template using a schema ID.
import { IndicioEcosystem } from '@hovi/core-sdk';
const indicio = new IndicioEcosystem({
apiKey: 'your-ecosystem-api-key',
});
const template = await indicio.importCredentialTemplateAnoncreds({
tenantId: 'your-tenant-id',
schemaId: 'schema-789',
tag: 'imp-emp-id-v1',
description: 'Imported AnonCreds template for employee IDs',
});
Params
| Parameter | Type | Description |
|---|---|---|
| tenantId | string (Required) | The ID of the tenant to associate the template with. |
| schemaId | string (Required) | The ID of the existing AnonCreds schema. |
| tag | string (Required) | A unique tag for the imported template. |
| description | string (Required) | A description of the template. |
| image | string (Optional) | A URL for the template’s image. |
| categoryId | string (Optional) | The ID of a category to associate with the template. |
- The
schemaIdmust reference a valid AnonCreds schema on the ledger. - The
tagmust be unique within the tenant.