# Declare a metadata key on one kind of object, or replace its declaration

`PUT /metadata-fields/{object}/{key}` · Rivier · keys

Declare a metadata key on one kind of object, or replace its declaration: a kind (text, number, integer, boolean, date, datetime, enum, url), whether it is required, bounds, a pattern or options. Every write of metadata by the project's keys is then checked against it, inside the businesses a platform works in too; undeclared keys stay free and values stay text. Values already kept are checked again only when written.

- Scope: keys:admin
- Graphql: Mutation.keysMetadataFieldDeclare
- Sdk: keys.metadataField.declare
- Cli: keys metadata field declare

## Parameters

- `object` (path, required), string
- `key` (path, required), string

## Request body

`application/json`

```json
{
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "text",
        "number",
        "integer",
        "boolean",
        "date",
        "datetime",
        "enum",
        "url"
      ]
    },
    "description": {
      "type": "string",
      "maxLength": 300
    },
    "required": {
      "type": "boolean",
      "default": false
    },
    "min": {
      "type": "number"
    },
    "max": {
      "type": "number"
    },
    "pattern": {
      "type": "string",
      "maxLength": 200
    },
    "options": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100
      },
      "minItems": 1,
      "maxItems": 100
    }
  },
  "required": [
    "kind"
  ],
  "additionalProperties": false
}
```

## Responses

- `200`: 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 PUT 'https://api.rivier.ai/metadata-fields/{object}/{key}' \
  -H 'Authorization: Bearer $KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "kind": "text"
}'
```
