# Request a schema change

## `POST /v1/schema/changes`

Submit schema operations. Changes that need review are proposed for a workspace administrator. Requires the `schema:write` scope.

```json
{
  "tags": [
    "Schema"
  ],
  "operationId": "request-schema-change",
  "summary": "Request a schema change",
  "description": "Submit schema operations. Changes that need review are proposed for a workspace administrator. Requires the `schema:write` scope.",
  "x-retainer-scope": "schema:write",
  "parameters": [],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "operations": {
              "minItems": 1,
              "maxItems": 100,
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "create_object"
                      },
                      "object": {
                        "type": "object",
                        "properties": {
                          "universalId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "class": {
                            "type": "string",
                            "enum": [
                              "entity",
                              "event"
                            ]
                          },
                          "nameSingular": {
                            "type": "string",
                            "minLength": 1
                          },
                          "namePlural": {
                            "type": "string",
                            "minLength": 1
                          },
                          "labelSingular": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "labelPlural": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "description": {
                            "type": "string",
                            "maxLength": 2000
                          },
                          "labelField": {
                            "type": "string",
                            "minLength": 1
                          },
                          "fields": {
                            "default": [],
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "universalId": {
                                  "type": "string",
                                  "format": "uuid",
                                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                                },
                                "name": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "label": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 200
                                },
                                "description": {
                                  "type": "string",
                                  "maxLength": 2000
                                },
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "text",
                                    "number",
                                    "boolean",
                                    "date",
                                    "date_time",
                                    "select",
                                    "multi_select",
                                    "money",
                                    "emails",
                                    "phones",
                                    "links",
                                    "full_name",
                                    "address",
                                    "relation",
                                    "json",
                                    "files"
                                  ]
                                },
                                "settings": {
                                  "type": "object",
                                  "properties": {
                                    "options": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "value": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 100
                                          },
                                          "label": {
                                            "type": "string",
                                            "minLength": 1,
                                            "maxLength": 200
                                          }
                                        },
                                        "required": [
                                          "value",
                                          "label"
                                        ],
                                        "additionalProperties": false
                                      }
                                    },
                                    "targetObject": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "targetObjects": {
                                      "minItems": 1,
                                      "maxItems": 20,
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "minLength": 1
                                      }
                                    },
                                    "inverseField": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "relationCardinality": {
                                      "type": "string",
                                      "enum": [
                                        "many_to_one",
                                        "many_to_many"
                                      ]
                                    },
                                    "onDelete": {
                                      "type": "string",
                                      "enum": [
                                        "set_null",
                                        "cascade"
                                      ]
                                    },
                                    "rollUpEvents": {
                                      "type": "boolean"
                                    },
                                    "maxValues": {
                                      "type": "integer",
                                      "exclusiveMinimum": 0,
                                      "maximum": 100
                                    }
                                  },
                                  "additionalProperties": false
                                },
                                "isNullable": {
                                  "type": "boolean"
                                },
                                "isUnique": {
                                  "type": "boolean"
                                },
                                "isFilterable": {
                                  "type": "boolean"
                                },
                                "isSearchable": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "name",
                                "label",
                                "type"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "nameSingular",
                          "namePlural",
                          "labelSingular",
                          "labelPlural"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "op",
                      "object"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "update_object"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "labelSingular": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "labelPlural": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "description": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 2000
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "labelField": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "op",
                      "object"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "rename_object"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "nameSingular": {
                        "type": "string",
                        "minLength": 1
                      },
                      "namePlural": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "nameSingular",
                      "namePlural"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "delete_object"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "op",
                      "object"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "create_field"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "field": {
                        "type": "object",
                        "properties": {
                          "universalId": {
                            "type": "string",
                            "format": "uuid",
                            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                          },
                          "name": {
                            "type": "string",
                            "minLength": 1
                          },
                          "label": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "description": {
                            "type": "string",
                            "maxLength": 2000
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "text",
                              "number",
                              "boolean",
                              "date",
                              "date_time",
                              "select",
                              "multi_select",
                              "money",
                              "emails",
                              "phones",
                              "links",
                              "full_name",
                              "address",
                              "relation",
                              "json",
                              "files"
                            ]
                          },
                          "settings": {
                            "type": "object",
                            "properties": {
                              "options": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "value": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 100
                                    },
                                    "label": {
                                      "type": "string",
                                      "minLength": 1,
                                      "maxLength": 200
                                    }
                                  },
                                  "required": [
                                    "value",
                                    "label"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "targetObject": {
                                "type": "string",
                                "minLength": 1
                              },
                              "targetObjects": {
                                "minItems": 1,
                                "maxItems": 20,
                                "type": "array",
                                "items": {
                                  "type": "string",
                                  "minLength": 1
                                }
                              },
                              "inverseField": {
                                "type": "string",
                                "minLength": 1
                              },
                              "relationCardinality": {
                                "type": "string",
                                "enum": [
                                  "many_to_one",
                                  "many_to_many"
                                ]
                              },
                              "onDelete": {
                                "type": "string",
                                "enum": [
                                  "set_null",
                                  "cascade"
                                ]
                              },
                              "rollUpEvents": {
                                "type": "boolean"
                              },
                              "maxValues": {
                                "type": "integer",
                                "exclusiveMinimum": 0,
                                "maximum": 100
                              }
                            },
                            "additionalProperties": false
                          },
                          "isNullable": {
                            "type": "boolean"
                          },
                          "isUnique": {
                            "type": "boolean"
                          },
                          "isFilterable": {
                            "type": "boolean"
                          },
                          "isSearchable": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "name",
                          "label",
                          "type"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "field"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "update_field"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "field": {
                        "type": "string",
                        "minLength": 1
                      },
                      "label": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "description": {
                        "anyOf": [
                          {
                            "type": "string",
                            "maxLength": 2000
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "isNullable": {
                        "type": "boolean"
                      },
                      "isUnique": {
                        "type": "boolean"
                      },
                      "isFilterable": {
                        "type": "boolean"
                      },
                      "isSearchable": {
                        "type": "boolean"
                      },
                      "rollUpEvents": {
                        "type": "boolean"
                      },
                      "type": {
                        "type": "string",
                        "enum": [
                          "text",
                          "number",
                          "boolean",
                          "date",
                          "date_time",
                          "select",
                          "multi_select",
                          "money",
                          "emails",
                          "phones",
                          "links",
                          "full_name",
                          "address",
                          "relation",
                          "json",
                          "files"
                        ]
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "field"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "rename_field"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "field": {
                        "type": "string",
                        "minLength": 1
                      },
                      "name": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "field",
                      "name"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "delete_field"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "field": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "field"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "add_option"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "field": {
                        "type": "string",
                        "minLength": 1
                      },
                      "option": {
                        "type": "object",
                        "properties": {
                          "value": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "label": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          }
                        },
                        "required": [
                          "value",
                          "label"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "field",
                      "option"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "update_option"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "field": {
                        "type": "string",
                        "minLength": 1
                      },
                      "value": {
                        "type": "string",
                        "minLength": 1
                      },
                      "label": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "field",
                      "value",
                      "label"
                    ],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "properties": {
                      "op": {
                        "type": "string",
                        "const": "remove_option"
                      },
                      "object": {
                        "type": "string",
                        "minLength": 1
                      },
                      "field": {
                        "type": "string",
                        "minLength": 1
                      },
                      "value": {
                        "type": "string",
                        "minLength": 1
                      }
                    },
                    "required": [
                      "op",
                      "object",
                      "field",
                      "value"
                    ],
                    "additionalProperties": false
                  }
                ]
              }
            },
            "reason": {
              "type": "string",
              "maxLength": 2000
            }
          },
          "required": [
            "operations"
          ],
          "additionalProperties": false
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "The schema change was applied or made no changes.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/SchemaChangeResult"
          }
        }
      }
    },
    "202": {
      "description": "The proposal is pending review.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/SchemaChangeResult"
          }
        }
      }
    },
    "401": {
      "$ref": "#/components/responses/Unauthorized"
    },
    "409": {
      "description": "The change failed to apply.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/SchemaChangeResult"
          }
        }
      }
    },
    "default": {
      "$ref": "#/components/responses/ApiError"
    }
  }
}
```

[Full OpenAPI contract](/openapi.json)
