SDKs
Official Node.js and Python SDKs for integrating SignedApproval into your applications and AI agent pipelines.
Key Concepts
SignedApproval provides official SDKs for Node.js and Python that wrap the REST API in a type-safe, idiomatic interface. The SDKs handle authentication, polling, retry logic, and signature verification.
Node.js SDK
Install from npm:
npm install @signedapproval/sdkBasic usage:
import { SignedApproval } from '@signedapproval/sdk';
const sa = new SignedApproval({
apiKey: process.env.SIGNEDAPPROVAL_API_KEY, // sa_live_...
});
// Create an approval request
const request = await sa.createRequest({
action: 'Deploy v2.1.0 to production',
ttlSeconds: 3600,
metadata: { environment: 'production', version: '2.1.0' },
});
console.log('Request created:', request.id);
// Wait for the decision (polls automatically)
const decision = await sa.waitForDecision(request.id, {
pollInterval: 3000, // 3 seconds
timeout: 300000, // 5 minutes
});
if (decision.status === 'approved') {
console.log('Approved via', decision.decision.method);
// Proceed with the action
} else {
console.log('Not approved:', decision.status);
}Verify a signature:
// Online verification
const result = await sa.verify(requestId);
console.log('Valid:', result.valid);
// Offline verification (using cached public key)
const isValid = sa.verifyOffline({
payload: result.payload,
signature: result.signature,
publicKey: result.public_key,
});Python SDK
Install from PyPI:
pip install signedapprovalBasic usage:
from signedapproval import SignedApproval
sa = SignedApproval(api_key="sa_live_...")
# Create an approval request
request = sa.create_request(
action="Deploy v2.1.0 to production",
ttl_seconds=3600,
metadata={"environment": "production", "version": "2.1.0"},
)
print(f"Request created: {request.id}")
# Wait for the decision (polls automatically)
decision = sa.wait_for_decision(
request.id,
poll_interval=3.0, # seconds
timeout=300.0, # seconds
)
if decision.status == "approved":
print(f"Approved via {decision.decision.method}")
else:
print(f"Not approved: {decision.status}")Verify a signature:
# Online verification
result = sa.verify(request_id)
print(f"Valid: {result.valid}")
# Offline verification
is_valid = sa.verify_offline(
payload=result.payload,
signature=result.signature,
public_key=result.public_key,
)LangChain Integration
Use SignedApproval as a human-in-the-loop gate in a LangChain agent:
from signedapproval import SignedApproval
from langchain.tools import tool
sa = SignedApproval(api_key="sa_live_...")
@tool
def deploy_to_production(version: str) -> str:
"""Deploy the specified version to production. Requires human approval."""
# Request approval
request = sa.create_request(
action=f"Deploy {version} to production",
ttl_seconds=300,
)
# Wait for human decision
decision = sa.wait_for_decision(request.id, timeout=300)
if decision.status != "approved":
return f"Deployment blocked: {decision.status}"
# Proceed with deployment
# ... your deployment logic here ...
return f"Deployed {version} to production (approved via {decision.decision.method})"CrewAI Integration
Add approval gates to CrewAI agent tasks:
from signedapproval import SignedApproval
sa = SignedApproval(api_key="sa_live_...")
def require_approval(action: str, ttl: int = 300) -> bool:
"""Gate a high-risk action behind signed human approval."""
request = sa.create_request(action=action, ttl_seconds=ttl)
decision = sa.wait_for_decision(request.id, timeout=ttl)
return decision.status == "approved"Note
Both SDKs are open source. The Node.js SDK is in
sdk/node/ and the Python SDK is in sdk/python/ within the SignedApproval repository.Tip
The
waitForDecision / wait_for_decision method handles polling automatically with configurable intervals and timeouts. For production systems, consider also setting up webhooks for immediate notifications.Related Articles