Integration patterns
Store Envelope Data on Completion
When an envelope completes, receive the webhook, fetch the envelope with the values signers entered, and save them to your database with your own IDs.
After an envelope completes, you may want to store the signing data in your own database or system of record. This guide shows how to detect when an envelope completes using a webhook, retrieve the envelope details (including any captured input from the signer), and persist the data.
Overview
The flow has five steps:
- Register a webhook endpoint for the
envelope.completedevent. - Create the envelope with
capture_ason the places whose values you want, and your own IDs inmetadata. - Receive the
envelope.completedevent when every recipient has finished. - Retrieve the full envelope, including
captures, with the API. - Store the data in your database.
Steps 3 to 5 happen in your webhook endpoint:
- SignatureAPI to Your webhook endpoint: Webhook
envelope.completed - Your webhook endpoint to SignatureAPI: Get the envelope
GET /v1/envelopes/{envelope_id} - SignatureAPI to Your webhook endpoint: Envelope with
capturesandmetadata - Your webhook endpoint to Your database: Save the record
- Your webhook endpoint to SignatureAPI: Respond
200 OK
- Webhook
envelope.completedThe event carries the envelope ID and your
envelope_metadata, but not the captured values. - Save the record
Upsert by envelope ID, so a redelivered event writes the same row again instead of a duplicate.
Dashed: a reply, or an asynchronous call such as a webhook.
Step 1: Set Up a Webhook Endpoint
Register a webhook endpoint in the Dashboard and subscribe to the envelope.completed event. See Set Up Webhooks for detailed instructions.
Step 2: Create an Envelope with Captures
When creating the envelope, use capture_as on interactive places to store values entered by the signer. Also use metadata to attach your own identifiers for matching the envelope back to your records.
POST /v1/envelopes HTTP/1.1
Host: api.signatureapi.com
X-API-Key: YOUR_API_KEY
Content-Type: application/json
{
"title": "Order Confirmation",
"metadata": {
"order_id": "ORD-2026-1234",
"customer_id": "cust_5678"
},
"documents": [
{
"url": "https://pub-9cb75390636c4a8a83a6f76da33d7f45.r2.dev/privacy-placeholder.pdf",
"format": "pdf",
"fixed_positions": [
{
"place_key": "reference_number",
"page": 2,
"top": 600,
"left": 72
}
],
"places": [
{
"key": "signer_signs_here",
"type": "signature",
"recipient_key": "customer"
},
{
"key": "reference_number",
"type": "text_input",
"recipient_key": "customer",
"hint": "Your 8-digit reference code",
"capture_as": "reference",
"width": 200
}
]
}
],
"recipients": [
{
"type": "signer",
"key": "customer",
"name": "Jane Doe",
"email": "jane.doe@example.com"
}
]
}The signature sits on the document’s [[signer_signs_here]] placeholder. The text input has no placeholder, so it gets a fixed position below the signature on page 2.
Step 3: Handle the Webhook Event
When the envelope completes, SignatureAPI sends an envelope.completed event to your endpoint:
{
"id": "evt_4GpGD1cNnrkemsTLAvPW9G",
"type": "envelope.completed",
"timestamp": "2026-11-02T15:21:40.000Z",
"data": {
"object_id": "eb4cf433-a8af-4161-b37b-7ef57d423e56",
"object_type": "envelope",
"envelope_id": "eb4cf433-a8af-4161-b37b-7ef57d423e56",
"envelope_metadata": {
"order_id": "ORD-2026-1234",
"customer_id": "cust_5678"
}
}
}The envelope_metadata property reflects the metadata you attached when creating the envelope. You can use these values to match the event to your internal records without making an additional API call.
Step 4: Retrieve the Envelope
If you need data beyond what the webhook event provides (such as captured input from the signer), use the envelope_id from the event to fetch the full envelope.
GET /v1/envelopes/eb4cf433-a8af-4161-b37b-7ef57d423e56 HTTP/1.1
Host: api.signatureapi.com
X-API-Key: YOUR_API_KEYThe response is the full envelope. Trimmed to the fields this guide uses, it looks like this:
{
"id": "eb4cf433-a8af-4161-b37b-7ef57d423e56",
"title": "Order Confirmation",
"status": "completed",
"metadata": {
"order_id": "ORD-2026-1234",
"customer_id": "cust_5678"
},
"captures": {
"reference": "11223344"
},
"completed_at": "2026-11-02T15:21:40.000Z"
}The captures object contains any values the signer entered in interactive places that had capture_as defined.
Step 5: Store the Data
With the envelope details and captures in hand, persist the data to your database. Verify the webhook first, against the raw body and the webhook-* headers (see Verify the Signature). This example uses Express and the Standard Webhooks library:
import express from "express";
import { Webhook } from "standardwebhooks";
const app = express();
const wh = new Webhook(process.env.SIGNATUREAPI_WEBHOOK_SECRET);
app.post("/webhooks/signatureapi", express.raw({ type: "application/json" }), async (req, res) => {
let event;
try {
event = wh.verify(req.body.toString("utf8"), {
"webhook-id": req.header("webhook-id"),
"webhook-timestamp": req.header("webhook-timestamp"),
"webhook-signature": req.header("webhook-signature"),
});
} catch {
return res.status(400).send("Invalid signature");
}
if (event.type === "envelope.completed") {
// Fetch the full envelope to get captures
const response = await fetch(
`https://api.signatureapi.com/v1/envelopes/${event.data.envelope_id}`,
{ headers: { "X-API-Key": process.env.SIGNATUREAPI_KEY } }
);
if (!response.ok) return res.status(500).send("Retry later"); // SignatureAPI retries the event
const envelope = await response.json();
// Upsert by envelope ID: a redelivered event writes the same row again
await db.signingRecords.upsert({
envelope_id: envelope.id,
order_id: envelope.metadata.order_id,
customer_id: envelope.metadata.customer_id,
reference: envelope.captures.reference,
completed_at: envelope.completed_at
});
}
res.status(200).send("OK");
});db.signingRecords.upsert stands for your own database client.
Try It
Send the request with your test API key to create a free, non-binding test envelope, for example from the API Playground. Sign it from the email preview in the Dashboard, then read captures with GET /v1/envelopes/{envelope_id}.
Keep Learning
- Learn more about captures and which place types support them.
- Set up webhooks with signature verification and retry handling.
- Use topics to route events from specific envelopes to different webhook endpoints.
- Download signed documents after the envelope completes.