---
title: "Update a data-object definition"
---

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

# Update a data-object definition

Path: CloudRaker Workspace API › Data Objects

`PATCH /objects/definitions/{definitionId}`

Applies a field-by-key diff to a definition. Authorization: organization administrators only — other callers get 403. Body is strict (immutable `name`/field keys rejected). Fields present are upserted; **omitting an active field soft-archives it** (archive-on-omit). Changing a field type while live objects exist returns 409 `type_change_blocked` (with `fieldKey`); the `version` bumps only on a schema-affecting change. Unknown id → 404, invalid body → 422 `validation_failed`. Returns `{ definition }`.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `definitionId` (`updateObjectDefinition.path.definitionId`; string, required)

## Request body

_Required._

- `labelSingular` (`updateObjectDefinition.labelSingular`; string, optional)
  - minLength 1; maxLength 200
- `labelPlural` (`updateObjectDefinition.labelPlural`; string, optional)
  - minLength 1; maxLength 200
- `namePlural` (`updateObjectDefinition.namePlural`; string, optional)
  - minLength 1; maxLength 64
- `description` (`updateObjectDefinition.description`; string, optional)
  - maxLength 2000
- `icon` (`updateObjectDefinition.icon`; string, optional)
  - minLength 1; maxLength 64
- `color` (`updateObjectDefinition.color`; string, optional, nullable)
- `labelFieldKey` (`updateObjectDefinition.labelFieldKey`; string, optional)
  - minLength 1
- `fields` (`updateObjectDefinition.fields`; array<map<unknown>>, optional) — Field descriptors. Each names a `key`, a `type` and its type-specific options.
- `fieldGroups` (`updateObjectDefinition.fieldGroups`; array<map<unknown>>, optional)

## Example request

```json
{
  "labelSingular": "string",
  "labelPlural": "string",
  "namePlural": "string",
  "description": "string",
  "icon": "string",
  "color": "string",
  "labelFieldKey": "string",
  "fields": [
    {
      "property1": null,
      "property2": null
    }
  ],
  "fieldGroups": [
    {
      "property1": null,
      "property2": null
    }
  ]
}
```

## Code samples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.cloudraker.com/objects/definitions/<definitionId>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "labelSingular": "string",
  "labelPlural": "string",
  "namePlural": "string",
  "description": "string",
  "icon": "string",
  "color": "string",
  "labelFieldKey": "string",
  "fields": [
    {
      "property1": null,
      "property2": null
    }
  ],
  "fieldGroups": [
    {
      "property1": null,
      "property2": null
    }
  ]
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/objects/definitions/<definitionId>';
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    labelSingular: 'string',
    labelPlural: 'string',
    namePlural: 'string',
    description: 'string',
    icon: 'string',
    color: 'string',
    labelFieldKey: 'string',
    fields: [{property1: null, property2: null}],
    fieldGroups: [{property1: null, property2: null}]
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/objects/definitions/<definitionId>"

payload = {
    "labelSingular": "string",
    "labelPlural": "string",
    "namePlural": "string",
    "description": "string",
    "icon": "string",
    "color": "string",
    "labelFieldKey": "string",
    "fields": [
        {
            "property1": None,
            "property2": None
        }
    ],
    "fieldGroups": [
        {
            "property1": None,
            "property2": None
        }
    ]
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The updated definition.

#### Example

```json
{
  "definition": {
    "_id": "def_contract",
    "nameSingular": "contract",
    "namePlural": "contracts",
    "labelSingular": "Contract",
    "labelPlural": "Contracts",
    "description": "string",
    "icon": "string",
    "color": "string",
    "labelFieldKey": "string",
    "fields": [
      {
        "property1": null,
        "property2": null
      }
    ],
    "fieldGroups": [
      {
        "property1": null,
        "property2": null
      }
    ],
    "version": 0,
    "archivedAt": "2019-08-24T14:15:22Z",
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
    "createdBy": "string"
  }
}
```

- `definition` (`updateObjectDefinition.response.200.definition`; object, required)
  - `_id` (`updateObjectDefinition.response.200.definition._id`; string, required)
    - example `"def_contract"`
  - `nameSingular` (`updateObjectDefinition.response.200.definition.nameSingular`; string, required)
    - example `"contract"`
  - `namePlural` (`updateObjectDefinition.response.200.definition.namePlural`; string, required)
    - example `"contracts"`
  - `labelSingular` (`updateObjectDefinition.response.200.definition.labelSingular`; string, required)
    - example `"Contract"`
  - `labelPlural` (`updateObjectDefinition.response.200.definition.labelPlural`; string, required)
    - example `"Contracts"`
  - `description` (`updateObjectDefinition.response.200.definition.description`; string, required)
  - `icon` (`updateObjectDefinition.response.200.definition.icon`; string, required)
  - `color` (`updateObjectDefinition.response.200.definition.color`; string | null, required)
  - `labelFieldKey` (`updateObjectDefinition.response.200.definition.labelFieldKey`; string, required) — Field key whose value is the object’s display label.
  - `fields` (`updateObjectDefinition.response.200.definition.fields`; array<map<unknown>>, required) — The type-discriminated field model (13 field types plus composites). Emitted permissively so the resource stays navigable.
  - `fieldGroups` (`updateObjectDefinition.response.200.definition.fieldGroups`; array<map<unknown>>, required)
  - `version` (`updateObjectDefinition.response.200.definition.version`; number, required) — Bumps only on a schema-affecting change.
  - `archivedAt` (`updateObjectDefinition.response.200.definition.archivedAt`; any of, required)
    - any of: `string`, `null`
  - `createdAt` (`updateObjectDefinition.response.200.definition.createdAt`; string, required)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `updatedAt` (`updateObjectDefinition.response.200.definition.updatedAt`; string, required)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `createdBy` (`updateObjectDefinition.response.200.definition.createdBy`; string, required)

### 403

Caller is not an org admin.

### 404

No definition with that id.

### 409

`type_change_blocked` — a field type change is blocked by live objects.

### 422

`validation_failed` — the patch body is invalid.


Source: https://docs.cloudraker.com/workspace/api/data-objects/update-object-definition/index.md
