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 thesignoperation.
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
| Header | Required | Description |
|---|---|---|
X-API-Key | Yes* | An agent API key or a service API key. Authorization: Bearer <key> is also accepted. |
X-Signing-Grant | No* | A one-time signing grant, used instead of an API key. It signs only the exact content it was issued for. Agents only. |
Content-Type | Yes | Must 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"
}
| Field | Type | Required | Description |
|---|---|---|---|
content | string | Yes | The message to sign. Max 256 KB (UTF-8). |
audience | string | No | Who the signature is for. It is embedded in the signature, and verifiers can require it with expectedAudience. Max 512 characters. |
expiresIn | integer | No | Seconds until the signature expires. Max one year (31,536,000). Omit it for a signature that does not expire. |
delivery | "inline" | "link" | No | inline 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" | No | Link 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..." }
}
}
| Field | Type | Description |
|---|---|---|
requestId | string | Unique request identifier for tracing |
signedMessage | string | The armored signed message. The content is inside the signed payload, so the block can be pasted, emailed or attached as a .4qs file. |
signature.jws | string | The compact JWS. You can send it on its own as a detached signature. |
signature.kid | string | Signing key fingerprint. Resolve it at /.well-known/jwks/<kid>. |
signature.algorithm | string | JOSE algorithm: ML-DSA-44, ML-DSA-65, ML-DSA-87, ES256 or PS256 |
signature.quantum_safe | boolean | true for ML-DSA signatures |
signature.signed_at | string | ISO 8601 signing time |
signature.expires_at | string | null | ISO 8601 expiry, or null |
signature.audience | string | null | The audience embedded in the signature |
signature.mode | string | Always "service-held": 4Quays holds the private key |
signature.signer | object | The signing principal: { "type": "agent" | "service", "id": "<uuid>" } |
Link delivery (200 OK)
{
"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" }
}
| Field | Type | Description |
|---|---|---|
url | string | Hosted verify page for the signed message. The stored block is envelope-encrypted. |
expiresAt | string | When the link stops resolving (24 hours after signing) |
signature | object | Same 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 algorithm | JOSE alg | Quantum-safe |
|---|---|---|
| ML-DSA-44 | ML-DSA-44 | Yes |
| ML-DSA-65 | ML-DSA-65 | Yes |
| ML-DSA-87 | ML-DSA-87 | Yes |
| ECDSA P-256 | ES256 | No |
| RSA-2048 / RSA-4096 (RSASSA-PSS) | PS256 | No |
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"
}
| Status | Code | Applies to | Meaning |
|---|---|---|---|
| 400 | INVALID_REQUEST | All | The body failed validation (details lists the problems) |
| 401 | AUTHENTICATION_FAILED | All | Missing, invalid, expired or revoked API key |
| 403 | GRANT_INVALID | Grant | The signing grant is invalid, expired or already used |
| 403 | GRANT_PAYLOAD_MISMATCH | Grant | The grant was issued for different content |
| 403 | OPERATION_NOT_ALLOWED | Agent, service | The policy does not grant sign |
| 403 | POLICY_INACTIVE | Agent, service | The policy is not active |
| 403 | TENANT_FROZEN | Agent, service | The organization is suspended |
| 403 | AGENT_REVOKED | Agent | The agent has been revoked |
| 403 | AGENT_FROZEN | Agent | The agent is frozen |
| 403 | SERVICE_FROZEN | Service | A service on the policy's connection (source or destination) is frozen |
| 403 | SERVICE_DEACTIVATED | Service | A service on the policy's connection has been deactivated |
| 404 | POLICY_NOT_FOUND | Service | The key's policy no longer exists or has no source service |
| 409 | NO_SIGNING_KEY | Agent | The agent has no usable signing key |
| 409 | SIGNING_KEY_MISSING | Service | The service policy has no active signing key |
| 429 | RATE_LIMITED | All | Too many sign requests for this principal. Honor Retry-After. |
| 500 | INTERNAL_ERROR | All | Signing 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;
}
Related
- POST /verify: verify a signed message
- Error Codes: full error reference