Embedded Signing — Send Contracts from Templates and Sign Inside Your App
Most contracts go out by email. You send it, the signer gets a link and signs when they get to it. That works well when the signer is somewhere else.
Sometimes, though, the person who needs to sign is already in your app: booking a tour, starting a lease, accepting a quote. Sending them off to their inbox to sign something they could sign right where they are is the step where people drop off.
Fjordvik Kayaks has that problem. Customers book tours in the Fjordvik mobile app, and every paddler has to sign a liability waiver before they get a boat. Until now, staff handed out paper waivers at the jetty. What they want is simple: book, sign in the app, done.
Here's how to build it:
- Send a contract from a template in code, with examples in curl, TypeScript and Python.
- Open the signer's link inside your app: in an iframe on the web, and with Expo WebBrowser or a WebView on mobile.
- Find out when it's signed.
How embedded signing works
Every signer on a contract has their own signing link:
https://apisign.io/sign/{contract_id}/{signer_id}
You get both IDs back when you create the contract, and the link opens as soon as the contract is sent. So "embedded signing" is just that link, opened inside your app instead of from an email:
- Your server creates a contract from a template and sends it.
- Your server gives the link to the signed-in user who is that signer.
- Your app opens it.
Two rules shape everything below:
- Your API key stays on your server. It can create and send contracts on your account, and spend your balance. Never put it in a web bundle or a mobile app. Your app talks to your server, and your server talks to APISign.
- The signing link is the signer's key. Anyone who has it can sign as that person. Only show it to the signed-in user it belongs to, and keep it out of logs and analytics.
One more thing to know up front: sending still emails the signer. Embedded signing adds a second way to sign; it doesn't replace the email. Whichever one they use first, the contract is signed once. If they open the emailed link afterwards, it tells them they've already signed.
Here's the whole flow on a phone, done each of the three ways this post covers:
- 01Tap to signYour page asks your server for the customer's signing link.
- 02Show it in an iframeThe signing page loads inside your page. The address bar still says fjordvik.com.
- 03SignThey read the waiver and draw their signature with a finger.
- 04Back to your pageYour page checks with your server every few seconds. Once it's signed, your own message replaces the iframe.
1. Send a contract from a template
You'll need a template with a signature field, and an API key. Fjordvik started from the Liability Waiver in our template library and set the participant's name, the tour and the date as fields Fjordvik fills in, so each waiver is made out to one paddler. How to Send a Contract for Signature covers setting up a template.
For the key, go to Developers → Access keys in the dashboard and create a key with Read & write access. Keep it in an environment variable on your server:
export APISIGN_API_KEY="your-api-key"
Every request goes to https://apisign.io/api with the key in an x-api-key header.
Try it with curl
Three requests take you from template to signing link. First, find your template's ID:
curl -s https://apisign.io/api/template/find \
-H "x-api-key: $APISIGN_API_KEY"
Create a contract from it. variables fills in the template's fields, and test_mode makes it free while you build (more on that below):
curl -s https://apisign.io/api/contract/create \
-H "x-api-key: $APISIGN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Waiver: Maya Berg, Sunset Paddle",
"template_id": "YOUR_TEMPLATE_ID",
"variables": {
"participant_name": "Maya Berg",
"activity_description": "Sunset Paddle, guided sea kayak tour",
"activity_dates": "June 14, 2027"
},
"signers": [
{ "name": "Maya Berg", "email": "maya@example.com", "signing_order": 1 }
],
"test_mode": true
}'
The response has the contract's id and, under signers, each signer's id. Then send it:
curl -s https://apisign.io/api/contract/send \
-H "x-api-key: $APISIGN_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "contract_id": "THE_CONTRACT_ID" }'
Now open https://apisign.io/sign/THE_CONTRACT_ID/THE_SIGNER_ID in your browser. That's the page your app will show.
A small helper in TypeScript
Here's a helper the rest of the post uses. It runs on your server, never in the app:
// apisign.ts: server only, it holds your API key
const API = "https://apisign.io/api";
export async function apisign<T>(path: string, body?: unknown): Promise<T> {
const res = await fetch(`${API}${path}`, {
method: body === undefined ? "GET" : "POST",
headers: {
"x-api-key": process.env.APISIGN_API_KEY!,
"Content-Type": "application/json",
},
body: body === undefined ? undefined : JSON.stringify(body),
});
const data = await res.json();
if (!res.ok) {
throw Object.assign(new Error(data.error ?? `APISign responded ${res.status}`), {
status: res.status,
});
}
return data as T;
}
Check what a template needs
A template has two kinds of fields: the ones you fill in when you create a contract (creator fields), and the ones the signer fills in (their signature, the date, maybe a phone number). Every creator field needs a value, or /contract/create refuses the request:
{ "error": "Missing required variables: activity_dates. All creator fields must be provided when using a template." }
That's better than a waiver with a blank where the date should be, but it's better still to find out before a customer does. /template/get lists the template's fields, so you can check that your code supplies every creator field when your server starts:
type Template = {
fields: { fields: { name: string; completedBy: "creator" | "signer" }[] } | null;
};
const { template } = await apisign<{ template: Template }>(
`/template/get?id=${process.env.APISIGN_WAIVER_TEMPLATE_ID}`,
);
const creatorFields = (template.fields?.fields ?? [])
.filter((field) => field.completedBy === "creator")
.map((field) => field.name);
// Fjordvik fills in these three. Fail at boot, not on a customer's booking.
const supplied = ["participant_name", "activity_description", "activity_dates"];
const missing = creatorFields.filter(
(name) => !supplied.some((s) => s.toLowerCase() === name.toLowerCase()),
);
if (missing.length) throw new Error(`Waiver template needs: ${missing.join(", ")}`);
Variable names are matched without regard to case, so the check is too. A variable without a field definition is always the signer's to fill in, so creatorFields is the complete list of what you must supply.
Send it when a booking is confirmed
Fjordvik sends the waiver once, from the code that already confirms bookings:
import { apisign } from "./apisign";
type Created = {
contract: { id: string };
signers: { id: string; email: string }[];
};
export async function sendWaiver(booking: Booking) {
const { contract, signers } = await apisign<Created>("/contract/create", {
name: `Waiver: ${booking.customerName}, ${booking.tourName}`,
template_id: process.env.APISIGN_WAIVER_TEMPLATE_ID,
variables: {
participant_name: booking.customerName,
activity_description: booking.tourName,
activity_dates: booking.tourDate,
},
signers: [
{ name: booking.customerName, email: booking.customerEmail, signing_order: 1 },
],
expires_in_days: 30,
metadata: { booking_id: booking.id },
});
// Save the IDs before sending. If the send fails, the draft is still
// there, and you can send it again later.
await db.bookings.update(booking.id, {
waiverContractId: contract.id,
waiverSignerId: signers[0].id,
});
await apisign("/contract/send", { contract_id: contract.id });
}
Creating a contract is free, and sending one costs $0.25. Two errors are worth handling on purpose:
- 400 means something is wrong with the contract itself, such as a missing creator field. The
errormessage says what. - 402 means there isn't enough credit to send. Nothing is lost: the draft is saved, so add credit and send it again.
The same in Python
If your backend is Django, Flask or FastAPI, it's the same two calls:
import os
import requests
API = "https://apisign.io/api"
session = requests.Session()
session.headers["x-api-key"] = os.environ["APISIGN_API_KEY"]
def apisign(path, body=None):
if body is None:
res = session.get(API + path, timeout=30)
else:
res = session.post(API + path, json=body, timeout=30)
data = res.json()
if not res.ok:
raise RuntimeError(data.get("error", f"APISign responded {res.status_code}"))
return data
def send_waiver(booking):
created = apisign("/contract/create", {
"name": f"Waiver: {booking.customer_name}, {booking.tour_name}",
"template_id": os.environ["APISIGN_WAIVER_TEMPLATE_ID"],
"variables": {
"participant_name": booking.customer_name,
"activity_description": booking.tour_name,
"activity_dates": booking.tour_date,
},
"signers": [
{"name": booking.customer_name, "email": booking.customer_email, "signing_order": 1}
],
"metadata": {"booking_id": booking.id},
})
# Save the IDs before sending, so a failed send can be retried.
booking.waiver_contract_id = created["contract"]["id"]
booking.waiver_signer_id = created["signers"][0]["id"]
booking.save()
apisign("/contract/send", {"contract_id": booking.waiver_contract_id})
2. Give your app the link
Your app needs two things from your server: the signing link, and whether it's been signed yet. One endpoint can answer both. It only reads, so your app can call it as often as it likes:
// GET /api/bookings/:id/waiver: the signed-in customer's waiver
app.get("/api/bookings/:id/waiver", requireUser, async (req, res) => {
// Only the customer who made the booking gets its link.
const booking = await db.bookings.findForUser(req.params.id, req.user.id);
if (!booking?.waiverContractId) return res.sendStatus(404);
const { contract } = await apisign<{ contract: Contract }>(
`/contract/get?id=${booking.waiverContractId}`,
);
const signer = contract.signers.find((s) => s.id === booking.waiverSignerId);
res.json({
// The link only opens while the contract is sent.
signingUrl:
contract.status === "sent"
? `https://apisign.io/sign/${contract.id}/${booking.waiverSignerId}`
: null,
signed: signer?.status === "signed",
});
});
Notice what this endpoint doesn't do: send. Calling /contract/send on a contract that's already been sent is a resend. The signer is emailed again, and the send is charged again. Send once, when the contract is created, and only read after that.
3. Embed it on the web
On the web, the signing page goes straight into an iframe. The page inside the iframe is on apisign.io, so your page can't see what happens in it. Instead, it asks your server every few seconds until the waiver is signed:
import { useEffect, useState } from "react";
type Waiver = { signingUrl: string | null; signed: boolean };
export function SignWaiver({ bookingId }: { bookingId: string }) {
const [waiver, setWaiver] = useState<Waiver | null>(null);
useEffect(() => {
let timer: ReturnType<typeof setTimeout> | undefined;
let stopped = false;
async function check() {
const res = await fetch(`/api/bookings/${bookingId}/waiver`);
const next: Waiver = await res.json();
if (stopped) return;
setWaiver(next);
if (!next.signed) timer = setTimeout(check, 3000);
}
check();
return () => {
stopped = true;
clearTimeout(timer);
};
}, [bookingId]);
if (!waiver) return <p>Loading your waiver…</p>;
if (waiver.signed) return <p>Waiver signed. See you on the water.</p>;
if (!waiver.signingUrl) return <p>Your waiver isn't ready to sign yet.</p>;
return (
<iframe
src={waiver.signingUrl}
title="Sign your waiver"
style={{ width: "100%", height: "min(85dvh, 900px)", border: 0 }}
/>
);
}
A few things that make it feel right:
- Give the iframe real height. The signing page scrolls inside the frame and keeps its Start button pinned to the bottom of it, so a tall panel or a full-screen modal works best. On a phone, let it fill the screen.
- It's already built for touch. Signers draw their signature with a finger or a mouse, inside the frame.
- Add your brand. The signing page shows your organization's name and logo. Set them under Organization → Brand, and it'll look like part of your app.
- Every load is a view. A
contract_viewedwebhook fires each time the page opens, so an iframe that reloads counts as another view.
When the waiver is signed, the component swaps the iframe for your own confirmation, and your app carries on.
4. Embed it in an Expo app
On mobile there are two good ways to open the link: the system's in-app browser, with expo-web-browser, or a WebView inside your own screen, with react-native-webview.
Option A: Expo WebBrowser
expo-web-browser opens the link in the in-app browser that comes with the phone: Safari View Controller on iOS, Chrome Custom Tabs on Android. It slides up over your app, the signer can see they're on apisign.io, and when they're done they tap Done and they're back where they left off.
npx expo install expo-web-browser
import * as WebBrowser from "expo-web-browser";
import { useCallback, useEffect, useState } from "react";
import { ActivityIndicator, AppState, Button, Text } from "react-native";
import { api } from "./api"; // your own API client, with the user's session
type Waiver = { signingUrl: string | null; signed: boolean };
export function WaiverButton({ bookingId }: { bookingId: string }) {
const [waiver, setWaiver] = useState<Waiver | null>(null);
const refresh = useCallback(async () => {
setWaiver(await api.get<Waiver>(`/bookings/${bookingId}/waiver`));
}, [bookingId]);
// Check now, and again whenever the app comes back to the foreground.
useEffect(() => {
refresh();
const subscription = AppState.addEventListener("change", (state) => {
if (state === "active") refresh();
});
return () => subscription.remove();
}, [refresh]);
async function sign() {
if (!waiver?.signingUrl) return;
const result = await WebBrowser.openBrowserAsync(waiver.signingUrl, {
dismissButtonStyle: "done",
controlsColor: "#0f766e",
});
// On iOS this resolves when the signer closes the browser. On Android it
// resolves as soon as the browser opens, and the AppState listener above
// checks again when they come back.
if (result.type !== "opened") refresh();
}
if (!waiver) return <ActivityIndicator />;
if (waiver.signed) return <Text>Waiver signed ✓</Text>;
return <Button title="Sign your waiver" onPress={sign} disabled={!waiver.signingUrl} />;
}
There's no webpage to build and nothing extra to maintain. The trade-off is control: you can't see inside the browser, so you only find out it's signed when the signer comes back to your app.
Option B: a WebView
If you'd rather the signing page sit inside your own screen, with your own header and no browser around it, use a WebView:
npx expo install react-native-webview
import { Linking, Pressable, Text } from "react-native";
import { SafeAreaView } from "react-native-safe-area-context";
import { WebView } from "react-native-webview";
export function WaiverScreen({ signingUrl, onDone }: { signingUrl: string; onDone: () => void }) {
return (
<SafeAreaView style={{ flex: 1 }}>
<Pressable onPress={onDone} style={{ padding: 16, alignSelf: "flex-end" }}>
<Text>Done</Text>
</Pressable>
<WebView
source={{ uri: signingUrl }}
style={{ flex: 1 }}
onShouldStartLoadWithRequest={(request) => {
// Keep the WebView on the signing page, and open any other link
// in the phone's browser.
if (request.url.startsWith(signingUrl)) return true;
Linking.openURL(request.url);
return false;
}}
/>
</SafeAreaView>
);
}
Show it as a modal screen, and check the waiver's status when it closes, just like the WebBrowser example. Or poll every few seconds while it's open, like the iframe, and close it for the signer as soon as they've signed.
Which one?
- Start with WebBrowser. It's the least code, it uses the phone's own browser engine, and the address bar shows the signer exactly where they're signing.
- Use a WebView when the signing step has to look like one of your own screens, or when you want to close it the moment the signer has signed.
If your Expo app also runs on the web, use the iframe component there. openBrowserAsync on the web opens a new tab, which isn't what you want here.
5. Find out when it's signed
The endpoint above asks APISign for the signer's status each time it's called. That's enough for a screen that's waiting. For everything that happens after the app closes, such as confirming the booking or filing the signed PDF, use webhooks.
Add your endpoint under Developers → Webhooks and subscribe to:
contract_signed, when a signer signs. The payload includesdata.signer.id, so you know exactly who.contract_completed, when everyone has signed and the signed PDF is ready. The payload includesdata.contract.final_pdf, its URL.
With a webhook keeping your own database up to date, the status endpoint can read from your database instead of calling APISign. The webhooks docs show how to verify each delivery's signature, in Node.js and Python.
Test it without emailing anyone
Create the contract with "test_mode": true while you build. A test contract runs the whole flow for free. The signing email goes to your organization's billing email (or its owner) instead of the signer, so the customer address in your test data never gets anything. The signed PDF is stamped as a test.
The signing link works exactly the same. You can create a contract, open it in your iframe or app, sign it, and watch your status endpoint flip to signed, all without spending anything. Test mode is set when a contract is created and can't be changed, so remove it when you go live.
A short checklist
Before you ship:
- The API key is only on your server. Search your app bundle for it, just to be sure.
- Each link only goes to its signer. Check the user owns the booking before returning its link.
- You send each contract once. Opening the signing screen only reads.
- The deadline fits. Links stop working at the contract's
expires_at: 30 days after creation by default, up to 365. If people sign close to their booking, setexpires_in_daysto cover it. - You've signed a test contract end to end. In the iframe, in WebBrowser on both iOS and Android, or in your WebView.
The Contracts API reference has every field used here, and the Templates API reference covers creating and updating templates from code. If you'd rather an AI agent did the sending, MCP in Practice connects one with the same API key.
No account yet? Sign up: your first 20 contracts are free, and test contracts cost nothing at all.
