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.

CURL

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 _id from 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. raw is the default.
    • "raw" — Response field signature is the standard Base64 raw signature.
    • "jwt" — Response field jwt is a compact JWT. plaintext must be a JSON object. See Sign a JWT.
  • headers: Object (optional) - Additional JWT protected headers. Send this only when format is jwt.

Example Response
{
  "signature": "MEUCIQDxF7X8h9..."
}

Response Fields:

  • signature: String - Standard Base64 raw signature. Present when format is raw.

Response Codes

  • 200 — Signature created successfully.
  • 400 — plaintext is null, or headers was 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.

CURL

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 _id from 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) - raw by default. Use jwt when the response should be a compact JWT.
  • headers: Object (optional) - Additional JWT protected headers. Send this only when format is jwt.

Example Response
{
  "signature": "MEUCIQDxF7X8h9..."
}

Response Fields:

  • signature: String - Standard Base64 raw signature over the compact JSON bytes.

Response Codes

  • 200 — Signature created successfully.
  • 400 — plaintext is null, or headers was 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.

CURL

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 _id from 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) - jwt returns 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. b64 is 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 as alg.
    • kid: String (optional) - Key identifier to place in the protected header.
    • typ: String (optional) - Token type. JWT when this field is omitted.
    • alg: String (optional) - Must match the key's JWS algorithm. An imported JWK uses its alg member, such as PS256. When this field is omitted, the service sets alg from 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 — plaintext is not a JSON object, alg does 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

Last updated on November 26, 2026