---
title: "Create 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.

# Create a data-object definition

Path: CloudRaker Workspace API › Data Objects

`POST /objects/definitions`

Creates a new organization-level definition. Authorization: organization administrators only — other callers get 403. Body describes the schema: `nameSingular`/`namePlural`, labels, `fields[]` (13 field types, plus composites), `fieldGroups[]`, `labelFieldKey`, `icon`/`color`. Invalid schema returns 422 `validation_failed` (with `issues`). Returns 201 with `{ definition }`.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Request body

_Required._

- `nameSingular` (`createObjectDefinition.nameSingular`; string, required)
  - minLength 1; maxLength 64; example `"contract"`
- `labelSingular` (`createObjectDefinition.labelSingular`; string, required)
  - minLength 1; maxLength 200
- `labelPlural` (`createObjectDefinition.labelPlural`; string, required)
  - minLength 1; maxLength 200
- `namePlural` (`createObjectDefinition.namePlural`; string, required)
  - minLength 1; maxLength 64
- `icon` (`createObjectDefinition.icon`; string, required)
  - minLength 1; maxLength 64
- `labelFieldKey` (`createObjectDefinition.labelFieldKey`; string, required)
  - minLength 1
- `fields` (`createObjectDefinition.fields`; array<map<unknown>>, required) — Field descriptors. Each names a `key`, a `type` and its type-specific options.
- `description` (`createObjectDefinition.description`; string, optional) — Free-form description of the definition. Omitted means empty.
  - maxLength 2000
- `color` (`createObjectDefinition.color`; string, optional, nullable)
- `fieldGroups` (`createObjectDefinition.fieldGroups`; array<map<unknown>>, optional)

## Example request

```json
{
  "nameSingular": "contract",
  "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 POST \
  --url https://api.cloudraker.com/objects/definitions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "nameSingular": "contract",
  "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';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    nameSingular: 'contract',
    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"

payload = {
    "nameSingular": "contract",
    "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.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 201

The created 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` (`createObjectDefinition.response.201.definition`; object, required)
  - `_id` (`createObjectDefinition.response.201.definition._id`; string, required)
    - example `"def_contract"`
  - `nameSingular` (`createObjectDefinition.response.201.definition.nameSingular`; string, required)
    - example `"contract"`
  - `namePlural` (`createObjectDefinition.response.201.definition.namePlural`; string, required)
    - example `"contracts"`
  - `labelSingular` (`createObjectDefinition.response.201.definition.labelSingular`; string, required)
    - example `"Contract"`
  - `labelPlural` (`createObjectDefinition.response.201.definition.labelPlural`; string, required)
    - example `"Contracts"`
  - `description` (`createObjectDefinition.response.201.definition.description`; string, required)
  - `icon` (`createObjectDefinition.response.201.definition.icon`; string, required)
  - `color` (`createObjectDefinition.response.201.definition.color`; string | null, required)
  - `labelFieldKey` (`createObjectDefinition.response.201.definition.labelFieldKey`; string, required) — Field key whose value is the object’s display label.
  - `fields` (`createObjectDefinition.response.201.definition.fields`; array<map<unknown>>, required) — The type-discriminated field model (13 field types plus composites). Emitted permissively so the resource stays navigable.
  - `fieldGroups` (`createObjectDefinition.response.201.definition.fieldGroups`; array<map<unknown>>, required)
  - `version` (`createObjectDefinition.response.201.definition.version`; number, required) — Bumps only on a schema-affecting change.
  - `archivedAt` (`createObjectDefinition.response.201.definition.archivedAt`; any of, required)
    - any of: `string`, `null`
  - `createdAt` (`createObjectDefinition.response.201.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` (`createObjectDefinition.response.201.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` (`createObjectDefinition.response.201.definition.createdBy`; string, required)

### 403

Caller is not an org admin.

### 422

`validation_failed` — the definition body is invalid (see `issues`).


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