> For the complete documentation index, see [llms.txt](https://codemash.gitbook.io/codemash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codemash.gitbook.io/codemash/cloud/database/schema/field-types/uri.md).

# URI

A string field with format uri: the server accepts only a valid URI; the form shows it with the website widget.

A **URI** field is a [Text](/codemash/cloud/database/schema/field-types/text.md) field with `format: "uri"` — a link, a web address. In the UI schema its widget is called `website`.

**Builder:** Form fields panel → **URI** · widget `website` · data type `string.schema.v1`

## Data schema

```json
{
  "website": {
    "type": "string",
    "format": "uri",
    "maxLength": 2048
  }
}
```

| Keyword                                                  | Required          | What it does                                                       | Example    |
| -------------------------------------------------------- | ----------------- | ------------------------------------------------------------------ | ---------- |
| `type`                                                   | yes               | Always `"string"`.                                                 | `"string"` |
| `format`                                                 | yes for this type | `"uri"`.                                                           | `"uri"`    |
| `minLength`, `maxLength`, `pattern`, `default`, `unique` | no                | As on [Text](/codemash/cloud/database/schema/field-types/text.md). | `2048`     |

### What the server refuses

Every write — insert, update, replace; from Cloud, the API, an SDK, the CLI or an AI agent — is checked against the published schema. A broken value is answered with one error per field: the code, and `Field '<name>' is invalid: <reason>`. Nothing is written.

| Case                                  | Code                     | The reason it gives   |
| ------------------------------------- | ------------------------ | --------------------- |
| a required field is missing or `null` | `CM-ERRORS-DATABASE-030` | `a value is required` |
| the value is not a string             | `CM-ERRORS-DATABASE-039` | `must be a string`    |
| not a URI (no scheme, spaces, …)      | `CM-ERRORS-DATABASE-042` | `must be a valid uri` |

A keyword that is not in the table above is refused when the schema is **saved**, not when a record is written: `CM-ERRORS-SCHEMA-010` — `Data schema violates meta-schema: Property 'sort' has not been defined and the schema does not allow additional properties. Path 'properties.website.sort' (field 'properties.website' checked as string.schema.v1).`

Also refused at save time:

* a cell with `"widget": "uri"` — the widget is `website`: `CM-ERRORS-SCHEMA-012` `Visual schema violates meta-schema: Value "uri" is not defined in enum. Path 'tabs[0].containers[0].cells[0].element.meta.widget' …`.

## UI schema

The cell uses the `website` widget (a link icon in the input).

```json
{
  "colSpan": 4,
  "element": {
    "fieldId": "website",
    "meta": { "widget": "website", "label": "Website", "placeholder": "https://" }
  }
}
```

Every cell also takes the common layout options: `label`, `placeholder`, `help` (the text under the input), `required`, `readonly` and `hidden`. Keys outside this list — `watermark`, `hint`, `permissions` — are refused when the schema is saved (`CM-ERRORS-SCHEMA-012`), see [Schema authoring guide](/codemash/cloud/database/schema.md#one-contract-no-second-dialect).

<figure><img src="https://712692422-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHy372bqsaex2cqS3ikhL%2Fuploads%2Fgit-blob-ebf915cf71f4945a3c0d5bf9ef1529c892da44f4%2Ffield-types-text-1.png?alt=media" alt="The Text tab of the all-types record form with the field String format uri shown as a plain input next to String pattern"><figcaption><p>A website cell (String format uri) on the Text tab.</p></figcaption></figure>

## Records

A record the schema accepts:

```json
{ "website": "https://norbix.ai/docs" }
```

A record it refuses:

```json
{ "website": "not a url" }
```

The answer: `CM-ERRORS-DATABASE-042` — `Field 'website' is invalid: must be a valid uri`. In Cloud the same sentence is shown under the field before the form is sent; the server repeats the check on every API write.

## Good to know

* Any scheme passes (`https:`, `mailto:`, `ftp:`); the server does not open the link.

## Do it from code

```ts
await norbix.api.database.insertOne({
  collectionName: 'authors',
  document: JSON.stringify({ website: 'https://norbix.ai/docs' }),
});
```

```sh
norbix api database one insert --collectionName authors --document '{"website":"https://norbix.ai/docs"}'
```

The client setup is on the [Database page](/codemash/cloud/database.md#use-it-from-code). API: [Insert One](/codemash/api-reference/database/collections/insert-one.md) · [Save Database Schema](/codemash/api-reference/database/schemas/save-database-schema.md)

## Related

[Text](/codemash/cloud/database/schema/field-types/text.md) · [Email](/codemash/cloud/database/schema/field-types/email.md) · [Field type reference](/codemash/cloud/database/schema/field-types.md) · [Schema authoring guide](/codemash/cloud/database/schema.md) · [Create a schema](/codemash/cloud/database/collections/create-schema.md)
