Terminal API Usage
Use the Vanishd API directly from your terminal using dfx.
Prerequisites
- Your Vanishd API key (starts with
vnd_sk_) dfxCLI installedopensslfor hashing
Environment Setup
Set these environment variables:
export VANISHD_CANISTER="lyksb-qiaaa-aaaae-aec2a-cai"
export VANISHD_API_KEY="your-api-key-here"1. Create a Deletion Receipt
Step 1: Hash Your Credential
Your data never leaves your system. Hash locally first:
SALT=$(openssl rand -hex 16)
CREDENTIAL_ID="user@example.com"
HASH_INPUT="vanishd:v1:${CREDENTIAL_ID}:${SALT}"
CREDENTIAL_HASH=$(echo -n "$HASH_INPUT" | shasum -a 256 | cut -d' ' -f1)
echo "Salt (SAVE THIS): $SALT"
echo "Hash: $CREDENTIAL_HASH"Step 2: Call Certify
BLOB_HASH=$(echo $CREDENTIAL_HASH | sed 's/\(..\)/\\x\1/g')
TIMESTAMP_NS=$(($(date +%s) * 1000000000))
dfx canister call $VANISHD_CANISTER certify "(
\"$VANISHD_API_KEY\",
record {
credentialHash = blob \"$BLOB_HASH\";
destroyedAt = $TIMESTAMP_NS : int;
metadata = null;
idempotencyKey = null;
}
)" --network ic2. Verify a Receipt
Anyone can verify—no API key needed:
dfx canister call $VANISHD_CANISTER verify "(\"YOUR_RECEIPT_ID\")" --network ic --query3. List Your Receipts
dfx canister call $VANISHD_CANISTER listReceipts "(
\"$VANISHD_API_KEY\",
record {
limit = opt (10 : nat);
cursor = null;
status = null;
}
)" --network ic4. Check Usage
dfx canister call $VANISHD_CANISTER getUsage "(\"$VANISHD_API_KEY\")" --network icError Codes
| Error | Meaning |
|---|---|
| #invalidApiKey | API key is invalid or revoked |
| #usageLimitExceeded | Monthly quota reached |
| #receiptNotFound | Receipt ID doesn't exist |
| #rateLimited | Too many requests |
Prefer TypeScript?
For production, use our SDK for a cleaner developer experience.
npm install @vanishd/sdk