# Declare one of the platform's own types, or its next version

`POST /data/types` · Rivier · content

Declare one of the platform's own types, or its next version: typed fields (the content model's), an optional unique field, which of business and customer every row carries, who besides the platform may read or write (a business's owner reads; a customer reads or writes their own), whose a business's rows are when its connection ends, and what forgetting a customer does to theirs. A change that would refuse rows already kept is refused with what breaks; the same declaration again changes nothing.

- Scope: content:admin
- Graphql: Mutation.contentDataTypeDeclare
- Sdk: content.dataType.declare
- Cli: content data type declare

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "key": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9_]{0,39}$"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "description": {
      "type": "string",
      "maxLength": 600
    },
    "fields": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "text",
              "richtext",
              "number",
              "boolean",
              "date",
              "enum",
              "slug",
              "url",
              "json",
              "asset",
              "gallery",
              "reference",
              "list",
              "object"
            ]
          },
          "label": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": "string",
            "maxLength": 600
          },
          "required": {
            "type": "boolean"
          },
          "translatable": {
            "type": "boolean"
          },
          "min": {
            "type": "number"
          },
          "max": {
            "type": "number"
          },
          "pattern": {
            "type": "string",
            "maxLength": 300
          },
          "multiline": {
            "type": "boolean"
          },
          "integer": {
            "type": "boolean"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            },
            "minItems": 1,
            "maxItems": 200
          },
          "dateTime": {
            "type": "boolean"
          },
          "assetKinds": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 40
            },
            "maxItems": 20
          },
          "to": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,39}$"
            },
            "maxItems": 20
          },
          "many": {
            "type": "boolean"
          },
          "of": {},
          "fields": {
            "type": "object",
            "additionalProperties": {},
            "propertyNames": {
              "pattern": "^[a-z][A-Za-z0-9_]{0,39}$"
            }
          },
          "default": {},
          "instruction": {
            "type": "string",
            "maxLength": 600
          }
        },
        "required": [
          "type"
        ],
        "additionalProperties": false
      },
      "propertyNames": {
        "pattern": "^[a-z][A-Za-z0-9_]{0,39}$"
      }
    },
    "titleField": {
      "type": "string",
      "pattern": "^[a-z][A-Za-z0-9_]{0,39}$"
    },
    "unique": {
      "type": "string",
      "pattern": "^[a-z][A-Za-z0-9_]{0,39}$"
    },
    "scope": {
      "type": "string",
      "enum": [
        "project",
        "business",
        "customer",
        "business_customer"
      ],
      "default": "project"
    },
    "access": {
      "type": "object",
      "properties": {
        "business": {
          "type": "string",
          "enum": [
            "none",
            "read"
          ],
          "default": "none"
        },
        "customer": {
          "type": "string",
          "enum": [
            "none",
            "read",
            "write"
          ],
          "default": "none"
        }
      },
      "additionalProperties": false,
      "default": {}
    },
    "keep": {
      "type": "string",
      "enum": [
        "platform",
        "business"
      ],
      "default": "platform"
    },
    "erase": {
      "type": "string",
      "enum": [
        "remove",
        "detach"
      ],
      "default": "remove"
    }
  },
  "required": [
    "key",
    "name",
    "fields"
  ],
  "additionalProperties": false
}
```

## Responses

- `201`: Success
- `400`: The request was malformed
- `401`: No valid credential
- `403`: The credential lacks the scope, origin or address
- `429`: Over the key's rate limit; see Retry-After

## Example

```sh
curl -X POST 'https://api.rivier.ai/data/types' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "key": "string",
  "name": "string",
  "fields": {}
}'
```
