Skip to main content
A personal AI knowledge base - a folder of notes, research, and strategy docs that an agent can read and act on - works well for one person. Startups and enterprises, however, need a shared source of truth that multiple people and multiple agents can use safely. Teams have to answer questions like:
  • Who can access specific information, and who can update it?
  • Which version is current?
  • How do you review agent-generated changes?
  • Can an answer be traced back to the source material it came from?
The answer is a shared company brain: a governed repository of company context, product knowledge, operating rules, and generated outputs that humans and agents use to operate the business. This provides the same trusted content whether it is reached by a developer’s local coding agent, a cloud agent over MCP, or a person in the Box web app. This tutorial builds that knowledge layer with Box:
  1. You organize content into a domain-based structure - one curated knowledge base per domain - with a staging area for new files and an approved area for trusted ones.
  2. When a file lands in staging, you use Box AI to review it: summarize it, score its content health, suggest a domain and tags, and flag issues like missing owners or stale guidance.
  3. You record that review as Box metadata so every file carries its governance status, and you promote approved content into a Box Hub - the trusted destination that agents query.
  4. Humans and agents query the brain through Box AI, getting answers grounded in approved, permission-controlled content, with citations back to the source.

What you are building

By the end of this tutorial, you have a working Python project that:
  • Provisions a governed folder structure - the company brain - organized by domain, each with a staging and an approved area.
  • Uses a dedicated service account as the shared, governed identity that both your automation and your agents act through.
  • Reviews staged files with Box AI, producing a summary, a suggested domain, tags, and a content health score, then flags quality issues.
  • Writes the review back to each file as a governance metadata instance, so status and ownership are searchable and auditable.
  • Publishes approved content to a domain Box Hub and answers natural-language questions grounded in that trusted content.
  • Gives your local and cloud agents a safe, permission-aware way to work from the same source of truth.

Prerequisites

Before you start, make sure you have the following:
  • A , or a with Box AI and Box Hubs enabled. See .
  • A Box platform application configured with Client Credentials Grant authentication.
  • Admin access to create a metadata template (Step 2), or a Box administrator who can create one for you.
  • Python 3.11 or higher.
  • The following scopes enabled on your platform app:
    • Read and write all files and folders stored in Box
    • Manage AI
    • Manage enterprise properties (required to create and write metadata)

Step-by-step process

A company brain is built from four Box Platform capabilities working together. Each one maps to a requirement that a shared, trusted knowledge layer must meet.
Box Hubs and Box AI inherit permissions from the underlying source files. Both people and agents only ever see answers derived from content they already have access to in Box. The company brain does not add a separate access-control layer - it reuses the one you already trust.
1

Design your company brain structure

The best knowledge bases are domain-based, not generic. Rather than one giant brain, create a focused knowledge base per domain - security, legal, product, and so on - and let each domain team own its content.Within each domain, separate content that has been reviewed from content that has not. New files land in a _staging area; only approved files move to the approved area that agents are pointed at.Create a folder structure in Box similar to the following:
Note the folder ID of the top-level Company Brain folder, and the ID of one domain’s _staging folder (for example, security/_staging). You use these in later steps. The folder ID is the number at the end of the folder’s URL: https://app.box.com/folder/123456789 means the folder ID is 123456789.
The operating-rules folder is part of the brain, not an afterthought. Storing your agent operating rules alongside the knowledge they govern means every agent - local or cloud - reads the current rules from the same place, instead of each teammate copying yesterday’s version into their own workspace.
This tutorial works one domain end to end (for example, security). Once the pattern works, repeat it per domain. Adding a domain is easy: a new folder pair and a new Hub, owned by the team closest to the work.
2

Create the knowledge governance metadata template

Governance is what separates a trusted knowledge base from a folder of files. A metadata template lets every file carry the same governance fields - which domain it belongs to, who owns it, whether it is approved, and how healthy its content is - so status is explicit, searchable, and auditable.
This step requires Admin access. If you do not have access, contact your Box administrator.
  1. Open the Box Admin Console and select Metadata.
  2. Click New and name the template Knowledge Governance.
  3. Add the following fields:
  1. Click Save.
  2. Click back into your newly created template and copy the template key shown under the template name. You need it in a later step.
Box derives each field’s key from its display name in camel case - Content Health Score becomes contentHealthScore. The code in Step 6 uses these keys. If you rename a field, confirm its key in the Admin Console and update the code to match. For a detailed walkthrough, see .
3

Set up the development environment

  1. Open your terminal and create a new project directory:
  1. Create and activate a Python virtual environment:
After activation, your terminal prompt shows (.venv) at the beginning. This confirms you are working inside the virtual environment.
Every time you open a new terminal window or tab, re-activate the virtual environment by running source .venv/bin/activate from the project directory. If you see ModuleNotFoundError when running commands, it usually means the venv is not activated.
  1. Install the required packages:
  1. Create a .env file to store your credentials, then add the following content. Replace the placeholder values with your actual credentials from the Box Developer Console:
