curl --request POST \
--url https://app.base44.com/api/apps/{app_id}/entity-schemas \
--header 'Content-Type: application/json' \
--header 'api_key: <api-key>' \
--data '
{
"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"
}
}
'import requests
url = "https://app.base44.com/api/apps/{app_id}/entity-schemas"
payload = {
"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"
}
}
headers = {
"api_key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {api_key: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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'
}
})
};
fetch('https://app.base44.com/api/apps/{app_id}/entity-schemas', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.base44.com/api/apps/{app_id}/entity-schemas",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api_key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.base44.com/api/apps/{app_id}/entity-schemas"
payload := strings.NewReader("{\n \"entity_name\": \"Invoice\",\n \"entity_schema\": {\n \"name\": \"Invoice\",\n \"properties\": {\n \"amount\": {\n \"description\": \"Total amount in cents\",\n \"type\": \"number\"\n },\n \"status\": {\n \"enum\": [\n \"draft\",\n \"sent\",\n \"paid\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"amount\"\n ],\n \"rls\": {\n \"read\": {\n \"created_by\": \"{{user.email}}\"\n }\n },\n \"type\": \"object\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("api_key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.base44.com/api/apps/{app_id}/entity-schemas")
.header("api_key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"entity_name\": \"Invoice\",\n \"entity_schema\": {\n \"name\": \"Invoice\",\n \"properties\": {\n \"amount\": {\n \"description\": \"Total amount in cents\",\n \"type\": \"number\"\n },\n \"status\": {\n \"enum\": [\n \"draft\",\n \"sent\",\n \"paid\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"amount\"\n ],\n \"rls\": {\n \"read\": {\n \"created_by\": \"{{user.email}}\"\n }\n },\n \"type\": \"object\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.base44.com/api/apps/{app_id}/entity-schemas")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["api_key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"entity_name\": \"Invoice\",\n \"entity_schema\": {\n \"name\": \"Invoice\",\n \"properties\": {\n \"amount\": {\n \"description\": \"Total amount in cents\",\n \"type\": \"number\"\n },\n \"status\": {\n \"enum\": [\n \"draft\",\n \"sent\",\n \"paid\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"amount\"\n ],\n \"rls\": {\n \"read\": {\n \"created_by\": \"{{user.email}}\"\n }\n },\n \"type\": \"object\"\n }\n}"
response = http.request(request)
puts response.read_body{
"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"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Create entity schema
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.
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.
apps:deploy scope.curl --request POST \
--url https://app.base44.com/api/apps/{app_id}/entity-schemas \
--header 'Content-Type: application/json' \
--header 'api_key: <api-key>' \
--data '
{
"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"
}
}
'import requests
url = "https://app.base44.com/api/apps/{app_id}/entity-schemas"
payload = {
"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"
}
}
headers = {
"api_key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {api_key: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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'
}
})
};
fetch('https://app.base44.com/api/apps/{app_id}/entity-schemas', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.base44.com/api/apps/{app_id}/entity-schemas",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'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'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"api_key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.base44.com/api/apps/{app_id}/entity-schemas"
payload := strings.NewReader("{\n \"entity_name\": \"Invoice\",\n \"entity_schema\": {\n \"name\": \"Invoice\",\n \"properties\": {\n \"amount\": {\n \"description\": \"Total amount in cents\",\n \"type\": \"number\"\n },\n \"status\": {\n \"enum\": [\n \"draft\",\n \"sent\",\n \"paid\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"amount\"\n ],\n \"rls\": {\n \"read\": {\n \"created_by\": \"{{user.email}}\"\n }\n },\n \"type\": \"object\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("api_key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.base44.com/api/apps/{app_id}/entity-schemas")
.header("api_key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"entity_name\": \"Invoice\",\n \"entity_schema\": {\n \"name\": \"Invoice\",\n \"properties\": {\n \"amount\": {\n \"description\": \"Total amount in cents\",\n \"type\": \"number\"\n },\n \"status\": {\n \"enum\": [\n \"draft\",\n \"sent\",\n \"paid\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"amount\"\n ],\n \"rls\": {\n \"read\": {\n \"created_by\": \"{{user.email}}\"\n }\n },\n \"type\": \"object\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.base44.com/api/apps/{app_id}/entity-schemas")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["api_key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"entity_name\": \"Invoice\",\n \"entity_schema\": {\n \"name\": \"Invoice\",\n \"properties\": {\n \"amount\": {\n \"description\": \"Total amount in cents\",\n \"type\": \"number\"\n },\n \"status\": {\n \"enum\": [\n \"draft\",\n \"sent\",\n \"paid\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"amount\"\n ],\n \"rls\": {\n \"read\": {\n \"created_by\": \"{{user.email}}\"\n }\n },\n \"type\": \"object\"\n }\n}"
response = http.request(request)
puts response.read_body{
"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"
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Personal API key.
Path Parameters
ID of the app whose entity schemas you want.
Body
Name for the new entity. Letters, numbers, and underscores only. Cannot be User.
"Invoice"
The entity's JSON Schema: its properties, its required fields, and any row-level security rules under rls.
{
"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.
Name of the entity.
"Invoice"
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.
{
"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"
}
Was this page helpful?