Security
Apertur is built with security at every layer. This guide covers the tools and best practices for protecting your API keys, verifying webhook payloads, and securing your account.
API Key Security
API keys are the primary way to authenticate with the Apertur API. Keeping them secure is critical to protecting your account and your users' data.
Allowed Sources
Restrict your API key to specific IP addresses, CIDR ranges, or hostnames so that only trusted sources can use it. Hostnames are resolved via DNS and matched against the caller's IP on every request.
- Open your project and go to Settings > API Keys.
- Click the key you want to restrict.
- Under Allowed Sources, add one IP address, CIDR range, or hostname per line.
- Click Save. Requests from sources not on the list will be rejected with a 403 error.
Add a trailing # label or ; label to any entry for your own reference, for example 1.2.3.4/24 # server 1 — labels are ignored when matching.
Key Expiry
Set a date after which the key stops working, the same way as with a manually revoked key. Configure it when creating the key, or add or change it later from the key's settings — leave it empty for a key that never expires.
Key Rotation
Rotate your API keys regularly, especially if you suspect a key has been compromised. You can create a new key and migrate your integration before revoking the old one — both keys can be active simultaneously during the transition.
Important
Never commit API keys to source control, embed them in client-side code, or share them in plaintext. Use environment variables or a secrets manager.
TOTP for API Keys
For an extra layer of security, you can require a time-based one-time password (TOTP) with every API request that uses a specific key.
- Open your API key settings and click Enable TOTP.
- Scan the QR code with your authenticator app (Google Authenticator, Authy, 1Password, etc.).
- Enter the 6-digit code to verify setup.
- From now on, include the TOTP code in the X-APTR-TOTP header with every request.
The header name is X-APTR-TOTP. Codes are valid for 30 seconds with a tolerance of one time step.
curl -X POST https://api.apertur.ca/v1/sessions \
-H "Authorization: Bearer aptr_live_xxxx" \
-H "X-APTR-TOTP: 123456" \
-H "Content-Type: application/json" \
-d '{ "delivery_mode": "webhook", "webhook_url": "https://..." }'Tip
TOTP for API keys is ideal for high-security environments such as financial services or healthcare. For most use cases, IP allowlisting provides sufficient protection.
Client Certificates (mTLS)
Mutual TLS (mTLS) provides the highest level of API authentication by requiring a client certificate with every request, in addition to your API key.
- Generate a client certificate and private key (or use one issued by your organisation's CA).
- Upload the certificate to your API key settings under Client Certificates.
- Apertur will validate the certificate on every request.
- Include both the certificate and key when making API calls (see example below).
- Requests without a valid client certificate will be rejected with a 403 error.
# cURL with client certificate
curl -X POST https://api.apertur.ca/v1/sessions \
--cert client.crt \
--key client.key \
-H "Authorization: Bearer aptr_live_xxxx" \
-H "Content-Type: application/json" \
-d '{ "delivery_mode": "webhook", "webhook_url": "https://..." }'Session Passwords
You can protect individual upload sessions with a password. When set, end-users must enter the password before they can upload photos.
curl -X POST https://api.apertur.ca/v1/sessions \
-H "Authorization: Bearer aptr_live_xxxx" \
-H "Content-Type: application/json" \
-d '{
"delivery_mode": "webhook",
"webhook_url": "https://your-app.com/webhook",
"password": "claim-4521-pin"
}'Passwords are hashed using bcrypt on the server. Apertur never stores passwords in plaintext and they cannot be retrieved after creation.
Use Case
Session passwords are useful for sensitive workflows, such as insurance claims or medical photo submissions, where you want to ensure only the intended recipient can upload.
SDK Origin Validation
When using the aptr-connect SDK, you can restrict which domains are allowed to use your public key by configuring allowed domains on your OAuth app. The server validates the Origin header of incoming requests against your allowed domains list.
Wildcards are supported: *.example.com matches any subdomain at any depth. Leave the list empty during development to allow all origins.
Configure allowed domains in your partner OAuth app settings.
Webhook Signature Verification
Every webhook delivery includes an X-APTR-Signature header containing an HMAC-SHA256 signature of the request body. Verify this signature to ensure the payload was sent by Apertur and hasn't been tampered with.
const crypto = require("crypto");
function verifyWebhook(body, signatureHeader, secret) {
const expected = "sha256=" +
crypto.createHmac("sha256", secret)
.update(body)
.digest("hex");
return crypto.timingSafeEqual(
Buffer.from(expected),
Buffer.from(signatureHeader)
);
}
// In your Express handler:
app.post("/webhook", express.raw({ type: "*/*" }), (req, res) => {
if (!verifyWebhook(req.body, req.headers["x-aptr-signature"], WEBHOOK_SECRET)) {
return res.status(401).send("Invalid signature");
}
// Safe to process...
res.status(200).end();
});import hmac
import hashlib
def verify_webhook(body: bytes, signature: str, secret: str) -> bool:
expected = "sha256=" + hmac.new(
secret.encode(), body, hashlib.sha256
).hexdigest()
return hmac.compare_digest(expected, signature)Security Note
Always use a constant-time comparison function (like timingSafeEqual or hmac.compare_digest) to prevent timing attacks when verifying signatures.
Account Security
Beyond API key security, protect your Apertur account itself with these measures.
Two-Factor Authentication (2FA)
Enable 2FA to require a second verification step when logging in.
- Go to Account Settings > Security.
- Click Enable Two-Factor Authentication.
- Scan the QR code with your authenticator app.
- Enter the verification code and save your recovery codes in a safe place.
- From now on, you'll need your authenticator code every time you log in.
Passkeys
Passkeys provide a passwordless, phishing-resistant login experience using biometrics or a hardware security key.
- Go to Account Settings > Security.
- Click Add Passkey.
- Follow your browser's prompts to register a passkey (fingerprint, Face ID, or security key).
- You can now log in using your passkey instead of a password.
Login Alerts
Apertur sends an email notification when your account is accessed from a new device or location. Review these alerts promptly and change your password if you don't recognise the activity.
Related Articles
Was this article helpful?
Need more help? Contact our support team.