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.

entity_schema must be a JSON Schema object, so it needs "type": "object" and a properties object. Put row-level security rules under rls. Base44 adds a name key holding the entity name to the schema it stores and returns.

<Warning>This changes the app's live schema right away, but it does not change the entity definition in the app's source code. Base44 rebuilds the live schema from the source files whenever the app's code changes, which reverts anything you set here. Change the code itself when you need the edit to last.</Warning>

Pass User as the entity_name to set the custom fields on the built-in user entity. Those custom fields cannot redeclare email or full_name, which Base44 manages. User is also the one name this endpoint creates when it does not exist yet; every other unknown name returns a 404.

<Note>This endpoint accepts a personal API key, or a workspace API key with the apps:deploy scope.</Note>

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.

ID of the app whose entity schemas you want.

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

The updated entity schema.

entity_namestring required

Name of the entity.

entity_schemaobject required

The entity's stored JSON Schema. For the app's own entities this includes a name key Base44 sets on every write; the User schema does not get one.

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

Changed in 1 of the 10 revisions of this API.1