Update entity schema

<Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>

Replaces an entity's JSON Schema with the one you send. This is a full replacement, not a merge. Anything you leave out is dropped from the schema.

This changes the app's live data model, so it takes effect immediately. It doesn't change the file that defines that model in the app's source code. Since Base44 rebuilds the live model whenever the file is written or the app's code is pulled from GitHub, a change made using this endpoint may be reverted.

To change the model for good, change the entities configuration files.

Pass User as the entity_name to set custom fields on the built-in user entity. Those fields can't redeclare email or full_name, which Base44 manages.

put/api/apps/{app_id}/entity-schemas/{entity_name}

Path parameters

entity_namestring required

Name of the entity to replace, as returned by List entity schemas. Pass User to set the built-in user entity's custom fields.

Name of the entity to replace, as returned by List entity schemas. Pass User to set the built-in user entity's custom fields.

app_idstring required

ID of the app whose entity schemas you want to work with.

ID of the app whose entity schemas you want to work with.

Request body

entity_schemaobject required

The entity's full JSON Schema, replacing the stored one. Needs "type": "object" and a properties object, plus any required fields and row-level security rules under rls.

Example request

{
  "entity_schema": {
    "name": "Invoice",
    "properties": {
      "amount": {
        "description": "Total amount in cents",
        "type": "number"
      },
      "status": {
        "enum": [
          "draft",
          "sent",
          "paid"
        ],
        "type": "string"
      }
    },
    "required": [
      "amount"
    ],
    "rls": {
      "read": {
        "created_by": "{{user.email}}"
      }
    },
    "type": "object"
  }
}

Response

Successful Response

entity_namestring required

Name of the entity.

entity_schemaobject required

The entity's stored JSON Schema, including its properties, required fields, and any row-level security rules under rls. For the app's own entities it also carries a name key holding the entity name. For User it holds only the custom fields added on top of the built-in ones, and has no name key.

Example response

{
  "entity_name": "Invoice",
  "entity_schema": {
    "name": "Invoice",
    "properties": {
      "amount": {
        "description": "Total amount in cents",
        "type": "number"
      },
      "status": {
        "enum": [
          "draft",
          "sent",
          "paid"
        ],
        "type": "string"
      }
    },
    "required": [
      "amount"
    ],
    "rls": {
      "read": {
        "created_by": "{{user.email}}"
      }
    },
    "type": "object"
  }
}

Changes

No recorded changes to this endpoint across all 1 revision of this API.