Stub API: Purge Stubs
The /api/stubs endpoint with the DELETE method removes stubs from the storage. This is a destructive operation and cannot be undone.
Request
- Method:
DELETE - URL:
/api/stubs - Parameters: None required.
- Headers:
X-Gripmock-Sessionnarrows the purge to one session; without it every stub is removed.
Example Request:
bash
# Everything
curl -X DELETE http://127.0.0.1:4771/api/stubs
# Only the fixtures of one session
curl -X DELETE -H 'X-Gripmock-Session: team-a' http://127.0.0.1:4771/api/stubsResponse
- Status Code:
204 No Content - Body: Empty (no content returned).
Behavior
- Unscoped: Removes all stubs (both used and unused, every session).
- Session-scoped: With
X-Gripmock-Session, only that session's stubs go; global stubs and other sessions are untouched. This is what the admin UI uses, so one client cannot wipe another session's fixtures. - Static Stubs: Currently, all stubs in scope are deleted. A future flag may allow excluding static stubs.
- Irreversible: Deleted stubs cannot be recovered.
Example Workflow
Create Stubs:
bashcurl -X POST -d '[{"service":"Gripmock","method":"SayHello","input":{"equals":{"name":"test"}}}]' http://127.0.0.1:4771/api/stubsVerify Stubs Exist:
bashcurl http://127.0.0.1:4771/api/stubsResponse:
json[{"id": "...", ...}]Purge All Stubs:
bashcurl -X DELETE http://127.0.0.1:4771/api/stubsVerify Deletion:
bashcurl http://127.0.0.1:4771/api/stubsResponse:
json[]
Notes
- Edge Cases:
- If no stubs exist, the endpoint still returns
204. /api/stubs/usedand/api/stubs/unusedboth go empty: the stubs they reported are gone.
- If no stubs exist, the endpoint still returns
- Related Endpoints:
GET /api/stubs: List all stubs.POST /api/stubs: Add new stubs.POST /api/stubs/batchDelete: Delete specific stubs by ID.DELETE /api/history: The same scoping rule for recorded calls.
Schema References
For complete schema details, see: