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 app's entire set of entities with the one you send, in a single call. This is what a deploy uses to make the app's live schema match its source.

<Warning>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.</Warning>

The response reports what changed, split into created, updated, and deleted. It also carries warnings for problems Base44 accepted instead of rejecting, so a 200 with a non-empty warnings means the sync applied but something in it is not doing what it looks like.

<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>

This endpoint is only available for apps whose source code you manage yourself. On an app whose code Base44 generates, it returns a 428. An entity that still has records cannot be deleted, so a sync that drops such an entity returns a 428 and changes nothing.

<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

Path parameters

app_idstring required

ID of the app whose entity schemas you want.

ID of the app whose entity schemas you want.

Request body

entityNameToSchemaobject required

The app's complete set of entities, keyed by entity name. Each value is that entity's JSON Schema. Any entity the app currently has and this map does not 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

What the sync created, updated, and deleted, plus any warnings.

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[]

Problems Base44 accepted rather than rejected. Currently these are row-level security rules it cannot enforce on an entity that has no previous version, which a deploy usually carried over rather than wrote. The sync still applied.

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