{
  "swagger": "2.0",
  "info": {
    "title": "Sandbox workspace service",
    "version": "0.1507.0",
    "description": "Send your API key as a bearer token: `Authorization: Bearer <api key>`."
  },
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "Authorization",
      "description": "Your API key as a bearer token: `Authorization: Bearer <api key>`."
    }
  },
  "security": [
    {
      "ApiKey": []
    }
  ],
  "paths": {
    "/scout/v1/sandbox-workspace/{workspaceRid}/demo-workbooks": {
      "get": {
        "operationId": "SandboxWorkspaceService_getDemoWorkbooks",
        "summary": "Get demo workbooks",
        "tags": [
          "Sandbox Workspace Service"
        ],
        "description": "Returns the list of demo workbook RIDs for the given sandbox workspace.",
        "parameters": [
          {
            "name": "workspaceRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "WorkspaceRid",
            "required": true
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/GetDemoWorkbooksResponse"
            },
            "x-example": {
              "notebookRids": [
                "<notebook rid>"
              ]
            }
          }
        }
      },
      "put": {
        "operationId": "SandboxWorkspaceService_setDemoWorkbooks",
        "summary": "Set demo workbooks",
        "tags": [
          "Sandbox Workspace Service"
        ],
        "description": "Sets the list of demo workbook RIDs for the given sandbox workspace, replacing any existing entries.",
        "parameters": [
          {
            "name": "workspaceRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "WorkspaceRid",
            "required": true
          },
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/SetDemoWorkbooksRequest"
            },
            "required": true,
            "x-example": {
              "notebookRids": [
                "<notebook rid>"
              ]
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content."
          }
        }
      },
      "post": {
        "operationId": "SandboxWorkspaceService_addDemoWorkbooks",
        "summary": "Add demo workbooks",
        "tags": [
          "Sandbox Workspace Service"
        ],
        "description": "Appends workbooks to the existing demo workbook list. If archiveOnLabelConflict is true, existing workbooks with an exact label-set match are archived along with all related resources instead of raising an error. The cascade performs a full graph traversal: starting from the workbook's data scope (asset RIDs or run RIDs), it alternates between discovering runs linked to assets and assets linked to runs until convergence. All discovered assets, runs, datasets (from both asset and run data scopes), and events (from snapshot refs and from all discovered assets) are then archived. This ensures no orphaned resources remain when demo workbooks are replaced. Partial (subset/superset) label conflicts always raise an error.",
        "parameters": [
          {
            "name": "workspaceRid",
            "in": "path",
            "type": "string",
            "format": "rid",
            "x-alias": "WorkspaceRid",
            "required": true
          },
          {
            "name": "request",
            "in": "body",
            "schema": {
              "$ref": "#/definitions/AddDemoWorkbooksRequest"
            },
            "required": true,
            "x-example": {
              "notebookRids": [
                "<notebook rid>"
              ],
              "archiveOnLabelConflict": true
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content."
          }
        }
      }
    }
  },
  "definitions": {
    "AddDemoWorkbooksRequest": {
      "type": "object",
      "properties": {
        "notebookRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "NotebookRid"
          }
        },
        "archiveOnLabelConflict": {
          "type": "boolean",
          "description": "When true, existing workbooks with an exact label-set match are archived instead of raising an error, along with all related resources discovered via full graph traversal: the workbook's data scope seeds initial assets or runs, then the system alternates between discovering runs linked to assets and assets linked to runs until no new resources are found. All discovered assets, runs, datasets (from both asset and run data scopes), and events (from the workbook's snapshot refs and from all discovered assets) are archived. This is intended for demo workbook replacement flows where all resources are recreated from scratch. Partial (subset/superset) label conflicts always raise an error. Defaults to false."
        }
      },
      "example": {
        "notebookRids": [
          "<notebook rid>"
        ],
        "archiveOnLabelConflict": true
      }
    },
    "GetDemoWorkbooksResponse": {
      "type": "object",
      "properties": {
        "notebookRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "NotebookRid"
          }
        }
      }
    },
    "SetDemoWorkbooksRequest": {
      "type": "object",
      "properties": {
        "notebookRids": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "rid",
            "x-alias": "NotebookRid"
          }
        }
      },
      "example": {
        "notebookRids": [
          "<notebook rid>"
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Sandbox Workspace Service",
      "x-displayName": "Sandbox workspace service",
      "description": "Service for managing demo workbooks in sandbox workspaces. All endpoints validate that the provided workspace has the human-readable ID \"sandbox\".",
      "x-errors": [
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "SandboxWorkspace:WorkspaceNotSandbox"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "SandboxWorkspace:DemoWorkbookTitleRequired"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "SandboxWorkspace:DemoWorkbookDescriptionRequired"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "SandboxWorkspace:DemoWorkbookLabelsRequired"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "SandboxWorkspace:DemoWorkbookMustBePublished"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "SandboxWorkspace:DemoWorkbookAlreadyArchived"
        },
        {
          "status": 400,
          "errorCode": "INVALID_ARGUMENT",
          "errorName": "SandboxWorkspace:DemoWorkbookDuplicateLabels"
        }
      ]
    }
  ]
}
