# `GET /v1/workspace` — Get the Workspace

Part of the [Bkper Managed Agent API](https://bkper.com/docs/api/managed-agent.md). Read its guide for authentication, conventions, and examples.

The user's verified domain, when they have one; the Book asked for, named by Bkper, when the user can view it; and every App the user develops: `managed` ones are `apps/{appId}`, `external` ones are hosted elsewhere (`repoUrl`). The user's own context is always `user`.

## Operation contract

```json
{
  "operationId": "getWorkspace",
  "tags": [
    "Workspace"
  ],
  "summary": "Get the Workspace",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [
    {
      "name": "bookId",
      "in": "query",
      "schema": {
        "type": "string",
        "pattern": "^[A-Za-z0-9_-]{1,128}$"
      }
    }
  ],
  "description": "The user's verified domain, when they have one; the Book asked for, named by Bkper, when the user can view it; and every App the user develops: `managed` ones are `apps/{appId}`, `external` ones are hosted elsewhere (`repoUrl`). The user's own context is always `user`.",
  "responses": {
    "200": {
      "description": "Success",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Workspace"
          }
        }
      }
    },
    "400": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "401": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "403": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "404": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "409": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "410": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "411": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "413": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "422": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "503": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  }
}
```

## Schemas

### Workspace

```json
{
  "type": "object",
  "properties": {
    "domain": {
      "description": "The user's company: their verified domain, when they have one. Its context is `domain`, read by everyone in it.",
      "type": "object",
      "properties": {
        "canEdit": {
          "type": "boolean",
          "description": "Whether the user may change its context: the domain's admin."
        }
      },
      "required": [
        "canEdit"
      ]
    },
    "book": {
      "description": "The Book asked for (`bookId`), when the user can view it: its context is `books/{bookId}`.",
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string",
          "description": "The Book's name, from Bkper."
        },
        "canEdit": {
          "type": "boolean",
          "description": "Whether the user may change its context: its editors and owner."
        }
      },
      "required": [
        "id",
        "name",
        "canEdit"
      ]
    },
    "apps": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "source": {
            "type": "string",
            "enum": [
              "managed",
              "external"
            ],
            "description": "managed: Bkper hosts its source, the repository `apps/{appId}`. external: hosted elsewhere, such as on GitHub; not a repository here."
          },
          "repoUrl": {
            "description": "external only: where its source is, an http(s) URL, when the App names one.",
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "source"
        ]
      },
      "description": "Every App the user develops (owner or developer), by name."
    }
  },
  "required": [
    "apps"
  ],
  "description": "The Workspace's root, beside the user's own context (`user`): the same tree as the agent's sandbox and a local `~/.bkper` (context) and the user's Apps."
}
```

### Error

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Stable code, e.g. not_found, idempotency_conflict, session_working, usage_limit_exceeded. Open."
        },
        "type": {
          "description": "Category, e.g. invalid_request_error, authentication_error, usage_limit_error. Open.",
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "host": {
          "description": "host_in_use: the host another service holds.",
          "type": "string"
        },
        "service": {
          "description": "host_in_use: the id of the service that holds the host.",
          "type": "string"
        },
        "reason": {
          "description": "file_invalid: why the change, or a picture, was refused. Open: path | text | size | skill | skills | count | type.",
          "type": "string"
        },
        "paths": {
          "description": "file_exists from an add: every path of the request where a file is and `replace` was not set, all at once, so the person can be asked once. publish_conflict: the files someone published changes to the same lines of.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "publishers": {
          "description": "publish_conflict: who published those changes, by name.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "code"
      ]
    }
  },
  "required": [
    "error"
  ]
}
```

## Authentication

```json
{
  "bearerAuth": {
    "type": "http",
    "scheme": "bearer"
  }
}
```
