API documentation
Authorization: Bearer <your API key>Quick start
1. Create an encryption key:
curl -X POST https://www.postquantic.com/api/v1/keys \
-H "Authorization: Bearer pq_live_..." \
-H "Content-Type: application/json" \
-d '{"type":"kem","label":"Acme case files"}'2. Encrypt a text with the id you received:
curl -X POST https://www.postquantic.com/api/v1/encrypt \
-H "Authorization: Bearer pq_live_..." \
-H "Content-Type: application/json" \
-d '{"key_id":"key_0123456789abcdef0123","plaintext":"Account number 0000-1111"}'3. Store the ciphertext in your database and decrypt it when you need it:
curl -X POST https://www.postquantic.com/api/v1/decrypt \
-H "Authorization: Bearer pq_live_..." \
-H "Content-Type: application/json" \
-d '{"ciphertext":"pq1.key_0123456789abcdef0123.1.AQEB..."}'
PHP example (no dependencies)
<?php
function pq(string $path, array $body): array {
$ch = curl_init('https://www.postquantic.com/api/v1/' . $path);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('PQ_API_KEY'), 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$res = json_decode(curl_exec($ch), true);
curl_close($ch);
return $res;
}
$c = pq('encrypt', ['key_id' => 'key_0123456789abcdef0123', 'plaintext' => 'sensitive value']);
$p = pq('decrypt', ['ciphertext' => $c['ciphertext']]);
echo $p['plaintext'];
JavaScript example (Node 18+ or server)
const pq = async (path, body) => (await fetch('https://www.postquantic.com/api/v1/' + path, {
method: 'POST',
headers: { Authorization: 'Bearer ' + process.env.PQ_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify(body),
})).json();
const { signature } = await pq('sign', { key_id: 'key_...', message: 'Contract 42 approved' });
const { valid } = await pq('verify', { signature, message: 'Contract 42 approved' });Endpoints
| Method | Path | What it does |
|---|---|---|
| GET | /health | Service status and algorithms (no authentication) |
| POST | /keys | Creates a key: type = kem (encryption) or sig (signature); optional label |
| GET | /keys | Lists your keys; optional filter ?type=kem|sig |
| GET | /keys/{id} | Key details, with its current public key |
| POST | /keys/{id}/rotate | Creates a new version; older versions keep decrypting and verifying |
| DELETE | /keys/{id} | Disables the key: it stops encrypting, decrypting and signing |
| GET | /public-keys/{id} | Public key of an active key (no authentication), so third parties can verify |
| POST | /encrypt | key_id + plaintext (text) or data (base64); optional aad → ciphertext |
| POST | /decrypt | ciphertext + the same aad → data (base64) and plaintext if it's text |
| POST | /sign | key_id + message or data; optional context (≤255 bytes) → signature |
| POST | /seal | Encrypts plaintext or data to a given MLKEM768-X25519 public_key → envelope |
| GET | /tunnel/{site}/config | Public configuration used by tunnel.js (no authentication, allowed origins only) |
| POST | /verify | signature + message or data + the same context → valid |
| POST | /login/check | user (user hash) + visitor ip → allowed, retry_after, human |
| POST | /login/result | user + ip + success (true/false) |
| POST | /human/challenge | Optional ip → challenge (human-verification challenge, 10 minutes) |
| POST | /human/verify | pass → human (true/false) and reason; each pass works only once |
| GET | /tunnel/{site}/challenge | Challenge for the tunnel (no authentication, allowed origins only) |
| POST | /report | An installation's status for the dashboard: stats (counts) and usage |
| GET | /domains | Your domains, with their TXT verification record and last grade |
| POST | /domains | host → registers a domain (or returns the existing one) |
| POST | /domains/{host}/verify | Checks the TXT record and marks the domain as verified |
| GET | /plugins/wordpress | WordPress plugin ZIP configured with the key making the request |
AAD (associated data)
The aad field isn't encrypted, but it's bound to the ciphertext: to decrypt you must send exactly the same value. Use it to tie the value to its context, for example "customer:1042|field:id_document"; that way a ciphertext copied to another record can't be opened.
Formats
Ciphertext: pq1.<key_id>.<version>.<envelope>. Signature: pqs1.<key_id>.<version>.<signature>. Store them as they are; they include the key version needed to open or verify them.
Sample response
{
"ok": true,
"ciphertext": "pq1.key_0123456789abcdef0123.1.UQEB...",
"key_id": "key_0123456789abcdef0123",
"version": 1
}
Simple SDK: passwords, data and files
The easiest way to use the platform. Download pq.php or pq.mjs from the portal (they come with the URL already set) and use your API key. You don't pick algorithms or create keys: the first call sets everything up.
<?php
// 1. Copy pq.php next to your code
require __DIR__ . '/pq.php';
// 2. Your API key (best kept in the PQ_API_KEY environment variable)
$pq = new PQ(getenv('PQ_API_KEY') ?: 'pq_live_YOUR_KEY');
// Sign-up: store $hash instead of the password (255-character column)
$hash = $pq->hashPassword($_POST['password']);
// Sign-in: also accepts your old password_hash() hashes and migrates them automatically
$ok = $pq->verifyPassword($_POST['password'], $user['password'], function ($new) use ($db, $user) {
$db->prepare('UPDATE users SET password = ? WHERE id = ?')->execute([$new, $user['id']]);
});
// Store encrypted (the second argument binds the value to its field)
$phone = $pq->encrypt($_POST['phone'], 'users.phone');
// Read
echo $pq->decrypt($row['phone'], 'users.phone');
// Search without decrypting: also store the index in another column
$index = $pq->index($_POST['email']);
// SELECT * FROM users WHERE email_index = ?
// Encrypt an uploaded file (store it outside public_html)
$pq->encryptFile($_FILES['document']['tmp_name'], '/home/USER/private/doc-42.pq');
// Decrypt when needed
$pq->decryptFile('/home/USER/private/doc-42.pq', '/tmp/doc-42.pdf');| What you protect | What travels to the platform | Stored format |
|---|---|---|
| Passwords | A slow hash (PBKDF2-SHA256, 600,000 iterations), never the password | pqp1$… |
| Data | Nothing of the value; only a data key is requested, stored wrapped with MLKEM768-X25519 | pqd1.dk_….… |
| Searches | The value to index (normalized), to compute an HMAC with your secret | pqi1.… |
| Files | Nothing of the file; it's encrypted on your server in 1 MiB blocks with AES-256-GCM | file.pq |
The PHP and Node SDKs use the same formats: what one encrypts, the other reads. If your database is stolen, the password hashes are useless without the "pepper" that lives in the platform's vault.
WordPress (no code)
In the portal, Integrate → User sign-in downloads a plugin with your key included. Upload it in Plugins → Add New → Upload Plugin, and turn it on with one click in Settings. Existing users get protected automatically on their next sign-in; if the plugin is deactivated, protected users reset their password by email.
Endpoints the SDK uses (in case you integrate another language): POST /password/harden, POST /index, POST /datakey, POST /datakey/unwrap.
Sign-in protection
Post-quantum encryption protects how passwords are stored and how they travel, but it doesn't make a weak password safe: "12345" is guessed in the first few attempts. These four pieces guard the front door:
| Piece | What it does | SDK |
|---|---|---|
| Weak or leaked passwords | Rejects them at sign-up or password change: too short, among the most common, sequences, containing the user's name or email, or found in leaks (the lookup uses k-anonymity: only 5 characters of the SHA-1 leave your server) | checkPassword() |
| Prompt at sign-in | Detects at sign-in who is using a weak password so you can ask them to change it | isWeakPassword() |
| Attempt limiting | A 15 to 30 minute pause after 5 failures from the same user and IP, or 30 failures from one IP. A user attacked from many IPs switches to requiring human verification, without locking out the owner | loginCheck() · loginResult() |
| Invisible human verification | The browser solves a small proof of work in the background (under a second) and gets a single-use pass. No images or puzzles | humanField() · verifyHuman() |
// Sign-up or password change: reject weak or leaked passwords
$r = $pq->checkPassword($_POST['password'], [$_POST['username'], $_POST['email']]);
if (!$r['ok']) { $errors = $r['problems']; }
// In your sign-in (and sign-up) form, inside the <form>:
echo $pq->humanField(['start' => 'load']);
// When the sign-in arrives:
$g = $pq->loginCheck($_POST['username']);
if (!$g['allowed']) { exit('Too many attempts. Please wait a few minutes.'); }
if (!$pq->verifyHuman()) { exit('Reload the page and try again.'); }
$ok = $pq->verifyPassword($_POST['password'], $user['password']);
$pq->loginResult($_POST['username'], $ok);
if ($ok && $pq->isWeakPassword($_POST['password'])) { /* ask them to change it */ }If the platform doesn't respond, attempt limiting and human verification let people through: they never block your sign-in because of an external failure. Human verification needs JavaScript.
Your own forms with the script
humanField() prints two hidden fields and the human.js script. If your page is cached, add data-refresh with a URL on your site that returns {"challenge": "..."} (for example, by calling humanChallenge()) and the script will request a fresh challenge when needed. In apps using fetch(): const pass = await PQHuman.solve(challenge) and send it in the X-PQ-Human header.
WordPress
The plugin (version 1.1 and later) includes the four pieces in Settings, no code: weak-password rejection, prompt at sign-in, attempt limiting and human verification on sign-in, registration, "Lost your password?" and comments (also on WooCommerce forms).
Tunnel for websites
Encrypts your website's fetch() calls from the browser to your server with a single line. Create the site in the customer portal and copy the snippet it gives you (it includes integrity):
<script src="https://www.postquantic.com/tunnel.js" data-site="site_0123456789abcdef0123" integrity="sha384-..." crossorigin="anonymous"></script>
On your server, use the pqtunnel.php SDK (download it from the portal) in the protected endpoints:
<?php
require __DIR__ . '/pqtunnel.php';
$tunnel = new PQTunnel([
'site_id' => 'site_0123456789abcdef0123',
'mode' => 'platform',
'api_url' => 'https://www.postquantic.com/api/v1',
'api_key' => getenv('PQ_API_KEY'),
]);
$order = $tunnel->json(); // decrypted body
$tunnel->respondJson(['ok' => true]); // encrypted response to the browser| Mode | Who decrypts | Requirements |
|---|---|---|
| Platform | The API, in memory; the content is never stored | An API key on your server |
| End to end | Your server, with a private key that never leaves it | The engine (pqengine) and proc_open on your server |
Protocol details: the body travels as application/pq-tunnel; the encryption is bound to the site, the method and the path, so it can't be replayed to another endpoint. Each page load generates an ephemeral key so your server can encrypt the response. For now fetch() calls are covered; classic forms and XMLHttpRequest will come later.
Human verification in the tunnel
In the portal, on your site, set the paths with human verification (for example /login, /signup). Every submission to those paths carries a single-use pass in the X-PQ-Human header that is also bound to the encryption: replaying a captured request doesn't work (its pass was already used) and changing the pass breaks decryption. On your server:
$tunnel = new PQTunnel([
'site_id' => 'site_0123456789abcdef0123',
'mode' => 'platform',
'api_url' => 'https://www.postquantic.com/api/v1',
'api_key' => getenv('PQ_API_KEY'),
'require_human' => true, // responds 403 if the pass is missing, already used or invalid
]);
Integrations
Download them from the portal under Downloads: they come with the platform URL already set.
WHM/cPanel servers
Protects every site on a server. Install it as root with sh install.sh, open WHM → Plugins → Postquantic, paste an API key and click "Protect all domains". For each domain it registers it in your account, creates its TXT verification record in the server's DNS zone, verifies it and installs the plugin on each WordPress (as the account's user, never as root). New accounts get protected automatically and it checks for new sites every day. If a domain's DNS is hosted elsewhere, add the TXT record by hand.
php /usr/local/cpanel/whostmgr/docroot/cgi/postquantic/sync.php --user=john
Laravel
# .env
PQ_API_KEY=pq_live_...
HASH_DRIVER=postquantic
// Model: encrypted field
protected $casts = ['phone' => \Postquantic\Laravel\Casts\Encrypted::class];
// Sign-up: weak or leaked passwords
'password' => ['required', 'confirmed', new \Postquantic\Laravel\Rules\StrongPassword],
// Sign-in route and, inside the <form>, @pqHuman('load')
Route::post('/login', [LoginController::class, 'store'])->middleware('pq.login');Existing bcrypt or argon hashes keep working and migrate automatically at sign-in.
Python and Django
# settings.py
PQ_API_KEY = 'pq_live_...'
PASSWORD_HASHERS = ['pq_django.PQPasswordHasher', 'django.contrib.auth.hashers.PBKDF2PasswordHasher']
AUTH_PASSWORD_VALIDATORS = [{'NAME': 'pq_django.PQPasswordValidator'}]
# models.py
from pq_django import EncryptedTextField
phone = EncryptedTextField()Outside Django, pq.py has the same functions as the PHP SDK: hash_password, verify_password, encrypt, decrypt, index, encrypt_file, check_password, login_check, human_field and verify_human. It only needs the cryptography package.
PrestaShop
Upload the ZIP under Modules → Module Manager → Upload a module. It rejects weak or leaked passwords at sign-up, slows down anyone guessing and filters bots on sign-in and sign-up with invisible human verification. If you download it "with my key included", it's connected as soon as it's installed.
Protection dashboard
In the portal, Protection shows what's protected and what's missing across five areas (server connection, passwords, sign-in, data and files, tunnel), with a 0 to 100 index, email alerts and daily monitoring of your verified domains (a TXT record in your DNS).
To build it, the platform only uses counts: how many operations each piece performed, names of protected fields and paths, and the totals each installation reports. It never receives passwords, data or files. The WordPress plugin reports on its own; with the SDK, send your totals whenever you like (for example, with a daily task):
$pq->report([
'users_total' => 530, // users with a password
'users_protected' => 412, // with a pqp1$… hash
'users_weak' => 37, // detected with isWeakPassword()
'throttle' => true, // you use loginCheck()
'human' => true, // you use verifyHuman()
], 'my-platform', 'https://acme.example');Encryption and file counts are sent automatically at most every 10 minutes; you can turn this off with the telemetry => false option.
Analytics and leak detection
In the portal, Analytics shows attack attempts per hour or per day (failed sign-ins, attempts stopped, bots rejected and tampered requests), the most targeted IPs and accounts, data decryption and the servers using your API keys. From there, or from each alert, you can block an IP or revoke a key in one click.
| Signal | What triggers it |
|---|---|
| New server | An API key with history is used from an IP it had never used (typical of a key copied from an .env file or a backup) |
| Mass decryption | Far more data keys than usual are opened within an hour (this is what a full export looks like) |
| Unusual hour | Decryption at a time of day when your application almost never does it |
| Key in the browser | A secret key makes requests from a web page |
| Decoy touched | Someone decrypts a decoy value or uses a trap key |
Decoys
A decoy value is a fake value encrypted in the same format as the SDK (pqd1.…). Create it in Analytics, store it in a fake row of your table (for example, a customer who doesn't exist) and never read it from your application. If someone decrypts it, they almost certainly had a copy of your database and your key: you get an instant alert with the time and IP. The API responds normally, so whoever decrypts it doesn't know they triggered an alert.
A trap key looks like a real API key. Leave it where an intruder would look (an old .env, a backup, a private repository). If someone uses it, it responds like an invalid key and alerts you.
The limit: we only see what goes through the platform. Data you store unencrypted triggers no signal if it leaks; that's why it pays to encrypt sensitive fields and plant decoys.
Errors and limits
{
"ok": false,
"error": { "code": "rate_limited", "message": "Límite de peticiones por minuto excedido" }
}The message field is meant for logs and comes in Spanish; use code in your logic.
| HTTP | Code | Meaning |
|---|---|---|
| 400 | invalid_request | A field is missing or has the wrong format |
| 401 | unauthorized | API key missing, invalid or revoked |
| 404 | not_found | The key or the path doesn't exist |
| 409 | key_disabled | The key is disabled |
| 413 | payload_too_large | The data exceeds the maximum size |
| 422 | decrypt_failed | Couldn't decrypt: different AAD, wrong key or tampered data |
| 402 | payment_required | The account's plan has expired. Decrypting and verifying keep working |
| 403 | ip_blocked | The IP is blocked for that key or for your sites |
| 429 | rate_limited | Too many requests; check Retry-After |
| 503 | maintenance | Service under maintenance |
Every authenticated response includes X-RateLimit-Limit and X-RateLimit-Remaining.