Skip to navigation Skip to main content

Free Grow sales & stop fraud — Smart Cycle Discounts + TrustLens, free on WordPress.org Two free WooCommerce plugins

Explore both

Free Grow sales & stop fraud — Smart Cycle Discounts + TrustLens, free on WordPress.org Two free WooCommerce plugins

Explore both
  • WordPress
    WordPress Plugins
    View all
    Smart Cycle Discounts logo

    Smart Cycle Discounts

    Automate discount campaigns with scheduling, analytics, and smart product targeting.

    7 Discount Types Cycle AI
    Free Pro from $59
    TrustLens logo

    TrustLens

    Customer trust intelligence for WooCommerce. Score customers, spot abuse, protect revenue.

    Trust Scores Abuse Detection
    Free Pro from $79

    New Plugin

    Coming Soon

    Something exciting is in the works. Join the waitlist to be first to know.

    Get Notified
    Notify Me
    Secure Checkout
    WordPress.org
    14-Day Refund
    Resources
    Documentation Guides & tutorials
    Discount Calculator Plan your strategy
    Support Get help
    SCD Changelog Discount plugin updates
    TrustLens Changelog Trust intelligence updates
    Get notified on new releases
  • Affiliate
    Program
    Overview How the program works
    How It Works 4 steps from apply to earn
    Commission Details 30% · 60-day cookie · recurring
    Get Started
    Apply Now Open
    Takes ~2 minutes
    Earnings Calculator Estimate your monthly income
    FAQ Payouts, cookies, renewals
    Resources
    Brand Kit Logos, banners, copy, social
    Playbook Tactics that actually convert
    FTC Disclosure How to disclose properly
    Affiliate Terms Full program agreement
    Contact Team Open the contact form
    Earn 30% recurring on every sale Free to join · 60-day cookie · monthly PayPal payouts
    Apply Now
  • Blog
  • DOCS
    Docs & Resources

    Guides, references, and answers for every Webstepper plugin.

    Smart Cycle Discounts Automated WooCommerce discount campaigns
    Getting started › Discount types › Cycle AI ›
    TrustLens Customer trust & fraud intelligence
    Trust scoring › Detection modules › Card-testing defense ›
    Docs Home Guides FAQ Pricing Support
    WordPress tools that solve real problems
  • Contact Us
  • About
    Company

    Our Story

    Founded 2020

    Built by store owners, for store owners. We create WordPress tools that solve real problems.

    Learn more
    Built from Experience Real solutions we use ourselves
    Time is Precious Simple, intuitive tools
    Real Support Talk to the founders
    Legal & Contact
    Contact Us Privacy Policy Terms of Service Refund Policy
    14-Day Money-Back Guarantee No questions asked
Popular requests
  • smart cycle discounts
  • trustlens
  • chargeback protection
GET STARTED

Glossary

1
  • TrustLens Glossary

Detection Modules

9
  • Card Testing Defense
  • Chargeback Tracking
  • Shipping Anomalies
  • Linked Accounts Detection
  • Category Aware Risk
  • Coupon Abuse Detection
  • Order Pattern Analysis
  • Return Abuse Detection
  • Modules Overview

Card Testing Defense

9
  • Attack History
  • Allowlists
  • Geo Diversity
  • Auto Escalation
  • Fingerprinting
  • VIP Bypass
  • Panic Button
  • Velocity Thresholds
  • Overview

Chargeback Monitor

7
  • Ratio Email Alerts
  • Dispute Evidence Report
  • Chargeback Monitor
  • Manual Dispute Entry
  • Stripe WooPayments Ingestion
  • Card Network Thresholds
  • Chargeback Ratio Speedometer

Customer Management

7
  • Admin Notes
  • Checkout Enforcement
  • Order Trust Column
  • Bulk Actions
  • Blocking and Allowlisting
  • Customer Detail Profile
  • Customer List

Automation

7
  • Async Dispatch Retries
  • Webhooks and HMAC
  • Rule Inspector
  • Actions Reference
  • Conditions Reference
  • Triggers Reference
  • Automation Overview

Trust Scoring

5
  • Account Age Loyalty Bonus
  • Signals Explained
  • Six Customer Segments
  • The 0–100 Score
  • How Trust Scoring Works
View Categories
  • Home
  • Docs
  • Trustlens
  • Developer Documentation
  • REST API Reference

REST API Reference

6 min read

