> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devias.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The docs are served at https://docs.devias.io. Every path in these docs is relative to that root: /llms.txt is https://docs.devias.io/llms.txt.
> Devias is an open-source platform that works as an operating system for a business: a core (records, views, workflows, agents, permissions) with installable modules.
> Pages are typed by folder. concepts/ explains what things are, guides/ gives procedures, reference/ is exhaustive (SDK, CLI, HTTP API), operate/ covers hosting. Use /start/glossary for exact terms.
> Every id in a module (module, object, field, view, action, workflow, step, connection, variable, event, policy) is a uuid. Generate them with `devias id <count>`. Never invent dotted or readable ids.
> Run `devias plan` and read its output before `devias apply`. Apply only what the plan says.
> The OpenAPI document, including the routes of the modules in the reference setup, is at /reference/api/openapi.json.
> Devias is young and changes quickly. If a page and the source repository (github.com/devias-io/devias) disagree, the repository is right.

# SDK metadata and modules

> How to read a workspace schema with metadata.getSchema, change objects, fields, views, layouts, navigation and commands with list, get, create, update and delete, and plan, apply, uninstall and run actions of modules with the TypeScript SDK.

The SDK reads the shape of a workspace, changes it, and installs modules from code through `client.metadata` and `client.modules`.

## Read the schema

`metadata.getSchema()` returns everything the studio needs to draw a workspace in one call: its objects, fields, views, layouts, navigation, commands and installed modules.

```ts theme={"dark"}
const schema = await client.metadata.getSchema();
schema.objects.map((object) => object.nameSingular); // ['person', 'company', 'deal']
```

Its `version` increases whenever the model changes, so it can be used as a cache key.

## Change the model

Objects, fields, views, layouts, navigation items and command items all have the same four methods: `list`, `get`, `create`, `update` and `delete`.

```ts theme={"dark"}
await client.metadata.fields.create({
  objectId: person.id,
  name: 'nickname',
  label: 'Nickname',
  type: 'text',
});
```

What a module owns is protected: a workspace can add to it, and cannot edit or delete what the module declared.

## Modules

| Call | What it does |
| - | - |
| `modules.list()` | The installed modules. |
| `modules.catalog()` | Every module the server can install. |
| `modules.plan(manifest)` | What applying a manifest would change. |
| `modules.apply(manifest)` | Apply it. Pass `allowDestructive` to allow deletions. |
| `modules.uninstall(id)` | Remove a module and what it owns. |
| `modules.runAction(id, name, input)` | Run one of a module's actions now. |

```ts theme={"dark"}
const plan = await client.modules.plan(manifest);

if (!plan.hasDestructive && !plan.hasConflicts) {
  await client.modules.apply(manifest);
}
```

## Connections, variables and events

A module with an outside service also has:

* `modules.connections`: list, create, test and disconnect connections;
* `modules.variables`: read and set its settings;
* `modules.events(id)`: read the events its webhook received.

## Related

* [Plan and apply](https://docs.devias.io/guides/modules/plan-and-apply.md): the same flow from the command line.
* [Events and notifications](https://docs.devias.io/reference/sdk/events-and-notifications.md): react to changes as they happen.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.