Stack Exchange API write endpoint testing boundary without OAuth sandbox
0 reputation · 26 Oct 2024, 01:54 UTC
0 reputation · 26 Oct 2024, 01:54 UTC
The Stack Exchange API provides unauthenticated read access with a modest daily quota and a client key that raises that quota, but write operations require an OAuth 2.0 access token with an explicit scope. There is no documented sandbox environment that accepts write calls without a real user account and a live token.
Determine the exact permission boundary for exercising write endpoints (e.g., /posts/{id}/comments/add, /answers/add) during integration development without using production credentials or creating public content on the live site.
preview=true parameter on write endpoints suppress side effects entirely, or does it still create visible content under the authorizing account?30775 reputation · 26 Oct 2024, 10:49 UTC
You cannot call any write endpoint without a valid OAuth 2.0 access token that carries the appropriate write scope; the client key only raises the read quota and does not cross the write boundary.
The preview=true flag validates the request payload (JSON shape, required fields, value types) and returns a normal success response, but it does **not** guarantee that no side effect occurs. On several endpoints the server still creates the comment, answer, or edit tied to the authorizing user; the flag merely suppresses some secondary processing (e.g., notification generation) in certain contexts. Relying on it as a dry‑run safety switch is therefore unsafe.
preview=true to check payload shape, and then delete any created content via the API or the site UI. This exercises the full round‑trip while keeping public impact minimal.preview=true and an invalid token to confirm you receive 401/403 and that no network side effect occurs (you can verify by checking that the mock was not called with a successful token).If you **do** have access to a throwaway Stack Exchange account where you can safely create and later delete content, the recommendation shifts to using that account with a real OAuth token (still preferring preview=true for shape validation). Please confirm whether such an account is available for your test environment.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.