TrustLens exposes a REST API for integrations. This page documents every endpoint with its request and response shape. The API is implemented in includes/class-rest-api.php and registered under the trustlens/v1 namespace.

Base URL: https://yoursite.com/wp-json/trustlens/v1


Authentication #

Every endpoint requires authentication. The plugin accepts two mechanisms:

Method 1 — WordPress User Authentication #

Any authenticated WordPress user with the manage_woocommerce capability can call the API. The most common implementation is the WordPress application-password feature:

  1. WordPress → Users → Edit your user
  2. Scroll to Application Passwords
  3. Add a new password (e.g. “TrustLens integration”)
  4. Use the username and generated password in HTTP Basic Auth
curl -u username:app_password \
  https://yoursite.com/wp-json/trustlens/v1/customers

Cookie-based authentication for browser requests also works as long as the logged-in user has manage_woocommerce.

Method 2 — TrustLens API Key #

For integrations that don’t have a WordPress user, TrustLens supports a static API key. The key is stored as a SHA-256 hash in the trustlens_api_key WordPress option and compared with hash_equals() for timing-safe matching.

Send the key in the X-TrustLens-API-Key request header:

curl -H "X-TrustLens-API-Key: your_api_key_here" \
  https://yoursite.com/wp-json/trustlens/v1/customers

Configure the key in TrustLens → Settings → API.


The Eight Endpoints #

Method Path Purpose
GET /customers List customers
GET /customers/lookup Look up a customer by raw email
GET /customers/{email_hash} Get customer record by hash
POST/PUT/PATCH /customers/{email_hash} Update customer state (block, allowlist, notes)
GET /customers/{email_hash}/events List events on a customer’s timeline
POST /customers/{email_hash}/recalculate Trigger immediate score recalculation
GET /stats Store-wide aggregate statistics
GET /stats/segments Segment distribution counts

The {email_hash} parameter is the keyed HMAC-SHA256 hash of the customer’s email (64 hex characters). Use /customers/lookup?email=... if you only have the raw email.


GET /customers #

Paginated list of customers with optional filters.

Query Parameters #

Param Description
page, per_page Standard pagination
segment Filter to one of: vip, trusted, normal, caution, risk, critical
min_score, max_score Trust score range filter
is_blocked, is_allowlisted Boolean filters
orderby, order Sort field and direction

Response includes X-WP-Total and X-WP-TotalPages headers in the standard WordPress REST convention.


GET /customers/lookup #

Look up a customer by raw email address. TrustLens hashes the email server-side and returns the matching customer record.

Query Parameters #

  • email (required) — raw email address

Returns the same payload as GET /customers/{email_hash}.


GET /customers/{email_hash} #

Get the full customer record.

Response (typical) #

{
  "email_hash": "...",
  "customer_email": "...",
  "trust_score": 75,
  "segment": "trusted",
  "is_blocked": false,
  "is_allowlisted": false,
  "total_orders": 12,
  "total_order_value": 1450.00,
  "total_refunds": 1,
  "full_refunds": 0,
  "partial_refunds": 1,
  "total_refund_value": 89.00,
  "return_rate": 8.33,
  "total_disputes": 0,
  "disputes_won": 0,
  "disputes_lost": 0,
  "total_coupons_used": 2,
  "first_order_coupons": 1,
  "coupon_then_refund": 0,
  "linked_accounts": 0,
  "first_order_date": "2023-04-15 10:30:00",
  "last_order_date": "2024-03-10 14:22:00",
  "score_updated_at": "2024-03-10 14:25:00",
  "admin_notes": "..."
}

Returns 404 if the hash doesn’t match any customer.


POST/PUT/PATCH /customers/{email_hash} #

Update mutable state on a customer record. The same endpoint is used for blocking, allowlisting, and editing admin notes — there are no separate /block or /allowlist endpoints.

Updatable Fields #

  • is_blocked (boolean)
  • is_allowlisted (boolean)
  • admin_notes (string)
  • tags (array of strings)

Example: Block a Customer #

curl -X PATCH \
  -H "Content-Type: application/json" \
  -H "X-TrustLens-API-Key: ..." \
  -d '{"is_blocked": true}' \
  https://yoursite.com/wp-json/trustlens/v1/customers/{email_hash}

Example: Allowlist a Customer #

{"is_allowlisted": true}

Sending "is_allowlisted": true triggers an automatic score recalculation that locks the score at 100. Removing the allowlist (false) triggers a recalculation that restores the score based on actual signals.

