Skip to main content

Create a Compact or Semantic Compact Credential configuration

Request

Make a request of the following structure to create a new Compact Credential configuration:


POST https://api.sovrin.one/v2/credentials/compact/configurations


{
"type": "CourseCredential",
"claimMappings": {
"email": {
"mapFrom": "claims.email"
},
"firstName": {
"mapFrom": "claims.given_name"
},
"lastName": {
"mapFrom": "claims.lastName"
},
"addressRegion": {
"mapFrom": "claims.addressRegion",
"required": true,
"defaultValue": "Kakapo"
},
"providerUrl": {
"mapFrom": "authenticationProvider.url",
"required": true
},
"providersubjectId": {
"mapFrom": "authenticationProvider.subjectId",
"required": true
}
},
"revocable": true,
"expiresIn": {
"years": 1
},
"claimSourceId": "945214ad-3635-4aff-b51d-61d69a3c8eee"
}

  • type (required): Used to differentiate between different Compact/Semantic compact credential configurations on your tenant. Thus, its value must:

    • Be unique across all Compact/Semantic compact credential configurations on your tenant.

    • Not be VerifiableCredential.

  • claimMappings: This is where you specify how to map claims (user attributes) into issued credentials. Each field in the object corresponds to a claim in the issued credential, and contains one or more from the following attributes:

    • mapFrom: References the path in the user object where the claim is available.

    • When using a URL as a claims namespace identifier, use bracket notation to access the claim value (e.g. mapFrom: "claims['https://example.com/claim-name']").

    • mapForm is optional when defaultValue is provided, as the latter will be used for all issued credentials. This is referred to as a static claim.

  • defaultValue: Indicates what value is used if required is set to false (field is optional) and no value is provided by the claims source. When defaultValue is provided, mapFrom is optional.

  • required: Indicates whether the claim is required (default: false). When a required claim cannot be retrieved and no defaultValue is available, credential issuance will fail.

Refer to Credential configuration claims to learn more about how this object is created and handled.

  • revocable: When set to true (default), the created credential can later be revoked. When set to false, the credential cannot be revoked.

  • claimSourceId (optional): References the unique identifier of a claims source that can be used to retrieve claims and include them in the issued credential.

  • expiresIn (optional): Used to determine when will issued credentials expire. Can include any combination of years, months, weeks, days, hours, minutes and seconds.

You can make a similar request to a different endpoint to create a new Semantic Compact Credential configuration:


POST https://api.sovrin.one/v2/credentials/compact-semantic/configurations

Response


{
"id": "8fda86fc-781d-4401-80d7-eaa43efafad9",
"type": "CourseCredential",
//... rest of your credential configuration
}

  • id: Uniquely identifies the created credential configuration. This identifier can be used to create an offer based on this credential configuration, or to retrieve, update or remove the credential configuration.

What's next?

Now that you have created a credential configuration, you can proceed to create a credential offer based on this configuration.