Build an app
Stokzone apps access merchant data via OAuth 2.1. This guide covers every step from creating an app to publishing it.
End-to-end flow
You create your app in the panel, get its credentials, submit for review, and publish on apps.stokzone.com once approved.
- Developer account and appCreate your developer organisation and app in the panel (app.stokzone.com/{locale}/dashboard/developer).
- Client ID and secretA client_id (prefix szapp_) and client_secret (prefix szcs_) are generated. The secret is shown ONCE; you can rotate it, and rotation invalidates the old one immediately (no grace).
- Install URL and redirect URIsDefine your Install URL and redirect URIs. redirect_uri must match EXACTLY (no prefix/wildcard), https is required; http is only accepted for localhost/127.0.0.1 loopback, and fragments (#) are forbidden.
- ScopesRequest the scopes your app needs, with justification. Broad legacy 'read'/'write' scopes are not granted; only granular scopes are used.
- Mandatory webhooksFor GDPR/KVKK you must subscribe to app.uninstalled, customer.data_request, customer.redact and shop.redact.
- Store listingUpload TR and EN listing copy, an icon and screenshots (limits below).
- Submit for reviewSubmit the version for review: automated checks first, then a human review by the Stokzone team. On rejection you get a reason, fix it and resubmit.
- PublishOnce approved the app becomes 'published' and goes live on apps.stokzone.com. Until a new version is approved, the storefront shows the previous active version.
OAuth 2.1 endpoints
All endpoints are under /api/v1. The consent screen lives at app.stokzone.com/oauth/authorize; the token and revoke endpoints are on api.stokzone.com.
| Endpoint | Purpose |
|---|---|
GET /oauth/authorize | Validates the authorization request; the panel renders the consent screen (tenant selection + scopes). |
POST /oauth/token | authorization_code → access + refresh token; the refresh token rotates on every use. |
POST /oauth/revoke | Token revocation (RFC 7009). Revoking a refresh token drops the whole family. |
GET /oauth/metadata | Authorization server metadata (RFC 8414): endpoints, S256, iss support. |
GET /app-api/v1/installation | Returns the installation and effective scopes for a Bearer access token (connection test). |
PKCE (S256) required
PKCE is mandatory and only S256 is accepted ('plain' is rejected). You send the user to the consent screen with these parameters. ⚠️ We cannot link straight to /oauth/authorize: the code_challenge (and code_verifier) must be generated by your app (RFC 7636).
https://app.stokzone.com/oauth/authorize
?response_type=code
&client_id=szapp_xxxxxxxxxxxx
&redirect_uri=https://app.example.com/oauth/callback
&scope=orders:read%20shipping:write
&state=<rastgele>
&code_challenge=<BASE64URL(SHA256(verifier))>
&code_challenge_method=S256After the user approves, a single-use code is returned to your redirect_uri. Exchange it with the code_verifier and your client secret (client_secret_basic or client_secret_post):
POST https://api.stokzone.com/api/v1/oauth/token
Content-Type: application/x-www-form-urlencoded
Authorization: Basic base64(client_id:client_secret)
grant_type=authorization_code
&code=szac_...
&redirect_uri=https://app.example.com/oauth/callback
&code_verifier=<43-128 karakter>Every redirect (success and error) includes the RFC 9207 iss parameter; the client must compare it against the expected issuer.
Token lifetimes and prefixes
| Token | Prefix | Lifetime |
|---|---|---|
| Authorization code | szac_ | 10 minutes (single-use) |
| Access token | szat_ | 1 hour |
| Refresh token | szrt_ | 90 days (rotates on every use) |
The code is single-use; if replayed, tokens issued from it are revoked. The refresh token is replaced on every use; if a revoked refresh token is replayed, the WHOLE family is revoked (reuse detection).
redirect_uri rules
redirect_uri must match a registered value as an EXACT string; https is required. Only http loopback addresses (localhost, 127.0.0.1, ::1) may vary the port. Addresses with a fragment (#) are rejected.
Scopes
Apps request the same granular scopes as the Web Service API. The risk class drives the coloured dot on the consent screen: high (writes), protected (personal data), normal.
| Scope | Meaning | Risk |
|---|---|---|
products:read | View your products and variants | Normal |
products:write | Create and edit your products | High — writes/changes data |
orders:read | View your orders — including buyer name and address | Protected — personal data |
orders:write | Update order status | High — writes/changes data |
inventory:write | Change stock quantities (sent to marketplaces) | High — writes/changes data |
prices:write | Change prices (sent to marketplaces) | High — writes/changes data |
returns:read | View returns — including buyer details | Protected — personal data |
returns:write | Approve or reject returns | High — writes/changes data |
invoices:read | View your invoices | Protected — personal data |
invoices:write | Upload invoices to orders | High — writes/changes data |
questions:read | View customer questions | Normal |
questions:write | Answer customer questions | Normal |
customers:read | View your customer list — including contact details | Protected — personal data |
categories:read | View your categories | Normal |
brands:read | View your brands | Normal |
buybox:read | View Buy Box status | Normal |
shipping:read | View shipments — including buyer address | Protected — personal data |
shipping:write | Create shipments | High — writes/changes data |
reports:read | View your sales reports | Normal |
webhooks:manage | Turn webhook subscriptions on or off for this app | Normal |
Webhooks and HMAC verification
Webhook requests carry the headers below. The timestamp is unix seconds; the signature is hex HMAC-SHA256(webhook_secret, "<timestamp>.<raw body>"). The webhook_secret is per app (prefix whsec_) and stored encrypted.
Mandatory topics: app.uninstalled, customer.data_request, customer.redact, shop.redact. The receiver must reject timestamps outside ±5 minutes and deduplicate by Event-Id (replay defence).
X-Stokzone-Topic: app.uninstalled
X-Stokzone-Event-Id: 9f1c...
X-Stokzone-Installation-Id: ins_...
X-Stokzone-Timestamp: 1764500000
X-Stokzone-Hmac-Sha256: 4b2a... (hex)Verify the signature with a constant-time comparison and sign over the RAW bytes WITHOUT parsing the body:
import crypto from "node:crypto";
function verify(req, secret) {
const ts = req.header("X-Stokzone-Timestamp");
const sig = req.header("X-Stokzone-Hmac-Sha256");
// req.rawBody = ham gövde (parse EDİLMEDEN)
const base = ts + "." + req.rawBody;
const expected = crypto
.createHmac("sha256", secret)
.update(base, "utf8")
.digest("hex");
const ok = crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(expected));
const fresh = Math.abs(Date.now() / 1000 - Number(ts)) <= 300;
return ok && fresh;
}import hmac, hashlib, time
def verify(headers, raw_body: bytes, secret: str) -> bool:
ts = headers["X-Stokzone-Timestamp"]
sig = headers["X-Stokzone-Hmac-Sha256"]
base = ts.encode() + b"." + raw_body
expected = hmac.new(secret.encode(), base, hashlib.sha256).hexdigest()
fresh = abs(time.time() - int(ts)) <= 300
return hmac.compare_digest(sig, expected) and freshDelivery attempts: first 3 fast in-process retries (0, 2, 8 s), then a recovery tick with exponential backoff up to 10 attempts total. After 24 hours an undelivered record expires and its body is deleted.
Rate limits
The OAuth consent endpoint (GET /oauth/authorize) is limited to 60 requests per 60 seconds per user (source: code). The Web Service API's general limits are in a separate guide; rely only on the numbers written in code.
Media and listing limits
Icon: PNG/JPEG, square, 256–1200 px, max 1 MB, 1 item. SVG/GIF/HEIC are rejected; images are re-encoded (EXIF/text chunks stripped).
Screenshot: PNG/JPEG/WebP, at least 1280×720, at most 3200×2000, max 2 MB, up to 8 items. Banner: up to 1 item.
Next steps
Explore the store and start building with the API reference.