#Integration guides
Pick your backend language. Every guide builds the same two things:
- One backend route (
POST /api/thehackstack/verification-session) that uses your secret API key to create a verification session for the customer who is signed in to your software. - Two buttons in your web pages, rendered by the JavaScript SDK: Leave a Review and Verify Your Review.
| Language | Frameworks covered | Guide |
|---|---|---|
| JavaScript / TypeScript | Node.js 18+ with Express (any framework works) | Node.js guide |
| Python | Flask, Django | Python guide |
| PHP | Plain PHP (cURL), Laravel | PHP guide |
| Java | Spring Boot 3 (JDK 17+ HttpClient) |
Java guide |
| C# / .NET | ASP.NET Core 8 minimal API | C# guide |
Using another language? Any stack that can make an HTTPS POST works. Follow
the API reference and copy the rules in
What every backend route must do.
#How your API key is linked to your product
TheHackStack account ──owns──▶ Product (listed on thehackstack.com)
│ one app per product
▼
Developer app ths_app_… (public: goes in your HTML)
│ created automatically
▼
API key ths_sk_… (secret: stays on your server)- The developer app is created automatically for each product you own, ready to use.
- Each API key belongs to that app, so every verification session it creates is tied to that product. A review on another product can never be verified with your key.
- If the product changes owner, the app stops working and the new owner gets their own app. Ownership stays in sync with the product listing automatically.
#Before you start
- Open Developer at
https://thehackstack.com/developer/appsand pick your product. - Copy its secret key (
ths_sk_…) and app id. Both are always shown there. - Store these settings on your server, never in frontend code or git:
THS_API_KEY=ths_sk_…your-secret-key… # secret
THS_APP_ID=ths_app_… # public
THS_BASE_URL=https://thehackstack.com # optional#The frontend (same for every language)
Add this to every page that shows the buttons. data-session-endpoint is the
backend route from your language guide, on your own origin.
<script src="https://thehackstack.com/sdk/v1.2.0/ths-reviews.js"
integrity="sha384-rSq3igDf1LtE8FQQEWmUsDIdvfJwHKXsykIji4SSHzwGhlGzhpMp6zPhb30s13Rb"
crossorigin="anonymous"
data-app-id="ths_app_XXXXXXXXXXXXXXXXXXXXXXXX"
data-session-endpoint="/api/thehackstack/verification-session"
async></script>
<!-- Anyone: opens your product's review section on TheHackStack -->
<button data-ths-review-button="leave">Review us on TheHackStack</button>
<!-- Signed-in customers: verify an existing review, or write a verified one -->
<button data-ths-review-button="verify">Verify your review</button>
<button data-ths-review-button="verify" data-ths-intent="write">Write a verified review</button>Show the Verify buttons only to customers who are signed in to your software. See SDK installation for the JavaScript API, events and Content-Security-Policy settings.
#What every backend route must do
- Identify the customer from your own login session. Return
401if nobody is signed in. Never read a user id or email from the request body. - Block CSRF: reject the request unless it is JSON and carries the
X-THS-SDKheader. The SDK always sends both; other sites can't without a CORS preflight. - Call
POST {THS_BASE_URL}/api/v1/verification-sessionswithAuthorization: Bearer {THS_API_KEY}, a 10-second timeout, and the body{"customer":{"id":"<your user id>"},"intent":"verify"|"write"}. - Return only
verification_urlandexpires_at, withCache-Control: no-store. On any failure return502. - Never log the
verification_urlor the API key. Logging the sessionidis fine.
#Test your route
Signed in to your own app in the browser, click Verify your review. You
should land on https://thehackstack.com/verify. From the command line, your
route should refuse requests without the SDK header:
curl -i -X POST https://your-app.example/api/thehackstack/verification-session \
-H "Content-Type: application/json" -d '{"intent":"verify"}'
# → 401 (not signed in) or 403 {"error":"csrf"}And your key should work server to server:
curl -s -X POST https://thehackstack.com/api/v1/verification-sessions \
-H "Authorization: Bearer $THS_API_KEY" -H "Content-Type: application/json" \
-d '{"customer":{"id":"test-user-1"},"intent":"verify"}'
# → 201 with "verification_url"Don't open or share that test link; it expires after 10 minutes.