Sign Data
This guide shows you how to sign a string, a JSON document, or a JWT with a key stored in the Enterprise Key Management Service.
Prerequisites
Before you begin, ensure you have:
- Key Management Service — Follow the Setup guide and create a signing key. Local stores that key in the Enterprise database.
- Bearer token — The account can sign with the key.
Sign a String
The default format is raw. A string plaintext is signed as its UTF-8 text.
Endpoint: POST /v1/{target}/kms-service-api/keys/sign | API Reference
Example Request
curl -X 'POST' \
'https://{orgID}.enterprise-sandbox.waltid.dev/v1/{target}/kms-service-api/keys/sign' \
-H 'accept: application/json' \
-H 'Authorization: Bearer {yourToken}' \
-H 'Content-Type: application/json' \
-d '{
"plaintext": "Hello, World!"
}'
Path Parameters
- orgID: String (required) - Your organization ID, e.g.
test. The request URL appends.enterprise-sandbox.waltid.dev. - target: String (required) - Full key path returned as
_idfrom key generation, e.g.waltid.tenant1.kms1.key1.
Header Parameters
- Authorization: String (required) - Bearer token for Enterprise Stack authentication. Format:
Bearer {token}.
Body Parameters
- plaintext: String (required) - Text to sign.
- format: String (optional) - Output mode.
rawis the default."raw"— Response fieldsignatureis the standard Base64 raw signature."jwt"— Response fieldjwtis a compact JWT.plaintextmust be a JSON object. See Sign a JWT.
- headers: Object (optional) - Additional JWT protected headers. Send this only when
formatisjwt.
Example Response
{
"signature": "MEUCIQDxF7X8h9..."
}
Response Fields:
- signature: String - Standard Base64 raw signature. Present when
formatisraw.
Response Codes
200— Signature created successfully.400—plaintextis null, orheaderswas sent for a raw signature.401— Invalid or missing authentication token.403— The caller cannot sign with this key.404— No key exists at{target}.
Sign a JSON Document
Send the JSON value as plaintext. An object, array, number, or boolean is signed as compact JSON, with object keys kept in the order they were sent. Number literals are kept as submitted.
Endpoint: POST /v1/{target}/kms-service-api/keys/sign | API Reference
Example Request
curl -X 'POST' \
'https://{orgID}.enterprise-sandbox.waltid.dev/v1/{target}/kms-service-api/keys/sign' \
-H 'accept: application/json' \
-H 'Authorization: Bearer {yourToken}' \
-H 'Content-Type: application/json' \
-d '{
"plaintext": {
"orderId": "123",
"amount": 10
}
}'
Path Parameters
- orgID: String (required) - Your organization ID, e.g.
test. The request URL appends.enterprise-sandbox.waltid.dev. - target: String (required) - Full key path returned as
_idfrom key generation, e.g.waltid.tenant1.kms1.key1.
Header Parameters
- Authorization: String (required) - Bearer token for Enterprise Stack authentication. Format:
Bearer {token}.
Body Parameters
- plaintext: Object (required) - JSON value to sign. Objects, arrays, numbers, and booleans are accepted.
- format: String (optional) -
rawby default. Usejwtwhen the response should be a compact JWT. - headers: Object (optional) - Additional JWT protected headers. Send this only when
formatisjwt.
Example Response
{
"signature": "MEUCIQDxF7X8h9..."
}
Response Fields:
- signature: String - Standard Base64 raw signature over the compact JSON bytes.
Response Codes
200— Signature created successfully.400—plaintextis null, orheaderswas sent for a raw signature.401— Invalid or missing authentication token.403— The caller cannot sign with this key.404— No key exists at{target}.
Sign a JWT
Set format to jwt. plaintext is the JWT payload and must be a JSON object. Put any extra protected headers in headers. The service sets alg from the key. When typ is omitted, the protected header uses JWT.
Endpoint: POST /v1/{target}/kms-service-api/keys/sign | API Reference
Example Request
curl -X 'POST' \
'https://{orgID}.enterprise-sandbox.waltid.dev/v1/{target}/kms-service-api/keys/sign' \
-H 'accept: application/json' \
-H 'Authorization: Bearer {yourToken}' \
-H 'Content-Type: application/json' \
-d '{
"format": "jwt",
"plaintext": {
"orderId": "123",
"amount": 10
},
"headers": {
"kid": "issuer-key-1"
}
}'
Path Parameters
- orgID: String (required) - Your organization ID, e.g.
test. The request URL appends.enterprise-sandbox.waltid.dev. - target: String (required) - Full key path returned as
_idfrom key generation, e.g.waltid.tenant1.kms1.key1.
Header Parameters
- Authorization: String (required) - Bearer token for Enterprise Stack authentication. Format:
Bearer {token}.
Body Parameters
- format: String (required) -
jwtreturns a compact JWT. - plaintext: Object (required) - JWT payload. A string, array, number, or boolean is rejected.
- headers: Object (optional) - Additional protected headers copied onto the JWT.
b64is rejected.crit, when present, must name only extension headers that are also present in this object, and it must not name a registered header such asalg.- kid: String (optional) - Key identifier to place in the protected header.
- typ: String (optional) - Token type.
JWTwhen this field is omitted. - alg: String (optional) - Must match the key's JWS algorithm. An imported JWK uses its
algmember, such asPS256. When this field is omitted, the service setsalgfrom that declaration.
Example Response
{
"jwt": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCIsImtpZCI6Imlzc3Vlci1rZXktMSJ9.eyJvcmRlcklkIjoiMTIzIiwiYW1vdW50IjoxMH0.signature"
}
Response Fields:
- jwt: String - Compact JWT signed by the targeted key.
Response Codes
200— JWT created successfully.400—plaintextis not a JSON object,algdoes not match the key, or this key cannot sign a JWT.401— Invalid or missing authentication token.403— The caller cannot sign with this key.404— No key exists at{target}.
Next Steps
- Create a key — Local.
- Sign with a token key — PKCS#11 HSM.
- Browse the API — Full API Reference.