Never commit .env files to version control. Add .env to your .gitignore.
Understanding environment variables: The .env file stores sensitive values (your actual credentials). Your Python code reads these values by referencing their names using os.getenv("VARIABLE_NAME"). When you copy the code in the following steps, keep the quoted variable names exactly as shown. Do not replace them with your actual credentials.
4

Authenticate as a service account

A company brain is shared, so it should be reached through a shared, governed identity rather than any one person’s account. Client Credentials Grant gives your automation - and the agents you connect later - their own service account in Box. That service account is the security boundary: it can only touch content you explicitly share with it.Create a file called box_client.py and add the following code:
Share the company brain with the service account. A CCG app acts as a separate service account user that does not automatically have access to your content. Invite the service account email as a collaborator on the top-level Company Brain folder with the Editor role - Editor is required so the app can write metadata and move approved files.To find the email: go to the Developer Console, open your app, and look in the App Details sidebar for the Service Account ID (it looks like AutomationUser_xxxxx_xxxxxx@boxdevedition.com). Without this, API calls return 404 Not found.
Sharing only the Company Brain folder - not your whole account - is the point. The service account gets exactly the access the brain needs and nothing more. This is the same boundary you rely on later when an agent authenticates as this identity.
5

Review staged content with Box AI

If an agent can search everything, it can also find the wrong thing - an old scope deck, an unreviewed draft, a template with outdated assumptions. For a person that is annoying; for an agent it is a trust problem. So before a file becomes part of the trusted layer, it goes through an intake review.Instead of prompting Box AI with an open-ended question, you define a fixed review schema so every file comes back in the same shape. Create a file called review.py:
The fixed schema is what makes the review dependable: the same fields, in the same shape, for every file - so the intake step behaves consistently no matter who uploaded the document or how it is formatted.
Treat the content health score as a signal, not a verdict. A low score means “an owner should look at this before agents rely on it,” which is exactly what the approval step in Step 6 is for.
6

Record the review as governance metadata

A review is only useful if it stays attached to the file. Writing the result back as a metadata instance means every file carries its own governance record - domain, owner, status, and health - that both people and agents can see, search, and audit.Create a file called intake.py. It reviews every file in a domain’s staging folder and stamps each one with governance metadata:
Upload a document or two to your domain’s _staging folder in Box, then run:
For each staged file you see the suggested domain, a health score, a summary, and any review notes - and each file is stamped with a staged governance record.
The intake step sets status to staged and owner to unassigned on purpose. A file being uploaded does not make it trusted knowledge. A human still decides what gets approved and who owns it - the next step.
To run intake automatically whenever a file lands in staging, trigger it from a folder event instead of running it by hand. See for event-driven routing and approval tasks, or register a on the staging folder.
7

Approve content and publish it to a domain Hub

Once a domain owner is satisfied with a file, it becomes trusted knowledge and needs a destination where both people and agents can find it. A Box Hub is that destination: a curated, permission-inheriting knowledge base for one domain. Pointing agents at a small set of approved content - rather than every file the company has - is what keeps answers grounded and trustworthy.Create a file called publish.py. It marks a file as approved, moves it into the domain’s approved folder, and ensures a domain Hub exists and contains that folder:
Run it once for a file you want to approve:
Save the hub ID from the output - you need it to query the brain.
You create a domain’s Hub once, then reuse it. In production, look up the existing Hub for a domain and only create one if it does not exist, rather than creating a new Hub on every approval. Adding a folder to a Hub automatically indexes the files within it, and new files added to that folder are picked up automatically.
Control who can query the knowledge base by adding Hub collaborations - viewer for people who consume knowledge, editor for the domain owners who curate it. See .
8

Query the company brain

With approved content published, both people and agents can ask natural-language questions and get answers grounded in reviewed, source-backed material - with citations back to the files the answer came from. Create a file called ask.py:
Replace YOUR_HUB_ID with the hub ID from the previous step, then run:
Because the Hub inherits Box permissions, the answer only ever draws on documents the querying identity can access, and each answer lists the approved files it came from. The result is a knowledge base agents can depend on, instead of a guess assembled from a random mix of search results.At this point, your project directory should contain the following files:
After publishing content to a Hub, allow a few minutes for Box to index the files before querying. Queries against newly added content may return empty or incomplete results until indexing completes.
9

Connect your agents to the company brain

This step is guidance rather than code you run now. It shows how the same governed brain you just built becomes the memory layer for your agents, wherever they run.
The whole point of a company brain is that it stays put while the agents change. Different teammates use different tools - a coding agent, a cloud assistant, a workflow bot - and the brain should not have to change as the agent changes; it should keep compounding. Box exposes the same source of truth through two access paths:
  • Local agents (for example, a coding agent working against synced files) reach the brain through Box Drive or the , treating it like a local repository. Authenticate the CLI as the service account from Step 4 so the agent inherits exactly the access you granted the brain. More information is available on how to .
  • Cloud agents (for example, an assistant in a chat app) reach the same content through the , with permission-aware access and admin controls. See more information on how to .
