Publish a schema
Publishing a schema is the final step to making it an immutable, publicly verifiable, and production-ready resource. This page provides a practical guide on how to publish a schema that you have already defined.
Publishing a schema is an explicit action that creates a permanent record of the schema definition. Once a schema is published, it cannot be modified.
Using the SDK
The easiest way to publish a schema is by using the publishSchema() method on a VcDecorator instance. When you call this method, the SDK publishes the schema defined by the user-deinfed types (UDTs) and makes it available on the Truvity platform.
The slug and version parameters in your UDT's @VcSchema decorator are used to identify the published schema.
- Java
// Create a decorator from your UDT
VcDecorator<ProofOfIdentity> proofOfIdentity = client.vcDecorator(ProofOfIdentity.class);
// Publish the schema for production
proofOfIdentity.publishSchema();
- If the schema is already published, the platform performs no action.
- If the schema is already published but there were changes in the UDT definition, this operation shows an error.
- It is recommended to set up schema publication outside the main app workflow to avoid unnecessary API requests.
Using the API
For direct API access, you can publish a schema using the PATCH /schemas/{id}/publish endpoint. You must have the resource ID of the CredentialSchema you want to publish.
The request payload requires a slug and an optional version to identify the published schema.
{
"slug": "basic-profile",
"version": 1
}