Create entity schema

Changed on

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

Adds a new entity to the specified app.

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.

You can't create User, which is built in. Use Update entity schema with User to add custom fields to it.

Entity schemas change on main only, so naming a branch in branch_id returns a 409. To add entities or fields on a branch, use Send chat message with that branch_id.

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

Request

  • Base URL
    https://app.base44.com
  • URL
    https://app.base44.com/api/apps/{app_id}/entity-schemas
  • Auth
    • HTTP bearer
    • or API key in header api_key
    • or HTTP bearer

Path parameters

app_idstring required

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

Query parameters

branch_idstring

ID of the branch to work on, as returned by List branches. Omit it to work on the app's main branch.

Request body

entity_namestring required

Name for the new entity. Letters, numbers, and underscores only. Cannot be User.

entity_schemaobject required

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

Example request

{
  "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"
  }
}

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