Playground API
DocsStatsBlogStudio
Playground API

The free, stateful mock REST & GraphQL API sandbox where visitor mutations actually persist in an isolated session overlay without sign-up.

Public API Online (99.98%)

Endpoints

  • /api/v1/posts
  • /api/v1/users
  • /api/v1/comments
  • /api/v1/todos
  • /api/v1/graphql

Simulations

  • JWT Auth & Roles
  • Stripe Payments
  • Virtual Email & OTP
  • Latency & Chaos
  • Realtime Webhooks

Articles & Guides

Deep Dives
  • All Feature Articles→
  • React CRUD Guide
  • Why Static APIs Fail
  • Mocking Stateful Auth
  • WebSockets & SSE

Ecosystem

  • Quickstart Guide
  • TypeScript SDK
  • OpenAPI Spec
  • Postman Collection
  • GitHub Repository

Ā© 2026 Playground API. Created by Nilesh Kumar. Open source under ISC license.

Powered by Express 5, Prisma & Neon PostgreSQLllms.txt
HomeBlogDual-Mode User Sandboxing: Anonymous Session vs Authenticated State in Playground API
Feature Deep Dive2 min read•2026-09-20

Dual-Mode User Sandboxing: Anonymous Session vs Authenticated State in Playground API

Deep dive into Dual-Mode User Sandboxing in Playground API: Anonymous Session-Level (user_id = 0) vs Authenticated User-Scoped (user_id > 0) hybrid state isolation.

NK
Nilesh Kumar
Creator of Playground API
Dual-Mode User Sandboxing: Anonymous Session vs Authenticated State in Playground API

Dual-Mode User Sandboxing: Anonymous Session vs Authenticated State in Playground API

When developers prototype web applications, they frequently navigate two distinct phases:

  1. Anonymous / Guest Phase: Rapid UI prototyping without logging in, creating mock posts and comments that persist locally in the browser session.
  2. Authenticated / Multi-User Phase: Logging into distinct user accounts (user_id = 1, user_id = 2) to test user profile ownership, private data isolation, and user-specific collections (/users/1/posts).

In traditional mock APIs, this hybrid model breaks: either all mutations are global (causing test pollution), or authentication is purely decorative.

Playground API solves this with an architectural breakthrough: Dual-Mode User Sandboxing!


1. Mode A: Anonymous Session Sandbox (user_id = 0)

When no Authorization: Bearer <jwt> header is provided:

  • Playground API provisions a session sandbox tied to an HMAC-signed cookie or X-Playground-Identity header.
  • Mutations are overlaid on top of global seed data with virtual user_id = 0.
  • Perfect for anonymous prototyping, public blogs, and landing page demos.
Terminal
1
# Creates a session-scoped post without logging in
2
curl -X POST https://playground.nileslabs.com/posts \
3
-H "Content-Type: application/json" \
4
-d '{"title": "Anonymous Prototype Post", "body": "Session isolated"}'

2. Mode B: Authenticated User-Scoped Sandbox (user_id > 0)

When a valid JWT is provided (Authorization: Bearer <token>):

  • The overlay engine extracts the authenticated user_id (e.g. user_id = 3).
  • All created records are strictly stamped with that user ID.
  • Relational queries like GET /users/3/posts or GET /todos?user_id=3 automatically resolve both base seed data and that specific user's virtual mutations.
  • Other users in the same sandbox cannot modify or delete these records.
typescript
1
// Authenticated user creates a scoped record
2
const res = await fetch('https://playground.nileslabs.com/posts', {
3
method: 'POST',
4
headers: {
5
'Content-Type': 'application/json',
6
'Authorization': Bearer ${userJwtToken},
7
},
8
body: JSON.stringify({ title: 'My Private Post', body: 'User 3 only' }),
9
});

3. Seamless Transition & Migration

When an anonymous user registers or logs in during an interactive demo, Playground API seamlessly links the anonymous session mutations to the newly authenticated account, preserving UI continuity.


4. Interactive Sandboxing Studio

Inspect your active session tokens, identity hashes, and authenticated user state:

šŸ‘‰ https://playground.nileslabs.com/docs/sandboxing


Conclusion

Experience true full-stack realism without a dedicated database. Build with Playground API today!

Tags:#webdev#react#architecture#backend
Continue Reading
Previous Article
How to Test JWT Token Expiration & Axios Silent Refresh Race Conditions in React

Try Playground API in Your Own App

Stateful mock REST & GraphQL API with private sandbox overlays.

Quickstart GuideOpen Interactive Studio
Table of Contents
0%
  • 1. Mode A: Anonymous Session Sandbox (userid = 0)
  • 2. Mode B: Authenticated User-Scoped Sandbox (userid > 0)
  • 3. Seamless Transition & Migration
  • 4. Interactive Sandboxing Studio
  • Conclusion
Feature Deep Dives

In-depth technical guides exploring Playground API features — real-time subscriptions, stateful sandboxes, schema validation, latency simulation, and developer tooling.

Browse All Articles