Create entity schema
<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 app and makes it queryable right away.
Send the entity name and its JSON Schema. The name must contain only letters, numbers, and underscores. Put the entity's properties and required fields in entity_schema, and its 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>
You cannot create User, which is built in. Use Update entity schema with User to add custom fields to it.
A name the app already uses returns a 409. The one exception is a workspace API key resending a byte-identical schema, which returns a 200 so a repeated deploy is safe. The same request with a personal API key still returns a 409.
<Note>This endpoint accepts a personal API key, or a workspace API key with the apps:deploy scope.</Note>
Path parameters
ID of the app whose entity schemas you want.
ID of the app whose entity schemas you want.
Request body
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
The created entity schema.
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"
}
}