> For the complete documentation index, see [llms.txt](https://docs.flxbl.io/flxbl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flxbl.io/flxbl/sfp-server/api-reference/mock-workspaces.md).

# Mock Workspaces

## GET /sfp/api/mocks/workspaces

> List mock workspaces

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces":{"get":{"operationId":"MocksWorkspacesController_list","summary":"List mock workspaces","parameters":[],"responses":{"200":{"description":"Workspace summaries"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## Activate (or re-activate) a mock workspace

> Registers WireMock stubs for every service in the definition. Re-activation replaces the baseline but preserves session overrides by service name.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"ActivateWorkspaceDto":{"type":"object","properties":{"workspace":{"type":"string"},"context":{"type":"object","properties":{"repository":{"type":"string"},"prNumber":{"type":"number"},"branch":{"type":"string"},"environment":{"type":"string"}},"selfRequired":false},"services":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"namedCredential":{"type":"string"},"packageName":{"type":"string"},"specSource":{"type":"string","enum":["source","org","none"]},"spec":{"type":"string","nullable":true},"baselineRules":{"type":"array","items":{"type":"object","properties":{"request":{"type":"object","properties":{"method":{"type":"string"},"path":{"type":"string"},"query":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"bodyContains":{"type":"string"}},"required":["method","path"]},"response":{"type":"object","properties":{"status":{"type":"number"},"body":{},"headers":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"delayMs":{"type":"number"}},"required":["status"]},"scenario":{"type":"string"},"responses":{"type":"array","items":{"type":"object","properties":{"status":{"type":"number"},"body":{}},"required":["status"],"additionalProperties":{}}}},"required":["request"]}}},"required":["name","namedCredential","packageName","specSource","baselineRules"]}},"playbooks":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"steps":{"type":"array","items":{"type":"object","properties":{"service":{"type":"string"},"request":{"type":"object","properties":{"method":{"type":"string"},"path":{"type":"string"}},"required":["method","path"]},"response":{"type":"object","properties":{"status":{"type":"number"},"body":{},"headers":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"delayMs":{"type":"number"}},"required":["status"],"additionalProperties":{}}},"required":["service","request","response"]}}},"required":["name","steps"]}}},"required":["workspace","context","services"]}}},"paths":{"/sfp/api/mocks/workspaces":{"post":{"operationId":"MocksWorkspacesController_activate","summary":"Activate (or re-activate) a mock workspace","description":"Registers WireMock stubs for every service in the definition. Re-activation replaces the baseline but preserves session overrides by service name.","parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ActivateWorkspaceDto"}}}},"responses":{"201":{"description":"Workspace activated; returns per-service stub counts and data-plane paths"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## GET /sfp/api/mocks/workspaces/{workspace}

> Get a workspace with effective rules per service

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}":{"get":{"operationId":"MocksWorkspacesController_get","summary":"Get a workspace with effective rules per service","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Full workspace state"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## Tear down a workspace (stubs + record)

> restore=true reverts switched credentials first; force=true tears down even when restore fails.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}":{"delete":{"operationId":"MocksWorkspacesController_teardown","summary":"Tear down a workspace (stubs + record)","description":"restore=true reverts switched credentials first; force=true tears down even when restore fails.","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}},{"name":"restore","required":true,"in":"query","schema":{"type":"string"}},{"name":"force","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Workspace removed"},"403":{"description":"Forbidden - Requires role: owner, application"}},"tags":["Mock Workspaces"]}}}}
```

## PUT /sfp/api/mocks/workspaces/{workspace}/services/{service}/rules

> Set the session rule override for a service (applies immediately)

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}},"schemas":{"SetRulesDto":{"type":"object","properties":{"rules":{"type":"array","items":{"type":"object","properties":{"request":{"type":"object","properties":{"method":{"type":"string"},"path":{"type":"string"},"query":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"bodyContains":{"type":"string"}},"required":["method","path"]},"response":{"type":"object","properties":{"status":{"type":"number"},"body":{},"headers":{"type":"object","propertyNames":{"type":"string"},"additionalProperties":{"type":"string"}},"delayMs":{"type":"number"}},"required":["status"]},"scenario":{"type":"string"},"responses":{"type":"array","items":{"type":"object","properties":{"status":{"type":"number"},"body":{}},"required":["status"],"additionalProperties":{}}}},"required":["request"]}}},"required":["rules"]}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}/services/{service}/rules":{"put":{"operationId":"MocksWorkspacesController_setRules","summary":"Set the session rule override for a service (applies immediately)","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}},{"name":"service","required":true,"in":"path","schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetRulesDto"}}}},"responses":{"200":{"description":"Override applied and stubs re-registered"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## DELETE /sfp/api/mocks/workspaces/{workspace}/services/{service}/rules

> Clear the session override; baseline re-applies

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}/services/{service}/rules":{"delete":{"operationId":"MocksWorkspacesController_clearRules","summary":"Clear the session override; baseline re-applies","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}},{"name":"service","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Override cleared and stubs re-registered"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## GET /sfp/api/mocks/workspaces/{workspace}/requests

> Incoming-request journal for the workspace

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}/requests":{"get":{"operationId":"MocksWorkspacesController_requests","summary":"Incoming-request journal for the workspace","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}},{"name":"service","required":true,"in":"query","schema":{"type":"string"}},{"name":"since","required":true,"in":"query","schema":{"type":"string"}},{"name":"limit","required":true,"in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"Journal entries (newest first), wasMatched flags unanswered callouts"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## GET /sfp/api/mocks/workspaces/{workspace}/services/{service}/rules.yaml

> Export effective rules as yaml (graduate session edits to the repo)

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}/services/{service}/rules.yaml":{"get":{"operationId":"MocksWorkspacesController_exportRules","summary":"Export effective rules as yaml (graduate session edits to the repo)","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}},{"name":"service","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"rules yaml"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## Record which org credentials were switched to the mock data plane

> Called after the org-side switch so restore works from anywhere — first recorded original endpoint wins.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}/switch-state":{"post":{"operationId":"MocksWorkspacesController_recordSwitchState","summary":"Record which org credentials were switched to the mock data plane","description":"Called after the org-side switch so restore works from anywhere — first recorded original endpoint wins.","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"201":{"description":"Switch state recorded"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```

## Restore switched credentials to their original endpoints, org-side

> Resolves review-environment auth from the workspace context; force continues past per-credential failures.

```json
{"openapi":"3.0.0","info":{"title":"sfp server","version":"51.40.2"},"security":[{"access-token":[]}],"components":{"securitySchemes":{"access-token":{"scheme":"bearer","bearerFormat":"JWT","type":"http","in":"header"}}},"paths":{"/sfp/api/mocks/workspaces/{workspace}/restore":{"post":{"operationId":"MocksWorkspacesController_restore","summary":"Restore switched credentials to their original endpoints, org-side","description":"Resolves review-environment auth from the workspace context; force continues past per-credential failures.","parameters":[{"name":"workspace","required":true,"in":"path","schema":{"type":"string"}}],"responses":{"200":{"description":"Per-credential restore outcome"},"403":{"description":"Forbidden - Requires role: owner, member, application"}},"tags":["Mock Workspaces"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flxbl.io/flxbl/sfp-server/api-reference/mock-workspaces.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
