Sync entity schemas

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

Replaces the specified app's entire set of entities with the one you send, in a single call.

Send every entity the app should have. Any entity the app currently has that is missing from entityNameToSchema is deleted. Include User to keep its custom fields. Leaving it out drops them. An empty object deletes every entity the app has.

Base44 won't delete an entity that still holds records. If the set you send leaves out an entity that has records, the whole call fails and nothing changes.

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.

This endpoint requires the app's source code to be under your control. That includes projects you create with the Base44 CLI and projects you eject from the Base44 online app editor. Some managed-source apps may also be granted access.

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

Path parameters

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

entityNameToSchemaobject required

The app's complete set of entities, keyed by entity name. Each value is that entity's JSON Schema, which needs "type": "object" and a properties object, plus any required fields and row-level security rules under rls. Any entity the app currently has that this map leaves out is deleted.

Example request

{
  "entityNameToSchema": {
    "Invoice": {
      "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

createdstring[] required

Entities that did not exist before and were added.

updatedstring[] required

Entities that already existed and were replaced.

deletedstring[] required

Entities the app had and the request left out, which were removed.

warningsstring[] required

Row-level security rules Base44 stored but can't enforce. The sync still applied, so an entity named here exists with a rule that isn't protecting anything. Base44 reports a rule this way only for an entity the sync adds fresh (one that didn't exist in the app before). On an entity the app already has, a new or changed rule of this kind fails the call with a 400. An unchanged unenforceable rule on an existing entity is left in place silently and doesn't appear here.

Example response

{
  "created": [
    "Invoice"
  ],
  "updated": [
    "Customer"
  ],
  "deleted": [
    "LegacyOrder"
  ],
  "warnings": [
    "Invalid RLS rule in Invoice: \"properties.total.rls.delete\" — field-level delete rules are not enforced — delete removes the whole record (there is no field-level delete gate); put the restriction in a top-level rls.delete instead."
  ]
}

Changes

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