# @uidu/client reference

URL: https://developers.uidu.org/docs/reference/client

> Every export of @uidu/client, grouped by domain — 154 functions, generated from the source.

Every function takes a `UiduClient` as its first argument. **Kind**: *read* runs a query, *write* runs a mutation and returns its payload (check `errors`), *helper* is pure. **Auth**: *public token* works in the browser; *Bearer* needs an account token (`apiKey`) and must run server-side — see [Writes](https://developers.uidu.org/docs/foundations/writes.md). **CLI** lists the `uidu` commands that call the function.

Domains: [Client & utilities](#core) · [CMS — Sites](#sites) · [CMS — Projects (legacy)](#cms) · [Stories](#stories) · [Help center](#help-center) · [Knowledge base](#kb) · [Search](#search) · [Forms](#forms) · [Events](#events) · [Donations](#donations) · [Courses](#courses) · [Calls](#calls) · [Jobs & applications](#jobs) · [Contacts & deals](#contacts) · [Campaigns](#campaigns) · [People (HR)](#people) · [Goals (OKRs)](#goals) · [Spaces, tasks & notes](#workspace) · [Bookings & calendars](#bookings) · [Models (custom data)](#models) · [Provisioning & actions](#provisioning)

## Client & utilities

Client construction, errors, pagination, field-value helpers.

Guide: [Client & utilities](https://developers.uidu.org/docs/foundations/data-model.md).

* [`UiduClient`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/client.ts) — Sends GraphQL documents to one uidu endpoint with the configured credentials, and throws a `UiduError` when a request fails.
* [`UiduError`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/types.ts) — What `UiduClient` throws: `code` is `GRAPHQL_ERROR` (with `graphQLErrors`), `NETWORK_ERROR`, `TOKEN_ERROR` or `CONFIG_ERROR`.

| Function                                                                                                                  | Kind   | Auth | CLI | Description                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------------- | ------ | ---- | --- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createClient`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/client.ts)                              | helper | —    | —   | Build a `UiduClient`; it needs a `workspace` or an `endpoint`, and authenticates with `publicToken`, `apiKey` or `getToken`.                      |
| [`fromBridge`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/client.ts)                                | helper | —    | —   | Client config for a custom app, from a connected `@uidu/app-bridge`: the bridge's GraphQL endpoint, with its session token asked for per request. |
| [`normalizeFieldValueContent`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/utils/fieldValues.ts)     | helper | —    | —   | Wrap a `content` payload in `{ value }` unless it already carries a `value` key. Returns the input untouched when there is nothing to do.         |
| [`normalizeFieldValuesAttributes`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/utils/fieldValues.ts) | helper | —    | —   | Normalize a standalone `fieldValuesAttributes` array. Exported for callers that assemble one by hand outside an SDK mutation.                     |
| [`paginate`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/utils/paginate.ts)                          | read   | —    | —   | Walks every page of a Relay-style connection and returns a flat array of nodes.                                                                   |

**Types:** `PaginateOptions`, `UiduClientConfig`, `UiduErrorOptions`

## CMS — Sites

The new CMS: Site → page/block Models → ModelItems.

Guide: [CMS — Sites](https://developers.uidu.org/docs/domains/cms.md).

| Function                                                                                         | Kind  | Auth         | CLI            | Description                                                                                                                                                                                             |
| ------------------------------------------------------------------------------------------------ | ----- | ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createSite`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/sites.ts)        | write | Bearer       | `sites create` | Provisions a new Site in the workspace/account (`tenantId`). Bearer token (`apiKey`) — this is workspace admin territory, never a public write. Returns the mutation payload as-is, including `errors`. |
| [`getPageBySlug`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/sites.ts)     | read  | public token | —              | A page of the Site by slug, with its field values and its ordered blocks. Only published pages unless `includeDrafts`.                                                                                  |
| [`getSingletonBlock`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/sites.ts) | read  | public token | —              | A singleton of the Site — the header, the footer, the nav — by its Model's shortname, with its field values and blocks.                                                                                 |
| [`getSite`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/sites.ts)           | read  | public token | —              | A Site by its id — for previews, where there is no domain to go by.                                                                                                                                     |
| [`getSiteByDomain`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/sites.ts)   | read  | public token | —              | The Site served on `domain` (e.g. `www.acme.org`), or null.                                                                                                                                             |
| [`listSitePages`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/sites.ts)     | read  | public token | —              | The Site's pages, for navigation and sitemaps: published only unless `includeDrafts`, singletons (header, footer) left out.                                                                             |

**Types:** `Site`, `SiteBlock`, `SiteFields`, `SiteModel`, `SitePage`, `SitePageSummary`

## CMS — Projects (legacy)

Legacy CMS: Project → Page → PageBlock → FieldValue.

Guide: [CMS — Projects (legacy)](https://developers.uidu.org/docs/domains/cms.md).

| Function                                                                                      | Kind  | Auth         | CLI              | Description                                                                                                                                                                   |
| --------------------------------------------------------------------------------------------- | ----- | ------------ | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createFieldValue`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts) | write | Bearer       | `field create`   | Create a field value, e.g. set a page block's field (`fieldId`, `content`). Returns the payload (with `errors`) or null; the new value is at `fieldValue.node`.               |
| [`createPage`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts)       | write | Bearer       | `page create`    | Create a legacy CMS page from a `templateId`, with `slug` and optional `metadataAttributes` (there is no `projectId` attribute). Returns the payload (with `errors`) or null. |
| [`createPageBlock`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts)  | write | Bearer       | `block create`   | Place a template block on a page (`pageId`, `templateBlockId`, both numeric). Returns the payload (with `errors`) or null.                                                    |
| [`createProject`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts)    | write | Bearer       | `project create` | Create a legacy CMS project (`name`, `slug`, `domain`). Returns the payload (with `errors`) or null; the new project is at `project.node`.                                    |
| [`getPage`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts)          | read  | public token | `page get`       | A legacy CMS page by project and `slug`, with its metadata and ordered `pageBlocks` (and any linked form's questions), or null.                                               |
| [`getTemplate`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts)      | read  | public token | —                | A legacy CMS template by id, with every page it holds and their blocks, or null.                                                                                              |
| [`listPages`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts)        | read  | public token | `pages list`     | The pages of a legacy CMS project (`id` and `slug`), one Relay page at a time; use `paginate` with `ListPagesDocument` for all of them.                                       |
| [`listProjects`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/cms.ts)     | read  | public token | `projects list`  | The workspace's CMS projects. A page lives in one, and `getPage` needs its id.                                                                                                |

**Types:** `Page`, `Template`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListPagesDocument`

## Stories

Blog posts / news.

Guide: [Stories](https://developers.uidu.org/docs/domains/stories.md).

| Function                                                                                       | Kind  | Auth         | CLI              | Description                                                                                                                  |
| ---------------------------------------------------------------------------------------------- | ----- | ------------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| [`createStory`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/stories.ts)   | write | Bearer       | `stories create` | Create a story; returns the payload as-is, `{ errors, story }`, validation failures included.                                |
| [`getStory`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/stories.ts)      | read  | public token | `stories get`    | One story with its rich-text `body`, or null.                                                                                |
| [`listStories`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/stories.ts)   | read  | public token | `stories list`   | The workspace's stories as a flat array of summaries (no `body`); page with `first`/`after`.                                 |
| [`updateStory`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer       | `stories update` | Update a story: `{ input: { id, attributes } }` (create it with `createStory`). Returns the payload (with `errors`) or null. |

**Types:** `Story`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListStoriesDocument`

## Help center

Help-center channels.

Guide: [Help center](https://developers.uidu.org/docs/domains/help-center.md).

| Function                                                                                          | Kind  | Auth         | CLI              | Description                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------------- | ----- | ------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`createChannel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer       | `channel create` | Create a help-center channel. Returns the payload (with `errors`) or null. The new channel is at `channel.node`.                                                                           |
| [`deleteChannel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer       | `channel delete` | Delete a help-center channel by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                                                          |
| [`getChannel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/help-center.ts)   | read  | public token | `channel get`    | One help center channel with its collections and their articles in a single request (the last 100 of each), or null.                                                                       |
| [`listChannels`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/help-center.ts) | read  | public token | `channel list`   | The workspace's help center channels. `isDefault` marks the one the workspace treats as its main channel — a caller that has no channel id configured should prefer it over the first row. |
| [`updateChannel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer       | `channel update` | Update a help-center channel: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                                                |

**Types:** `Channel`

## Knowledge base

KB collections and articles.

Guide: [Knowledge base](https://developers.uidu.org/docs/domains/kb.md).

| Function                                                                                              | Kind  | Auth         | CLI                     | Description                                                                                                                                          |
| ----------------------------------------------------------------------------------------------------- | ----- | ------------ | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createKbArticle`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)    | write | Bearer       | `kb-articles create`    | Create a knowledge-base article in `attributes.kbCollectionId`. Returns the payload (with `errors`) or null. The new article is at `kbArticle.node`. |
| [`createKbCollection`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer       | `kb-collections create` | Create a knowledge-base collection. Returns the payload (with `errors`) or null. The new collection is at `kbCollection.node`.                       |
| [`deleteKbArticle`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)    | write | Bearer       | `kb-articles delete`    | Delete a knowledge-base article by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                 |
| [`deleteKbCollection`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer       | `kb-collections delete` | Delete a knowledge-base collection by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                              |
| [`getKbArticle`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/kb.ts)              | read  | public token | `kb-articles get`       | One knowledge-base article with its rich-text `body` and its collection, or null.                                                                    |
| [`getKbCollection`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/kb.ts)           | read  | public token | `kb-collections get`    | One knowledge-base collection with its first 50 articles, or null.                                                                                   |
| [`listKbArticles`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/kb.ts)            | read  | public token | `kb-articles list`      | Knowledge-base articles across every collection, as a flat array; page with `first`/`after` (or `last`/`before`).                                    |
| [`listKbCollections`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/kb.ts)         | read  | public token | `kb-collections list`   | The workspace's knowledge-base collections as a flat array; page with `first`/`after` (or `last`/`before`).                                          |
| [`updateKbArticle`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)    | write | Bearer       | `kb-articles update`    | Update a knowledge-base article: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                       |
| [`updateKbCollection`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer       | `kb-collections update` | Update a knowledge-base collection: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                    |

**Types:** `KbArticle`, `KbCollection`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListKbArticlesDocument`, `ListKbCollectionsDocument`

## Search

Workspace-wide full-text search.

Guide: [Search](https://developers.uidu.org/docs/domains/search.md).

| Function                                                                               | Kind | Auth         | CLI | Description                                                                                                                  |
| -------------------------------------------------------------------------------------- | ---- | ------------ | --- | ---------------------------------------------------------------------------------------------------------------------------- |
| [`search`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/search.ts) | read | public token | —   | Search the workspace index, optionally limited to `models`, with filters and sorting in `params`; page with `first`/`after`. |

**Types:** `SearchResult`

## Forms

Forms, their questions, and visitor responses.

Guide: [Forms](https://developers.uidu.org/docs/domains/forms.md).

| Function                                                                                          | Kind  | Auth         | CLI            | Description                                                                                                                                              |
| ------------------------------------------------------------------------------------------------- | ----- | ------------ | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createForm`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)     | write | Bearer       | `forms create` | Create a form, questions included via `attributes.formQuestionsAttributes`. Returns the payload (with `errors`) or null. The new form is at `form.node`. |
| [`createFormResponse`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/forms.ts) | write | Bearer       | —              | Submit a new response to a form; returns the payload as-is, `{ errors, formResponse }`, validation failures included.                                    |
| [`deleteForm`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)     | write | Bearer       | `forms delete` | Delete a form by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                                       |
| [`getForm`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/forms.ts)            | read  | public token | `forms get`    | One form with its questions (`inputs`, a connection of `FormQuestion` nodes with field metadata) ready to render, or null.                               |
| [`listForms`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/forms.ts)          | read  | public token | `forms list`   | The workspace's forms as a flat array of summaries, without their questions (use `getForm` for those); page with `first`/`after`.                        |
| [`updateForm`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)     | write | Bearer       | `forms update` | Update a form: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                             |
| [`updateFormResponse`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/forms.ts) | write | Bearer       | —              | Update a form response (answers by field value `id`, or a state `event` like `'complete!'`); returns `{ errors, formResponse }` as-is.                   |

**Types:** `Form`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListFormsDocument`

## Events

Events, their instances, and attendances (RSVPs).

Guide: [Events](https://developers.uidu.org/docs/domains/events.md).

| Function                                                                                         | Kind  | Auth         | CLI                  | Description                                                                                                                   |
| ------------------------------------------------------------------------------------------------ | ----- | ------------ | -------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| [`createAttendance`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/events.ts) | write | Bearer       | `attendances create` | RSVP a contact to an event: `attendableId` is an event *instance* id, never the event id.                                     |
| [`createEvent`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/events.ts)      | write | Bearer       | `events create`      | Create an event; returns the payload as-is, `{ errors, event }`, validation failures included.                                |
| [`getEvent`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/events.ts)         | read  | public token | `events get`         | One event with its primary address, its next or current `instance` and all its `instances`, or null.                          |
| [`listEvents`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/events.ts)       | read  | public token | `events list`        | The workspace's events as a flat array of summaries, each with its next or current `instance`; page with `first`/`after`.     |
| [`updateEvent`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)   | write | Bearer       | `events update`      | Update an event: `{ input: { id, attributes } }` (create it with `createEvent`). Returns the payload (with `errors`) or null. |

**Types:** `Event`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListEventsDocument`

## Donations

Donation campaigns and donations.

Guide: [Donations](https://developers.uidu.org/docs/domains/donations.md).

| Function                                                                                                  | Kind  | Auth         | CLI                | Description                                                                                                                   |
| --------------------------------------------------------------------------------------------------------- | ----- | ------------ | ------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| [`createDonation`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/donations.ts)         | write | Bearer       | —                  | Record a donation (amount in cents) to a campaign, creating the donor's contact inline; returns `{ errors, donation }` as-is. |
| [`createDonationCampaign`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/donations.ts) | write | Bearer       | `donations create` | Create a donation campaign (`goal` in cents); returns the payload as-is, `{ errors, donationCampaign }`.                      |
| [`deleteDonationCampaign`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer       | `donations delete` | Delete a donation campaign by `{ input: { id } }`. Returns the payload (with `errors`) or null.                               |
| [`getDonationCampaign`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/donations.ts)    | read  | public token | `donations get`    | One donation campaign with its body, its totals (`goal`, `donationsAmount`, in cents) and its donor `form`, or null.          |
| [`listDonationCampaigns`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/donations.ts)  | read  | public token | `donations list`   | The workspace's donation campaigns as a flat array of summaries with their totals in cents; page with `first`/`after`.        |
| [`updateDonationCampaign`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer       | `donations update` | Update a donation campaign: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                     |

**Types:** `DonationCampaign`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListDonationCampaignsDocument`

## Courses

Courses, lectures and enrollments.

Guide: [Courses](https://developers.uidu.org/docs/domains/courses.md).

| Function                                                                                         | Kind  | Auth         | CLI              | Description                                                                                                                                      |
| ------------------------------------------------------------------------------------------------ | ----- | ------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| [`createCourse`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer       | `courses create` | Create a course from `{ input: { attributes } }`. Returns the payload (with `errors`) or null.                                                   |
| [`deleteCourse`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer       | `courses delete` | Delete a course by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                             |
| [`getCourse`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/courses.ts)       | read  | public token | `courses get`    | One course with its rich-text `body`, or null.                                                                                                   |
| [`getEnrollment`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/courses.ts)   | read  | Bearer       | —                | One enrollment with its course, contact and custom fields (`fieldValuesByShortname`), or null.                                                   |
| [`getLecture`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/courses.ts)      | read  | public token | —                | One lecture with its `body`, its course and its `nextLecture` / `previousLecture` for navigation, or null.                                       |
| [`listCourses`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/courses.ts)     | read  | public token | `courses list`   | The workspace's courses as a flat array, optionally filtered with search `params`; page with `first`/`after`.                                    |
| [`listEnrollments`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/courses.ts) | read  | Bearer       | —                | Course enrollments as a flat array, optionally filtered with search `params`; page with `first`/`after`.                                         |
| [`listLectures`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/courses.ts)    | read  | public token | —                | Lectures across every course as a flat array (filter by `course.id` yourself), with `scopes`, `orderBy`, `from`/`to`; page with `first`/`after`. |
| [`updateCourse`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer       | `courses update` | Update a course: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                   |

**Types:** `Course`, `Enrollment`, `Lecture`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListCoursesDocument`, `ListEnrollmentsDocument`, `ListLecturesDocument`

## Calls

Open calls (grants, applications windows).

Guide: [Calls](https://developers.uidu.org/docs/domains/calls.md).

| Function                                                                                 | Kind | Auth         | CLI          | Description                                                                                          |
| ---------------------------------------------------------------------------------------- | ---- | ------------ | ------------ | ---------------------------------------------------------------------------------------------------- |
| [`getCall`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/calls.ts)   | read | public token | `calls get`  | One call (a job opening or open call) with its application `form`, same shape as `getForm`, or null. |
| [`listCalls`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/calls.ts) | read | public token | `calls list` | The workspace's calls as a flat array of summaries, without their forms; page with `first`/`after`.  |

**Types:** `Call`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListCallsDocument`

## Jobs & applications

Job postings (calls of kind `job`) and the applications to them.

Guide: [Jobs & applications](https://developers.uidu.org/docs/domains/jobs.md).

| Function                                                                                                  | Kind  | Auth         | CLI                   | Description                                                                                                                                                                                                               |
| --------------------------------------------------------------------------------------------------------- | ----- | ------------ | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`completeApplication`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/applications.ts) | write | Bearer       | —                     | Submit a draft application, the last step of applying.                                                                                                                                                                    |
| [`createApplication`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/applications.ts)   | write | Bearer       | `applications create` | Submit an application to a job. Pass `attributes.applicableId` (the job's id) plus `contactAttributes` and/or `formResponseAttributes`. Returns the mutation payload as-is (including any `errors`) rather than throwing. |
| [`getJob`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/jobs.ts)                      | read  | public token | `jobs get`            | Fetch a single job posting; returns `null` if the call is not a job.                                                                                                                                                      |
| [`listApplications`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/applications.ts)    | read  | Bearer       | `applications list`   | List applications across the workspace (requires a Bearer token).                                                                                                                                                         |
| [`listJobs`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/jobs.ts)                    | read  | public token | `jobs list`           | List job postings (calls of kind `job`).                                                                                                                                                                                  |
| [`updateApplication`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/applications.ts)   | write | Bearer       | —                     | Update an application, optionally firing a state event (`event: 'complete!'`). Returns the mutation payload as-is (including any `errors`) rather than throwing.                                                          |

**Types:** `Application`, `Job`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListApplicationsDocument`

## Contacts & deals

CRM contacts, organisations and deals.

Guide: [Contacts & deals](https://developers.uidu.org/docs/domains/contacts.md).

| Function                                                                                         | Kind  | Auth   | CLI               | Description                                                                                                                                     |
| ------------------------------------------------------------------------------------------------ | ----- | ------ | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createContact`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer | `contacts create` | Create a CRM contact from `{ input: { attributes } }`. Returns the payload (with `errors`) or null.                                             |
| [`createDeal`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)    | write | Bearer | `deals create`    | Create a deal in a pipeline (`attributes.pipelineId`, `statusId`). Returns the payload (with `errors`) or null. The new deal is at `deal.node`. |
| [`deleteContact`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer | `contacts delete` | Delete a contact by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                           |
| [`getContact`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/contacts.ts)     | read  | Bearer | `contacts get`    | One contact with its address and custom fields (`fieldValuesByShortname`), or null; a public token sees none.                                   |
| [`getDeal`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/contacts.ts)        | read  | Bearer | `deals get`       | One deal with its pipeline, status and owner (`user`), or null; `amount` is in cents.                                                           |
| [`listContacts`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/contacts.ts)   | read  | Bearer | `contacts list`   | Every contact the client may see, as an array: the field is not a connection, so there is no pagination.                                        |
| [`listDeals`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/contacts.ts)      | read  | Bearer | `deals list`      | The workspace's deals as a flat array, optionally filtered with search `params`; page with `first`/`after`.                                     |
| [`updateDeal`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)    | write | Bearer | `deals update`    | Update a deal, e.g. move it to another `statusId`: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                |

**Types:** `Contact`, `Deal`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListDealsDocument`

## Campaigns

Marketing and email campaigns.

Guide: [Campaigns](https://developers.uidu.org/docs/domains/campaigns.md).

| Function                                                                                              | Kind | Auth   | CLI              | Description                                                                                                                                    |
| ----------------------------------------------------------------------------------------------------- | ---- | ------ | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [`getCampaign`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/campaigns.ts)        | read | Bearer | `campaigns get`  | One campaign with its `preferences` and target `list`, or null; a public token sees none.                                                      |
| [`listCampaigns`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/campaigns.ts)      | read | Bearer | `campaigns list` | The workspace's campaigns as a flat array, optionally filtered by `kind` and `status`; page with `first`/`after`.                              |
| [`listEmailCampaigns`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/campaigns.ts) | read | Bearer | —                | The email blasts of the workspace's campaigns with their delivery metrics (sent, opened, clicked), as a flat array; page with `first`/`after`. |

**Types:** `Campaign`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListCampaignsDocument`, `ListEmailCampaignsDocument`

## People (HR)

Employees, employments (contracts), compensations, time clocks, benefits and HR reference data.

Guide: [People (HR)](https://developers.uidu.org/docs/domains/people.md).

| Function                                                                                                             | Kind   | Auth   | CLI                          | Description                                                                                                                                                                                                                                                                                                                                                                                                             |
| -------------------------------------------------------------------------------------------------------------------- | ------ | ------ | ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`contractEvents`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                       | helper | —      | —                            | Flatten employment history into dated contract events, most recent first: - the employee's earliest contract is a `hire` (assunzione) on its start date; - every later contract is a `variation` (variazione) on its start date; - any contract with an end date yields a `termination` (cessazione) on it.                                                                                                             |
| [`createBenefit`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/benefits.ts)                      | write  | Bearer | `benefits create`            | Create a benefit in the workspace's catalog (name, category, provider, employer/employee costs). Returns the payload (with `errors`) or null; it is at `benefit.node`.                                                                                                                                                                                                                                                  |
| [`createBenefitEnrollment`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/benefit-enrollments.ts) | write  | Bearer | `benefit-enrollments create` | Enroll an employment in a benefit (`benefitId`, `employmentId`, `enrolledAt`). Returns the payload (with `errors`) or null; it is at `benefitEnrollment.node`.                                                                                                                                                                                                                                                          |
| [`createCcnl`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                           | write  | Bearer | `ccnls create`               | Create a CCNL (national collective labor contract) — the first-class `Ccnl` record (code, sector, contract levels), distinct from the `Kind`-tagged rows `listCcnls` returns above. `Employment.ccnl` / `ccnlId` point at this first-class type. Requires a Bearer token (`apiKey`).                                                                                                                                    |
| [`createCompensation`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                | write  | Bearer | `compensations create`       | Add a pay item to an employment (`attributes.employmentId`, `amount`, `currency`, `frequency`, `effectiveFrom`). Returns the payload (with `errors`) or null. The new item is at `compensation.node`.                                                                                                                                                                                                                   |
| [`createEmployee`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                    | write  | Bearer | `employees create`           | Create the HR record for a workspace user (`attributes.userId`). Returns the payload (with `errors`) or null. The new employee is at `employee.node`.                                                                                                                                                                                                                                                                   |
| [`createEmployment`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                  | write  | Bearer | `employments create`         | Hire: open a new employment (contract) for `attributes.employeeId` with its start date, kind, role and hours. Returns the payload (with `errors`) or null. The new employment is at `employment.node`.                                                                                                                                                                                                                  |
| [`createTimeClock`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                   | write  | Bearer | `time-clocks create`         | Record a time-clock punch (`beginsAt`, optional `finishesAt`, `resourceId`). Returns the payload (with `errors`) or null. The new punch is at `timeClock.node`.                                                                                                                                                                                                                                                         |
| [`deleteCompensation`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                | write  | Bearer | `compensations delete`       | Delete a pay item by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                                                                                                                                                  |
| [`deleteEmployment`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                  | write  | Bearer | `employments delete`         | Delete an employment by `{ input: { id } }` (to end a contract, use `terminateEmployment` instead). Returns the payload (with `errors`) or null.                                                                                                                                                                                                                                                                        |
| [`getEmployee`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                          | read   | Bearer | —                            | One employee with current employment, today's time clocks and the shifts of the week starting `weekStartingAt` (see `weekStartFor`), or null.                                                                                                                                                                                                                                                                           |
| [`listCcnls`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                            | read   | Bearer | `ccnls list`                 | List the CCNLs (national collective labor contracts) configured for the workspace — used for an employment's `ccnlId`.                                                                                                                                                                                                                                                                                                  |
| [`listCircles`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                          | read   | Bearer | —                            | List the workspace circles. Circles come in two flavours distinguished by `kind`: org units (e.g. departments — used as an employment's `circleId`) and roles (`kind === 'role'` — used as an employment's `roleId`). Use `listRoles` when you only want the role-Circles.                                                                                                                                              |
| [`listEmployees`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                        | read   | Bearer | `employees list`             | The workspace's employees with their current employment, as a flat array; page with `first`/`after`.                                                                                                                                                                                                                                                                                                                    |
| [`listEmploymentHistory`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                | read   | Bearer | —                            | List every employee with their full employment (contract) history — not just the current one. Use `contractEvents` to turn this into a flat, dated list of hires, terminations and contract variations.                                                                                                                                                                                                                 |
| [`listKinds`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                            | read   | Bearer | —                            | List `Kind` records for the given polymorphic models.                                                                                                                                                                                                                                                                                                                                                                   |
| [`listOffices`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                          | read   | Bearer | `offices list`               | List the workspace offices — used for an employment's `employmentOfficesAttributes`.                                                                                                                                                                                                                                                                                                                                    |
| [`listRoles`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                            | read   | Bearer | `roles list`                 | List only the role-Circles (structured job titles) — an employment's `roleId`.                                                                                                                                                                                                                                                                                                                                          |
| [`terminateEmployment`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)               | write  | Bearer | —                            | Terminate (cessazione) an employment by closing it with an end date and reason. Thin semantic wrapper over `updateEmployment`. `endReason` is one of: resignation, termination, contract\_end, retirement, other, resignation\_just\_cause, dismissal\_just\_cause, dismissal\_subjective\_reason, dismissal\_objective\_reason, collective\_dismissal, mutual\_agreement, probation\_failed, death, business\_closure. |
| [`updateCompensation`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                | write  | Bearer | `compensations update`       | Update a pay item: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                                                                                                                                        |
| [`updateEmployee`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                    | write  | Bearer | `employees update`           | Update an employee's HR record (code, kiosk PIN, time-clock flags): `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                                                                                       |
| [`updateEmployment`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)                  | write  | Bearer | `employments update`         | Update an employment: `{ input: { id, attributes } }`; to end one, prefer `terminateEmployment`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                                                                                           |
| [`weekStartFor`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/people.ts)                         | helper | —      | —                            | Compute the Monday of the week containing `date` as an ISO8601 date string. Useful for the `weekStartingAt` argument required by `getEmployee` (and any other weekly-aggregated employee fields).                                                                                                                                                                                                                       |

**Types:** `Circle`, `CompensationRecord`, `ContractEvent`, `ContractEventType`, `Employee`, `EmployeeContracts`, `EmploymentRecord`, `Kind`, `Office`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListEmployeesDocument`

## Goals (OKRs)

Objectives, key results and timeframes, plus value/progress helpers.

Guide: [Goals (OKRs)](https://developers.uidu.org/docs/domains/goals.md).

| Function                                                                                       | Kind   | Auth   | CLI               | Description                                                                                                                                                                                                                                                                                              |
| ---------------------------------------------------------------------------------------------- | ------ | ------ | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`getGoal`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)         | read   | Bearer | `goals get`       | One goal with its key results (`subgoals`).                                                                                                                                                                                                                                                              |
| [`goalProgress`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)    | helper | —      | —                 | How far the goal is, 0 to 1 (above 1 when it overshoots). `goal.progress` itself is percent x100: 10000 is done.                                                                                                                                                                                         |
| [`goalTimeElapsed`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts) | helper | —      | —                 | How much of the goal's timeframe has passed, 0 to 1, or `null` when it has none. A goal whose `goalProgress` is below this is behind schedule.                                                                                                                                                           |
| [`goalValue`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)       | helper | —      | —                 | A stored goal value (`initialValue`, `currentValue`, `targetValue`) in the unit a person typed: uidu keeps every one of them x100. For `percentage` that is percent points (45 = 45%), for `currency` whole units of `goal.currency`, for `checkbox` 1 or 0. `null` stays `null`.                        |
| [`isGoalBehind`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)    | helper | —      | —                 | Behind schedule: less done than time elapsed, by more than `tolerance` (0.1 = ten points). `false` for a goal with no timeframe or one already accomplished. The goal's own `status` (`off_track`, `needs_attention`) is its owner's judgement — show it next to this, don't replace one with the other. |
| [`listGoals`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)       | read   | Bearer | `goals list`      | Every goal of the workspace (objectives and key results alike), newest first. Without `first`, all of them.                                                                                                                                                                                              |
| [`listTimeframes`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)  | read   | Bearer | `timeframes list` | The workspace's timeframes (the periods goals run over, `active` marks the current ones) as a flat array; page with `first`/`after`.                                                                                                                                                                     |
| [`toGoalRaw`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)       | helper | —      | —                 | The inverse of `goalValue`, for `updateGoal`.                                                                                                                                                                                                                                                            |
| [`updateGoal`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/goals.ts)      | write  | Bearer | `goals update`    | Authoring (Bearer / apiKey). Returns the payload, incl. `errors`. `initialValue` / `currentValue` / `targetValue` are stored x100: pass `toGoalRaw(value)`, never the number a person typed.                                                                                                             |

**Types:** `Goal`, `Timeframe`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListGoalsDocument`, `ListTimeframesDocument`

## Spaces, tasks & notes

Collaboration primitives: spaces, tasks, notes.

Guide: [Spaces, tasks & notes](https://developers.uidu.org/docs/domains/workspace.md).

| Function                                                                                       | Kind  | Auth   | CLI             | Description                                                                                                                 |
| ---------------------------------------------------------------------------------------------- | ----- | ------ | --------------- | --------------------------------------------------------------------------------------------------------------------------- |
| [`createNote`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/notes.ts)      | write | Bearer | `notes create`  | Create a note. Returns the payload (with `errors`) or null; the new note is at `note.node`.                                 |
| [`createSpace`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/spaces.ts)    | write | Bearer | `spaces create` | Create a space, the container tasks live in. Returns the payload (with `errors`) or null; the new space is at `space.node`. |
| [`createTask`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/tasks.ts)      | write | Bearer | `tasks create`  | Create a task, usually in a space (`attributes.spaceId`). Returns the payload (with `errors`) or null.                      |
| [`deleteNote`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer | `notes delete`  | Delete a note by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                          |
| [`deleteSpace`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer | `spaces delete` | Delete a space by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                         |
| [`deleteTask`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer | `tasks delete`  | Delete a task by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                          |
| [`updateNote`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer | `notes update`  | Update a note: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                |
| [`updateSpace`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts) | write | Bearer | `spaces update` | Update a space: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                               |
| [`updateTask`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/mutations.ts)  | write | Bearer | `tasks update`  | Update a task, e.g. its `statusId` or dates: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.  |

## Bookings & calendars

Bookings, calendars and calendar events.

Guide: [Bookings & calendars](https://developers.uidu.org/docs/domains/bookings.md).

| Function                                                                                             | Kind | Auth         | CLI             | Description                                                                                                                            |
| ---------------------------------------------------------------------------------------------------- | ---- | ------------ | --------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| [`getBooking`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/bookings.ts)         | read | Bearer       | `bookings get`  | One booking with its contact, totals in cents and custom fields (`fieldValuesByShortname`), or null; a public token sees none.         |
| [`getCalendar`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/bookings.ts)        | read | public token | —               | One calendar (name, color, time zone), or null.                                                                                        |
| [`getCalendarEvent`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/bookings.ts)   | read | public token | —               | One calendar event with its rich-text `body` and its calendar, or null.                                                                |
| [`listBookings`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/bookings.ts)       | read | Bearer       | `bookings list` | The workspace's bookings as a flat array; page with `first`/`after` (or `last`/`before`); a public token gets an empty list.           |
| [`listCalendarEvents`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/bookings.ts) | read | public token | —               | Calendar events as a flat array, optionally narrowed by `calendarIds` and named `scopes` (e.g. `upcoming`); page with `first`/`after`. |
| [`listCalendars`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/bookings.ts)      | read | public token | —               | The workspace's calendars as a flat array; page with `first`/`after` (or `last`/`before`).                                             |

**Types:** `Booking`, `Calendar`, `CalendarEvent`

**Documents** (for [`paginate`](https://developers.uidu.org/docs/recipes/paginate.md)): `ListBookingsDocument`, `ListCalendarEventsDocument`, `ListCalendarsDocument`

## Models (custom data)

Define your own record types (Models, Fields) and store ModelItems.

Guide: [Models (custom data)](https://developers.uidu.org/docs/domains/models.md).

| Function                                                                                                | Kind   | Auth   | CLI | Description                                                                                                                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------------- | ------ | ------ | --- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createField`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)             | write  | Bearer | —   | Pass `fieldableId` (the model) with `fieldableType: 'Model'`: a custom app may only name a type that matches the record it loads.                                                                                                                                                                        |
| [`createFieldOption`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)       | write  | Bearer | —   | Add an option to a select-kind field (`attributes.fieldId`, `name`, `color`). Returns the payload (with `errors`) or null.                                                                                                                                                                               |
| [`createModel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)             | write  | Bearer | —   | Create a model in a WorkspaceApp (`attributes.modelableId`, `name`, `namePlural`). Returns the payload (with `errors`) or null.                                                                                                                                                                          |
| [`createModelItem`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)         | write  | Bearer | —   | Pass `attributes.modelId` and `attributes.fieldValuesAttributes` — build the latter by shortname with `toFieldValuesAttributes`.                                                                                                                                                                         |
| [`deleteField`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)             | write  | Bearer | —   | Delete a field from its model by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                       |
| [`deleteFieldOption`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)       | write  | Bearer | —   | Delete a select option by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                              |
| [`deleteFieldValue`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)        | write  | Bearer | —   | Clear a single value by its FieldValue id; `deleteLinkedRecord: true` also deletes the record it links to. Returns the payload (with `errors`) or null.                                                                                                                                                  |
| [`deleteModelItem`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)         | write  | Bearer | —   | Delete an item by `{ input: { id } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                                      |
| [`ensureModel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)             | write  | Bearer | —   | Find the app's model by name, or create it — and any of `fields` it lacks. Returns the model with all its fields. What a custom app runs on its first load until schemas come from an install-time manifest (custom apps spec, step 3). Throws a `UiduError` (`MUTATION_ERROR`) when a write is refused. |
| [`getModel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)                | read   | Bearer | —   | One model with its fields, or null when the id is not a Model.                                                                                                                                                                                                                                           |
| [`getModelItem`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)            | read   | Bearer | —   | One model item with its values and its `model.id`, or null when the id is not a ModelItem.                                                                                                                                                                                                               |
| [`listModelItems`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)          | read   | Bearer | —   | A model's items. Each carries `fieldValuesByShortname` — `{ room: 'Aula Magna', when: '…' }` — the easiest shape to read values from.                                                                                                                                                                    |
| [`listModels`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)              | read   | Bearer | —   | The models of a WorkspaceApp, with their fields.                                                                                                                                                                                                                                                         |
| [`toFieldValuesAttributes`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts) | helper | —      | —   | `{ room: 'Aula Magna' }` → `[{ fieldId: '<id of room>', content: { value: 'Aula Magna' } }]`, for `createModelItem` / `updateModelItem`. Throws on a shortname the model doesn't have; skips `undefined` values.                                                                                         |
| [`updateField`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)             | write  | Bearer | —   | Update a field (name, `required`, preferences…): `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                           |
| [`updateFieldOption`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)       | write  | Bearer | —   | Update a select option: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                                    |
| [`updateFieldValue`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)        | write  | Bearer | —   | Set a single value by its FieldValue id: `{ input: { id, attributes: { content: { value } } } }`. Returns the payload (with `errors`) or null.                                                                                                                                                           |
| [`updateModel`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)             | write  | Bearer | —   | Rename or reconfigure a model: `{ input: { id, attributes } }`. Returns the payload (with `errors`) or null.                                                                                                                                                                                             |
| [`updateModelItem`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/models.ts)         | write  | Bearer | —   | Update an item: `{ input: { id, attributes: { fieldValuesAttributes } } }`, built with `toFieldValuesAttributes`. Returns the payload (with `errors`) or null.                                                                                                                                           |

**Types:** `EnsureModelOptions`, `Model`, `ModelField`, `ModelFieldOption`, `ModelItem`

## Provisioning & actions

Create workspaces, rotate API credentials, and run any tool-flagged ActionKey.

Guide: [Provisioning & actions](https://developers.uidu.org/docs/foundations/writes.md).

| Function                                                                                                        | Kind  | Auth   | CLI                     | Description                                                                                                                                                 |
| --------------------------------------------------------------------------------------------------------------- | ----- | ------ | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`createWorkspace`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/system.ts)                 | write | Bearer | `workspace create`      | Create a workspace owned by the authenticated account (`attributes.name`, `subdomain`…). Returns the payload (with `errors`) or null.                       |
| [`executeAction`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/actions.ts)                  | write | Bearer | `tools call`            | Run any backend action by `key` (an `ActionKey` flagged `of_kind_tool_key`), with optional `id` and `attributes`; returns `{ result, errors }` or null.     |
| [`generateWorkspaceApiCredentials`](https://github.com/uidu-org/api.js/blob/main/packages/client/src/system.ts) | write | Bearer | `workspace credentials` | Rotate + return a workspace's API credentials (apiKey/apiSecret). Operates on the current workspace. Use the returned credentials to wire a scaffolded app. |
