POST /sign

API reference for the sign endpoint - sign a message as an agent or service with a 4Quays-held key

The /sign endpoint signs a message with the caller's own 4Quays-held signing key and returns a portable signed message that anyone can verify. The private key never leaves 4Quays.

Both agents and services can sign:

  • Agents sign with the agent's signing key, created when the agent is enrolled.
  • Services sign as their policy's source service, using a dedicated signing key (key_purpose = 'sign') on that policy. Add the signing key from the policy page in 4Quays. The policy must grant the sign operation.

The signature names its signer in the JWS header (fourquays.agent_id or fourquays.service_id). Verifiers see whether an agent or a service signed.

Endpoint

POST /api/v1/sign

Request

Headers

HeaderRequiredDescription
X-API-KeyYes*An agent API key or a service API key. Authorization: Bearer <key> is also accepted.
X-Signing-GrantNo*A one-time signing grant, used instead of an API key. It signs only the exact content it was issued for. Agents only.
Content-TypeYesMust be application/json

* Send either an API key or a signing grant.

Body

{
  "content": "Approve payment of CAD 5,000 to ACME Ltd.",
  "audience": "payments.example.com",
  "expiresIn": 3600,
  "delivery": "inline",
  "access": "open"
}
FieldTypeRequiredDescription
contentstringYesThe message to sign. Max 256 KB (UTF-8).
audiencestringNoWho the signature is for. It is embedded in the signature, and verifiers can require it with expectedAudience. Max 512 characters.
expiresInintegerNoSeconds until the signature expires. Max one year (31,536,000). Omit it for a signature that does not expire.
delivery"inline" | "link"Noinline returns the signed message. link stores it and returns a short hosted verify URL. Defaults to the policy's configured delivery, otherwise inline.
access"open" | "api-protected"NoLink delivery only. open means anyone with the URL sees the verdict. api-protected means the URL resolves only with an agent or service API key from the same organization. Defaults to the policy's configured access, otherwise open.

Example Request

curl -X POST https://api.4quays.com/api/v1/sign \
  -H "X-API-Key: $FOURQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Approve payment of CAD 5,000 to ACME Ltd.",
    "expiresIn": 3600
  }'

Response

Inline delivery (200 OK)

{
  "requestId": "550e8400-e29b-41d4-a716-446655440000",
  "signedMessage": "-----BEGIN 4QUAYS SIGNED MESSAGE-----\nVersion: 4QSB/2\n...\n-----END 4QUAYS SIGNED MESSAGE-----",
  "signature": {
    "jws": "eyJhbGciOiJNTC1EU0EtNjUi...",
    "kid": "9f2c4e...",
    "algorithm": "ML-DSA-65",
    "quantum_safe": true,
    "signed_at": "2026-11-24T15:04:05.000Z",
    "expires_at": "2026-11-24T16:04:05.000Z",
    "audience": null,
    "mode": "service-held",
    "signer": { "type": "service", "id": "3b1d..." }
  }
}
FieldTypeDescription
requestIdstringUnique request identifier for tracing
signedMessagestringThe armored signed message. The content is inside the signed payload, so the block can be pasted, emailed or attached as a .4qs file.
signature.jwsstringThe compact JWS. You can send it on its own as a detached signature.
signature.kidstringSigning key fingerprint. Resolve it at /.well-known/jwks/<kid>.
signature.algorithmstringJOSE algorithm: ML-DSA-44, ML-DSA-65, ML-DSA-87, ES256 or PS256
signature.quantum_safebooleantrue for ML-DSA signatures
signature.signed_atstringISO 8601 signing time
signature.expires_atstring | nullISO 8601 expiry, or null
signature.audiencestring | nullThe audience embedded in the signature
signature.modestringAlways "service-held": 4Quays holds the private key
signature.signerobjectThe signing principal: { "type": "agent" | "service", "id": "<uuid>" }
{
  "requestId": "550e8400-e29b-41d4-a716-446655440000",
  "url": "https://api.4quays.com/v/k3J9xQ",
  "expiresAt": "2026-11-25T15:04:05.000Z",
  "signature": { "...": "same fields as inline delivery" }
}
FieldTypeDescription
urlstringHosted verify page for the signed message. The stored block is envelope-encrypted.
expiresAtstringWhen the link stops resolving (24 hours after signing)
signatureobjectSame as inline delivery

An api-protected link shows no verdict in a browser. Resolve it with GET /api/v1/artifacts/{id} and an agent or service API key (header X-API-Key) from the organization that signed it.

Algorithms

The algorithm comes from the signer's key, not from the request.

Key algorithmJOSE algQuantum-safe
ML-DSA-44ML-DSA-44Yes
ML-DSA-65ML-DSA-65Yes
ML-DSA-87ML-DSA-87Yes
ECDSA P-256ES256No
RSA-2048 / RSA-4096 (RSASSA-PSS)PS256No

To change algorithm, rotate the signing key. Signatures made with a rotated key still verify.

Error Responses

Errors use the standard envelope:

{
  "error": {
    "code": "SIGNING_KEY_MISSING",
    "message": "This service policy has no signing key. Add one from the policy page in 4Quays."
  },
  "requestId": "550e8400-e29b-41d4-a716-446655440000"
}
StatusCodeApplies toMeaning
400INVALID_REQUESTAllThe body failed validation (details lists the problems)
401AUTHENTICATION_FAILEDAllMissing, invalid, expired or revoked API key
403GRANT_INVALIDGrantThe signing grant is invalid, expired or already used
403GRANT_PAYLOAD_MISMATCHGrantThe grant was issued for different content
403OPERATION_NOT_ALLOWEDAgent, serviceThe policy does not grant sign
403POLICY_INACTIVEAgent, serviceThe policy is not active
403TENANT_FROZENAgent, serviceThe organization is suspended
403AGENT_REVOKEDAgentThe agent has been revoked
403AGENT_FROZENAgentThe agent is frozen
403SERVICE_FROZENServiceA service on the policy's connection (source or destination) is frozen
403SERVICE_DEACTIVATEDServiceA service on the policy's connection has been deactivated
404POLICY_NOT_FOUNDServiceThe key's policy no longer exists or has no source service
409NO_SIGNING_KEYAgentThe agent has no usable signing key
409SIGNING_KEY_MISSINGServiceThe service policy has no active signing key
429RATE_LIMITEDAllToo many sign requests for this principal. Honor Retry-After.
500INTERNAL_ERRORAllSigning failed

Freezes and revocations are read live on every call. They take effect on the next request, not when a key cache expires.

SDK

import { FourQ, ServiceFrozenError, SigningKeyMissingError } from '@4quays/sdk';

const fourq = new FourQ({
  endpoint: process.env.FOURQ_ENDPOINT,
  apiKey: process.env.FOURQ_API_KEY, // agent or service key
});

try {
  const { signedMessage, signature } = await fourq.sign(
    'Approve payment of CAD 5,000 to ACME Ltd.',
    { expiresInSeconds: 3600 },
  );
  console.log(signature.signer); // { type: 'service', id: '...' }
} catch (error) {
  if (error instanceof SigningKeyMissingError) {
    // add a signing key to the service policy
  } else if (error instanceof ServiceFrozenError) {
    // containment: signing resumes when the service is unfrozen
  }
  throw error;
}