The response is the updated customer record.


GET /customers/{email_hash}/events #

Returns the customer’s event timeline — order placements, refunds, coupon applications, disputes, score updates, admin actions, etc.

Query Parameters #

  • page, per_page — pagination
  • event_type — filter to a specific event type (e.g. order_placed)
  • since — ISO 8601 timestamp; return events at or after this time

Response Shape #

{
  "events": [
    {
      "id": 12345,
      "email_hash": "...",
      "event_type": "refund_issued",
      "event_data": { ... },
      "order_id": 5432,
      "created_at": "2024-03-10 14:22:00"
    },
    ...
  ]
}

event_data is a JSON-decoded object whose shape depends on the event type.


POST /customers/{email_hash}/recalculate #

Triggers an immediate, synchronous score recalculation. The recalculated score, segment, and current signal list are returned.

Response #

{
  "score": 52,
  "segment": "normal",
  "signals": [
    { "module": "returns", "score": -10, "reason": "Elevated return rate: 28%" },
    { "module": "account_age", "score": 10, "reason": "Established customer (6+ months)" }
  ]
}

This is the only endpoint that runs scoring inline rather than queueing it via Action Scheduler.


GET /stats #

Aggregate store-wide statistics.

Response (typical) #

{
  "total_scored_customers": 4823,
  "average_trust_score": 64,
  "store_return_rate": 8.4,
  "total_disputes_current_month": 12,
  "blocked_count": 47,
  "allowlisted_count": 89
}

Useful for external dashboards and integrations that want a quick health snapshot.


GET /stats/segments #

Customer count per segment.

Response #

{
  "vip": 127,
  "trusted": 892,
  "normal": 3456,
  "caution": 234,
  "risk": 89,
  "critical": 25
}

Error Format #

Errors follow the WordPress REST convention:

{
  "code": "trustlens_customer_not_found",
  "message": "Customer not found",
  "data": { "status": 404 }
}

Common error codes:

  • 401 — missing or invalid authentication
  • 403 — capability check failed
  • 404 — record not found
  • 400 — invalid request body or parameters

Pagination Headers #

List endpoints (/customers, /customers/{hash}/events) include WordPress’s standard headers:

  • X-WP-Total — total result count
  • X-WP-TotalPages — total page count given the current per_page

What This API Doesn’t Do #

To set expectations clearly:

  • No dispute endpoints. Disputes are not exposed as a standalone resource through the REST API. Dispute counts and outcomes are visible on the customer record’s stat columns. Use the WordPress admin or direct database queries for dispute-specific reads.
  • No health endpoint. No unauthenticated probe endpoint is registered.
  • No automation rule management. Automation rules are configured through the admin UI, not the REST API.
  • No webhook subscription management. Outgoing webhooks are configured per automation rule action through the admin UI.
  • No built-in rate limiting. The plugin does not enforce request-rate limits at the application layer. If you need rate limiting, apply it at the web server, CDN, or reverse-proxy layer.

Versioning #

The namespace trustlens/v1 is the current and only version. Future breaking changes would introduce v2 while keeping v1 available for backward compatibility. Non-breaking additions (new fields, new optional parameters) happen in v1 without a version bump.


Common Integration Patterns #

  • Read customer score from CRM: CRM calls GET /customers/lookup?email=... when displaying a customer record
  • Sync customer state to data warehouse: subscribe to TrustLens automation webhooks (configured per rule) and ingest events
  • Help desk integration: on ticket open, call GET /customers/lookup?email={ticket.requester} to surface trust context to the agent
  • External fraud-rule engine: consume webhook events from your rules, apply external logic, call PATCH /customers/{hash} with is_blocked: true when needed
Updated on June 4, 2026

What are your Feelings

  • Happy
  • Normal
  • Sad

Share This Article :

  • Facebook
  • X
  • LinkedIn
  • Pinterest
Database SchemaHooks and Filters Reference
Table of Contents
  • Authentication
    • Method 1 — WordPress User Authentication
    • Method 2 — TrustLens API Key
  • The Eight Endpoints
  • GET /customers
    • Query Parameters
  • GET /customers/lookup
    • Query Parameters
  • GET /customers/{email_hash}
    • Response (typical)
  • POST/PUT/PATCH /customers/{email_hash}
    • Updatable Fields
    • Example: Block a Customer
    • Example: Allowlist a Customer
  • GET /customers/{email_hash}/events
    • Query Parameters
    • Response Shape
  • POST /customers/{email_hash}/recalculate
    • Response
  • GET /stats
    • Response (typical)
  • GET /stats/segments
    • Response
  • Error Format
  • Pagination Headers
  • What This API Doesn't Do
  • Versioning
  • Common Integration Patterns