Both are working from the same underlying files, permissions, and versions. Store the rules that govern agent behavior in the operating-rules folder so every agent reads the current version from the brain itself. For example:
Version history, review workflows, and audit trails are not extra work you bolt on - they come from Box. When an agent writes an output back to the brain, it inherits the same governance every human contribution does.
10

Keep the brain healthy

This step provides reference patterns for keeping the knowledge base trustworthy over time. You do not need to run it now.
The default failure mode of any knowledge base is drift: policies go stale, best practices stay trapped in one team, and approved content slowly ages out of date. A healthy company brain closes the loop - the organization’s own work continuously improves it.Use the governance metadata you are already writing to surface content that needs attention. A can find every approved file below a health threshold, or every file still staged after too long:
Feed those signals back to the domain owner. Every workflow also generates signals worth capturing - missing context, repeated review comments, gaps an agent could not answer. Route them into the next review cycle so the brain gets more valuable the more it is used.
The from value must include your enterprise ID. Use enterprise_{BOX_ENTERPRISE_ID}.{template_key} - for example, enterprise_123456789.knowledgeGovernance.
Pair this with a scheduled review per domain. The owner re-reviews low-health and aging content, updates or archives it, and the Hub reindexes automatically. Ownership is what keeps quality from degrading - assign every domain an accountable owner.

Troubleshooting

Your virtual environment is not activated. Run source .venv/bin/activate from the project directory before running any python3 commands. Each new terminal tab needs its own activation.
Check your .env file:
  • Verify BOX_CLIENT_ID and BOX_CLIENT_SECRET match the values in Developer Console > Configuration.
  • Confirm BOX_ENTERPRISE_ID is your enterprise ID (Admin Console > Account & Billing, or Developer Console > icon in the top-right > Copy Enterprise ID).
  • Ensure your app is authorized in the Developer Console and uses Client Credentials Grant.
The service account does not have access to the folder or file. Invite the service account email (Developer Console > General Settings) as a collaborator with the Editor role on the top-level Company Brain folder. Because subfolders inherit collaboration, this grants access to every domain, staging, and approved folder inside it.
The BOX_METADATA_TEMPLATE_KEY value in your .env file is missing or empty. Add the template key you copied when creating the Knowledge Governance template in Step 2.
This means the request reached your template (a missing template returns 404, not 400), but one of the keys in the payload is not a field in the template, or a value breaks a field’s type. The most common cause is a field name mismatch - for example, if the first field was created as Domain in the Admin Console, Box generates the key domain, but if it was named anything else the key differs and the domain key the code sends is rejected.Every key in build_governance (domain, owner, status, contentHealthScore, summary, tags, reviewNotes) must exactly match a field key in your template. Print the actual keys and types to compare:
Then either rename or add the field in the Admin Console so its key matches (field keys are immutable once created, so add a correctly named field rather than trying to rename the key), or update the dict keys in build_governance to match what the template actually uses. A Number field also rejects non-numeric values, so make sure the health score is sent as a number.
This usually means the Hub content has not finished indexing, or the approved folder is empty:
  • Wait a few minutes after publishing before querying. Indexing is not instantaneous.
  • Verify the approved folder contains files (not just subfolders) and that they contain text (scanned image PDFs without OCR are not searchable).
  • Confirm you are querying the correct hub ID from Step 7.

Scaling to production

Instead of running intake.py by hand, trigger the review when a file lands in a _staging folder and route the result to the right owner as an approval task. See for event-driven workflows, or register a on each staging folder.
Provision a dedicated Hub for each domain and let agents combine the hubs a task needs - a product-planning agent might draw on product, legal, and security, while a code-review agent draws on architecture, security, and accessibility. Loop over your domains to create their folder pairs and Hubs, and give each domain an accountable owner.
The POST /2.0/ai/ask endpoint accepts a dialogue_history parameter carrying previous question-and-answer pairs. Maintain a list of exchanges and pass it with each request so users can ask follow-ups without losing context. See for a conversational implementation.
Combine the brain with to archive or delete outdated material automatically, and use enterprise events to see which content agents rely on most. Treat the knowledge layer as enterprise infrastructure, not an AI feature - the organizations that build it as a governed, reusable, permission-aware layer gain an advantage every time a new agent enters the business.

Next steps

Sales RFP answer bank

Apply the same Hubs and Box AI pattern to a sales knowledge base, and embed it in your CRM.

Box Hubs API reference

See the full Hubs API guide for advanced hub management.
Last modified on July 24, 2026