Agent Playbooks
Step-by-step guides for common dna CLI workflows. Each playbook is a complete, copy-paste-ready recipe for AI agents and automation scripts.
Basic Signup Flow Beginner
Create a disposable identity, use it for a website signup, extract the verification code, and clean up.
#!/usr/bin/env bash
set -euo pipefail
# 1. Create a disposable identity
IDENTITY=$(dna create --ttl 30 --label "signup" --json)
ID=$(echo "$IDENTITY" | jq -r '.id')
EMAIL=$(echo "$IDENTITY" | jq -r '.email')
PASSWORD=$(echo "$IDENTITY" | jq -r '.password')
echo "Created identity: $EMAIL"
# 2. Sign up on the target website
# (your agent fills the form with $EMAIL and $PASSWORD)
# 3. Wait for the verification email
CODE=$(dna verify "$ID" --timeout 30 --quiet)
echo "Verification code: $CODE"
# 4. Submit the code on the website
# (your agent enters $CODE on the verification page)
# 5. Clean up
dna delete "$ID"
echo "Done, identity deleted"Full Signup with Persona Beginner
Generate a complete fictional identity (name, address, phone, DOB) for filling multi-field registration forms.
#!/usr/bin/env bash
set -euo pipefail
# 1. Create identity with persona
IDENTITY=$(dna create --persona --country US --gender female --ttl 30 --label "full-signup" --json)
ID=$(echo "$IDENTITY" | jq -r '.id')
EMAIL=$(echo "$IDENTITY" | jq -r '.email')
PASSWORD=$(echo "$IDENTITY" | jq -r '.password')
# 2. Extract persona fields
FIRST=$(echo "$IDENTITY" | jq -r '.persona.firstName')
LAST=$(echo "$IDENTITY" | jq -r '.persona.lastName')
PHONE=$(echo "$IDENTITY" | jq -r '.persona.phone')
DOB=$(echo "$IDENTITY" | jq -r '.persona.dateOfBirth')
STREET=$(echo "$IDENTITY" | jq -r '.persona.address.street')
CITY=$(echo "$IDENTITY" | jq -r '.persona.address.city')
STATE=$(echo "$IDENTITY" | jq -r '.persona.address.state')
ZIP=$(echo "$IDENTITY" | jq -r '.persona.address.zip')
USERNAME=$(echo "$IDENTITY" | jq -r '.persona.username')
echo "Persona: $FIRST $LAST ($EMAIL)"
# 3. Fill the registration form with all fields
# (your agent maps each variable to the form inputs)
# 4. Verify and clean up
CODE=$(dna verify "$ID" --timeout 30 --quiet)
echo "Code: $CODE"
dna delete "$ID"import { execSync } from "child_process";
import { test } from "@playwright/test";
test("full persona signup", async ({ page }) => {
// 1. Create identity with persona
const identity = JSON.parse(
execSync("dna create --persona --country US --gender female --ttl 30 --json").toString()
);
// 2. Fill the registration form
await page.goto("https://example.com/signup");
await page.fill('[name="firstName"]', identity.persona.firstName);
await page.fill('[name="lastName"]', identity.persona.lastName);
await page.fill('[name="email"]', identity.email);
await page.fill('[name="password"]', identity.password);
await page.fill('[name="phone"]', identity.persona.phone);
await page.fill('[name="address"]', identity.persona.address.street);
await page.fill('[name="city"]', identity.persona.address.city);
await page.fill('[name="state"]', identity.persona.address.state);
await page.fill('[name="zip"]', identity.persona.address.zip);
await page.fill('[name="dob"]', identity.persona.dateOfBirth);
await page.click('button[type="submit"]');
// 3. Verify
const code = execSync(
`dna verify ${identity.id} --timeout 30 --quiet`
).toString().trim();
await page.fill('[name="code"]', code);
await page.click('button[type="submit"]');
// 4. Clean up
execSync(`dna delete ${identity.id}`);
});Handling Verification Flows Intermediate
Different strategies for extracting verification codes and links from emails.
# Wait up to 30s and extract any verification code
CODE=$(dna verify "$ID" --timeout 30 --quiet)# Match a specific pattern in the email body
CODE=$(dna verify "$ID" --timeout 30 --pattern "activation code: (\w+)" --quiet)# Extract a URL from the email (type will be "link")
RESULT=$(dna verify "$ID" --timeout 30 --json)
TYPE=$(echo "$RESULT" | jq -r '.type')
VALUE=$(echo "$RESULT" | jq -r '.value')
if [ "$TYPE" = "link" ]; then
echo "Click this link: $VALUE"
# Your agent navigates to $VALUE in the browser
else
echo "Enter this code: $VALUE"
fi# Retry verification with increasing wait times
MAX_ATTEMPTS=3
for i in $(seq 1 $MAX_ATTEMPTS); do
CODE=$(dna verify "$ID" --timeout 15 --quiet 2>/dev/null) && break
echo "Attempt $i failed, retrying..."
sleep 2
done
[ -n "$CODE" ] && echo "Code: $CODE" || echo "Failed after $MAX_ATTEMPTS attempts"# If verify doesn't find a code, read the raw email
MESSAGES=$(dna messages "$ID" --json)
MSG_ID=$(echo "$MESSAGES" | jq -r '.[0].id')
BODY=$(dna message "$ID" "$MSG_ID" --html)
echo "$BODY"
# Parse the HTML yourself for non-standard verification patternsBatch Identity Creation Intermediate
Create multiple identities for parallel testing, manage them with list/filter, and clean up in bulk.
#!/usr/bin/env bash
set -euo pipefail
COUNT=${1:-5}
echo "Creating $COUNT identities..."
# Create identities in a loop
IDS=()
for i in $(seq 1 "$COUNT"); do
ID=$(dna create --ttl 60 --label "batch-$i" --quiet)
IDS+=("$ID")
echo " Created: $ID"
done
# List all active identities
echo -e "\nActive identities:"
dna list
# Filter by label with jq
echo -e "\nBatch identities only:"
dna list --json | jq -r '.[] | select(.label | startswith("batch-")) | "\(.id) \(.email)"'
# Extend all batch identities
for ID in "${IDS[@]}"; do
dna extend "$ID" --ttl 120
done
echo "Extended all to 120 minutes"
# Clean up all batch identities
for ID in "${IDS[@]}"; do
dna delete "$ID"
done
echo "Deleted all $COUNT identities"Country-Specific Personas Intermediate
How persona data varies by country: address formats, phone numbers, and name ordering.
The --country flag accepts ISO country codes and affects all persona fields including name, address format, phone number, and name ordering.
| Country | Code | Address Format | Phone Format | Name Order |
|---|---|---|---|---|
| United States | US | 4721 Oak Street, Austin, TX 78701 | +1 555-482-7365 | First Last |
| United Kingdom | UK | 14 Kensington Road, London W8 4EP | +44 7700 900123 | First Last |
| Japan | JP | 東京都渋谷区神南1-2-3 | +81 90-1234-5678 | Last First |
| Germany | DE | Hauptstraße 42, 10115 Berlin | +49 170 1234567 | First Last |
| Brazil | BR | Rua das Flores 123, São Paulo SP 01310-100 | +55 11 91234-5678 | First Last |
| Australia | AU | 42 Collins Street, Melbourne VIC 3000 | +61 412 345 678 | First Last |
| India | IN | 15 MG Road, Bengaluru, Karnataka 560001 | +91 98765 43210 | First Last |
# US persona
dna create --persona --country US --json | jq '.persona'
# Japanese persona (family name first)
dna create --persona --country JP --json | jq '.persona'
# German persona
dna create --persona --country DE --json | jq '.persona'
# All supported: US, UK, AU, CA, DE, FR, JP, BR, IN, ES, IT, NL, KR, MX, SE, PL, NZConfigure CLI Defaults Beginner
Set persistent defaults so you don't need to pass --persona and --country flags on every create.
# Always generate a persona on create
dna config set defaults.persona true
# Default to US personas
dna config set defaults.country US
# Default to female personas
dna config set defaults.gender female
# Verify your config
dna config list# Uses defaults (persona=true, country=US)
dna create --ttl 30 --json
# Override country for this one create
dna create --country JP --ttl 30 --json
# Skip persona entirely (overrides the default)
dna create --no-persona --ttl 30 --json# Set via env vars (useful for CI/CD)
export DESTROY_API_KEY=sk_live_...
export DESTROY_DEFAULT_PERSONA=true
export DESTROY_DEFAULT_COUNTRY=US
export DESTROY_DEFAULT_GENDER=female
# Config priority: flag > env var > config file
dna create --json# Remove individual defaults
dna config unset defaults.persona
dna config unset defaults.country
dna config unset defaults.gender
# Verify they're removed
dna config list