Zero-gate · self-serve · no sales call
Developer Platform
Encryption API and SDKs
Encrypt your first record in 5 minutes.
SDKs for JavaScript, Python, Java and C. Add object-level encryption to your own application: data is encrypted where it is created, and its key is stored with XQ for the recipients you choose.
import { XQSDK, Authorize, CodeValidator, Encrypt }
from "@xqmsg/jssdk-core";
const sdk = new XQSDK({
XQ_API_KEY: process.env.XQ_API_KEY,
});
// 1. Authorize: XQ emails a PIN to this address
await new Authorize(sdk)
.supplyAsync({ [Authorize.USER]: "me@example.com" });
// 2. Validate the PIN to get an access token
await new CodeValidator(sdk)
.supplyAsync({ [CodeValidator.PIN]: pin });
// 3. Encrypt, then store the key with XQ
const aes = sdk.getAlgorithm("AES");
const { payload } = await new Encrypt(sdk, aes).supplyAsync({
[Encrypt.TEXT]: "Quarterly results",
[Encrypt.RECIPIENTS]: ["jane@example.com"],
[Encrypt.EXPIRES_HOURS]: 24,
});
const token = payload[Encrypt.LOCATOR_KEY]; // key lookupfrom xq import XQ
xq = XQ() # reads XQ_API_KEY from the environment
# 1. Authorize: XQ emails a PIN to this address
xq.api.authorize_user("me@example.com", "Jane", "Doe")
# 2. Validate the PIN, then exchange it for an access token
xq.api.code_validate(pin)
xq.api.exchange_key()
# 3. Generate a key, encrypt locally, store the key with XQ
key = xq.generate_key_from_entropy()
ciphertext = xq.encrypt_message("Quarterly results",
key=key, algorithm="AES")
token = xq.api.create_and_store_packet(
recipients=["jane@example.com"], key=key)
# 4. A recipient fetches the key by token and decrypts
key = xq.api.get_packet(token)
plaintext = xq.decrypt_message(ciphertext, key=key,
algorithm="AES")XQSDK sdk = new XQSDK(); // API key from config.properties
// 1. Authorize: XQ emails a PIN to this address
Authorize.with(sdk).supplyAsync(Optional.of(
Map.of(Authorize.USER, "me@example.com"))).get();
// 2. Validate the PIN to get an access token
CodeValidator.with(sdk).supplyAsync(Optional.of(
Map.of(CodeValidator.PIN, pin))).get();
// 3. Encrypt, then store the key with XQ
ServerResponse res = Encrypt.with(sdk, AlgorithmEnum.AES)
.supplyAsync(Optional.of(Map.of(
Encrypt.USER, "me@example.com",
Encrypt.TEXT, "Quarterly results",
Encrypt.RECIPIENTS, List.of("jane@example.com"),
Encrypt.MESSAGE_EXPIRATION_HOURS, 24))).get();
String token =
(String) res.payload.get(Encrypt.LOCATOR_KEY);#include <xq/xq.h>
struct xq_config cfg = xq_init("xq.ini"); /* has API key */
struct xq_error_info err = {0};
/* 1. Authorize: XQ emails a PIN to this address */
xq_svc_authorize(&cfg, "me@example.com", &err);
/* 2. Validate the PIN to get an access token */
xq_svc_code_validation(&cfg, pin, &err);
/* 3. Encrypt, then store the key with XQ */
struct xq_metadata meta = xq_new_email_metadata("Results");
struct xq_message_payload result = {0};
xq_encrypt_and_store_token(&cfg, Algorithm_OTP,
(uint8_t *)msg, strlen(msg), 64, "jane@example.com",
24, 0, &meta, &result, &err);
printf("Locator token: %s\n", result.token_or_key);Quickstart
From zero to encrypted in four steps.
Create an application
Sign in at manage.xqmsg.com, open Applications, create an application and generate a General API key.
Authorize a user
Request access for an email address. XQ sends a PIN, and validating it returns an access token.
Encrypt and store the key
Encrypt the data locally, then store its key with XQ for the recipients and expiry you choose. XQ returns a locator token.
Decrypt
An authorized recipient uses the locator token to fetch the key and decrypt. Revoke the key at any time to cut off access.
Reference
Everything you need to build.
FAQ
Build with XQ: the short answers.
How do I get an XQ API key?
Sign in at manage.xqmsg.com, open Applications, create an application and generate a General API key. No sales call is required.
Which languages does the XQ SDK support?
XQ publishes SDKs for JavaScript (Node.js and the browser), Python, Java and C. The source for each is on GitHub.
Why do users authorize before encrypting?
XQ stores each key for specific recipients, so it needs to know who is storing a key and who is reading it. Authorization verifies an email address with a PIN and returns an access token, which the SDK uses when it stores or fetches keys.
Does my data pass through XQ when I use the SDK?
No. The SDK encrypts and decrypts locally, in the application or device where the data is. XQ stores and releases the keys; the data itself is never sent to XQ.
Can I use the XQ SDK in the browser?
Yes. The JavaScript SDK runs in the browser as well as in Node.js, so data can be encrypted before it is uploaded.
Get your API key.
No sales form and no call required. Create your account and start building.