Worker recipes
Recipe: app approval
A signing worker for a provider that sends a push notification to the signer's phone, where they approve the signature in the provider's app, using the poll channel
Public beta. Qualified signatures are available on request, with any qualified trust service provider you choose and at no extra charge during the beta. See Request access. SWP/1 is in beta and may change.
This recipe fits a provider that:
- already knows the signer, who installed its app and enrolled earlier,
- keeps a long-term certificate for them, and
- asks for approval with a push notification: the signer opens the app, checks what they sign and confirms with a PIN or biometrics.
The signer never leaves the ceremony. Your worker answers authorize with poll_after instead of a URL, and SignatureAPI asks again until the signer has decided. Not sure this is your provider? See Choose your provider’s model.
The flow
Certificate and push
- Signer's browser to SignatureAPI: Finish the ceremony
- SignatureAPI to Your worker:
POST /v1/credential - Your worker to Provider: Look up the signer's certificate
- Your worker to SignatureAPI:
completedwithcertificates,key_algo_oids - SignatureAPI: Compute the digest
- SignatureAPI to Your worker:
POST /v1/authorizewith the digest and itslabel - Your worker to Provider: Start an approval request
- Provider to Signer's phone: Push notification
- Your worker to SignatureAPI:
pendingwith"poll_after": 3
pendingwith"poll_after": 3The ceremony shows **Waiting for your confirmation**. The signer stays in it.
Dashed: a reply, or an asynchronous call such as a webhook.
Polling
- SignatureAPI to Your worker:
POST /v1/authorizeagain, same body, everypoll_afterseconds - Signer's phone to Provider: The signer checks the document name and confirms with a PIN or biometrics
- SignatureAPI to Your worker: Next poll
- Your worker to Provider: Check the request
- Provider to Your worker: Approved
- Your worker to SignatureAPI:
completedwith an authorization reference
POST /v1/authorizeagain, same body, everypoll_aftersecondsYour worker checks the request at the provider and answers
pendingwhile the signer hasn't decided. Don't send a new push notification on each poll.
Dashed: a reply, or an asynchronous call such as a webhook.
Signing
- SignatureAPI to Your worker:
POST /v1/sign - Your worker to Provider: Sign the hash
- Your worker to SignatureAPI:
completedwithsignatures - SignatureAPI to Signer's browser: **Finalizing your signature…**
Dashed: a reply, or an asynchronous call such as a webhook.
1. credential: look up the certificate
The provider already has the signer’s certificate. Find it, and answer completed with the chain and key_algo_oids, as in the CSC recipe. If your provider returns a complete CMS, add "signature_format": "cms" instead. The polling below works the same in both formats.
If the signer isn’t enrolled, answer failed with credential_unavailable, and tell them in error_description what to do, for example which app to install.
2. authorize: push once, then report
A poll repeats the call, not the act. SignatureAPI sends the same body, with the same Idempotency-Key, every time. Your worker must start the approval once, then report on it.
async function authorize(body) {
const sessionId = body.session.id;
let request = await store.get(`approval:${sessionId}`);
if (!request) {
// First call: start the approval, which sends the push
request = await provider.startApproval({
user: await userFor(body.signer),
hash: body.digests[0].value,
text: `Sign "${body.digests[0].label}"`,
});
await store.set(`approval:${sessionId}`, request);
}
const state = await provider.getApproval(request.id); // Every later call: check, never push again
switch (state.status) {
case "approved":
return { status: "completed", authorization: { reference: state.sad } };
case "declined":
return { status: "failed", error: "access_denied", error_description: "You declined the signature in the app." };
case "expired":
return { status: "failed", error: "authorization_expired", error_description: "The request in the app expired." };
default:
return { status: "pending", poll_after: 3, expires_at: request.expiresAt };
}
}Run this inside your idempotency handler. It stores only final outcomes, so each poll reaches your code again while the answer is pending.
poll_afteris the wait in seconds. SignatureAPI keeps it between 1 and 60. A few seconds keeps the ceremony responsive.expires_atis when the provider gives up on the request. It can shorten the connection’s Authorization timeout, never extend it. When the deadline passes, the session fails withauthorization window expired.- The
labelis the envelope title. Show it in the app, so the signer knows what they confirm.
In CSC terms, this is an out-of-band authorization: credentials/authorize answers 202 while the signer decides, and credentials/authorizeCheck reports the result. Map 202 to pending and the final result to completed or failed.
What the signer sees
With poll_after and no action_url, the ceremony shows Waiting for your confirmation and asks the signer to confirm in their provider’s app or device. It checks with SignatureAPI on its own, and moves on as soon as your worker answers completed.
Offer a page too
Some signers start on a laptop and need a QR code to find the request on their phone. Answer with both channels:
{
"status": "pending",
"action_url": "https://signer.example.com/qr?ticket=6b0e...",
"poll_after": 3,
"expires_at": "2026-08-24T16:45:00Z"
}The ceremony then shows Authorize your signature and sends the browser to your page. SignatureAPI keeps polling at the same time. The first channel to finish wins:
- The poll finishes first. Still redirect your page to
callback_urlwith acode, so the signer gets back to the ceremony. SignatureAPI sees the step is already done and only takes them back. - The redirect finishes first. SignatureAPI calls
authorizewithcallback.code, and stops polling.
3. sign
Spend the approval and sign, as in the CSC recipe, or return the CMS for cms. sign never answers pending.
Test it
- Approve on the phone. The ceremony moves on by itself, without a click.
- Decline on the phone. The ceremony shows your
error_descriptionand Try again. - Ignore the push. The session fails when the deadline passes.
- Count the pushes. A slow signer gets one notification, however many polls arrive.