Newsletter

Insights that grow your business

Join thousands of WooCommerce store owners who get actionable tips, plugin updates, and industry news every week.

We respect your privacy. Unsubscribe at any time.

Weekly updates — Fresh content every Tuesday
Exclusive content — Tips you won't find on our blog
Early access — Be first to know about new plugins
Webstepper
Weekly WooCommerce Tips
Just now
This week: 5 proven strategies to boost your average order value using smart discount campaigns...
New issue!
Webstepper

Tools for store owners who'd rather grow than grind.

Simple, powerful plugins that help WooCommerce store owners sell more — without the learning curve.

500+ happy stores

Products

  • Smart Cycle Discounts
  • TrustLens
  • Discount Calculator
  • Sale Calendar

Company

  • About Us
  • Blog
  • Contact
  • Affiliates

Resources

  • Help Center
  • Guides
  • Affiliate Program
  • Become a Partner

Questions? We actually answer.

Real humans, real help. No bots, no runaround. Usually within a few hours.

Get in touch
Operated by Setmood LLC · 7901 4th St N, St Petersburg, FL 33702 · United States

© 2026 Webstepper. All rights reserved.

Privacy Terms Refunds
Visa Mastercard PayPal Apple Pay Google Pay & more
Limited Time Offer

Save 15% on
SCD, TrustLens & the Bundle

Smart Cycle Discounts and TrustLens — buy either plugin or grab both in the bundle. Use code at checkout.

WELCOME15
23 hours
:
59 minutes
:
59 seconds
Claim My Discount

Just want one? Smart Cycle Discounts · TrustLens

  • WordPress
    Back
    WordPress Plugins
    View all
    Smart Cycle Discounts logo

    Smart Cycle Discounts

    Automate discount campaigns with scheduling, analytics, and smart product targeting.

    7 Discount Types Cycle AI
    Free Pro from $59
    TrustLens logo

    TrustLens

    Customer trust intelligence for WooCommerce. Score customers, spot abuse, protect revenue.

    Trust Scores Abuse Detection
    Free Pro from $79

    New Plugin

    Coming Soon

    Something exciting is in the works. Join the waitlist to be first to know.

    Get Notified
    Notify Me
    Secure Checkout
    WordPress.org
    14-Day Refund
    Resources
    Documentation Guides & tutorials
    Discount Calculator Plan your strategy
    Support Get help
    SCD Changelog Discount plugin updates
    TrustLens Changelog Trust intelligence updates
    Get notified on new releases
  • Affiliate
    Back
    Program
    Overview How the program works
    How It Works 4 steps from apply to earn
    Commission Details 30% · 60-day cookie · recurring
    Get Started
    Apply Now Open
    Takes ~2 minutes
    Earnings Calculator Estimate your monthly income
    FAQ Payouts, cookies, renewals
    Resources
    Brand Kit Logos, banners, copy, social
    Playbook Tactics that actually convert
    FTC Disclosure How to disclose properly
    Affiliate Terms Full program agreement
    Contact Team Open the contact form
    Earn 30% recurring on every sale Free to join · 60-day cookie · monthly PayPal payouts
    Apply Now
  • Blog
  • DOCS
    Back
    Docs & Resources

    Guides, references, and answers for every Webstepper plugin.

    Smart Cycle Discounts Automated WooCommerce discount campaigns
    Getting started › Discount types › Cycle AI ›
    TrustLens Customer trust & fraud intelligence
    Trust scoring › Detection modules › Card-testing defense ›
    Docs Home Guides FAQ Pricing Support
    WordPress tools that solve real problems
  • Contact Us
  • About
    Back
    Company

    Our Story

    Founded 2020

    Built by store owners, for store owners. We create WordPress tools that solve real problems.

    Learn more
    Built from Experience Real solutions we use ourselves
    Time is Precious Simple, intuitive tools
    Real Support Talk to the founders
    Legal & Contact
    Contact Us Privacy Policy Terms of Service Refund Policy
    14-Day Money-Back Guarantee No questions asked
We use cookies to improve your experience on our website. By browsing this website, you agree to our use of cookies.
More info More info Accept