Updated on 2022-12-06 GMT+08:00

Publishing Credential Schemas

Function

This API is used to publish schemas for professional VCs. A schema enforces a specific structure on the credential data.

URI

POST /v1/identity/credential-schema

Request Parameters

Table 1 Request body parameters

Parameter

Mandatory

Type

Description

orgID

Yes

String

Organization ID.

channelID

Yes

String

Channel ID.

cryptoMethod

Yes

String

Encryption method, which is fixed at SW.

cert

Yes

String

User certificate. Add an explicit line break (\n) at the end of each line.

sk

Yes

String

User private key. Add an explicit line break (\n) at the end of each line.

timestamp

Yes

String

Timestamp.

title

No

String

Name.

identifier

Yes

String

Identifier.

attributes

No

Array of Attribute objects

Attribute information.

issuer

Yes

String

Issuer identifier.

Table 2 Attribute

Parameter

Mandatory

Type

Description

name

No

String

Name.

type

No

String

Type.

description

No

String

Description.

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

schemaIndex

String

Index of the schema stored on the blockchain.

credentialSchema

CredentialSchema object

CredentialSchema

Table 4 CredentialSchema

Parameter

Type

Description

creator

String

Creator identifier.

title

String

Name.

identifier

String

Credential schema identifier.

attributes

Array of Attribute objects

Attribute information.

version

Integer

Version.

Table 5 Attribute

Parameter

Type

Description

name

String

Name.

type

String

Type.

description

String

Description.

Status code: 500

Table 6 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

Minimum: 8

Maximum: 36

errorMsg

String

Error description.

Minimum: 2

Maximum: 512

Example Requests

{
  "orgID" : "4f1439758ebb41f7411b5f684b67713c08b89198",
  "channelID" : "mychannel",
  "cryptoMethod" : "SW",
  "cert" : "-----BEGIN CERTIFICATE-----\n...\n...\n-----END CERTIFICATE-----",
  "sk" : "------BEGIN PRIVATE KEY-----\n...\n...\n-----END PRIVATE KEY-----",
  "timestamp" : "2020-10-27T17:28:16+08:00",
  "title" : "string",
  "identifier" : "string",
  "attributes" : [ {
    "name" : "name",
    "type" : "someType",
    "description" : "Identity number"
  } ],
  "issuer" : "did:example:ebfeb1f712ebc6f1c276e12ec21"
}

Example Responses

Status code: 200

VCSchemaResponeParams

{
  "schemaIndex" : "string",
  "credentialSchema" : {
    "creator" : "string",
    "title" : "string",
    "identifier" : "string",
    "attributes" : [ {
      "name" : "name",
      "type" : "someType",
      "description" : "Identity number"
    } ],
    "version" : 0
  }
}

Status code: 500

Error response.

{
  "errorCode" : "BCS.5002035",
  "errorMsg" : "Schema Already Exist"
}

Status Codes

Status Code

Description

200

VCSchemaResponeParams

500

Error response.

Error Codes

See Error Codes.