Create Collection
Create a new collection with custom schema.
Creates an Alembic migration and applies it to create the physical table. Only superadmins can create collections.
curl --request POST \
--url https://api.example.com/api/v1/collections \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"schema": [
{
"name": "<string>",
"type": "<string>",
"required": false,
"default": "<unknown>",
"unique": false,
"options": {},
"collection": "<string>",
"on_delete": "<string>",
"pii": false,
"mask_type": "<string>",
"expression": "<string>",
"return_type": "<string>"
}
],
"list_rule": "<string>",
"view_rule": "<string>",
"create_rule": "<string>",
"update_rule": "<string>",
"delete_rule": "<string>",
"list_fields": "*",
"view_fields": "*",
"create_fields": "*",
"update_fields": "*"
}
'import requests
url = "https://api.example.com/api/v1/collections"
payload = {
"name": "<string>",
"schema": [
{
"name": "<string>",
"type": "<string>",
"required": False,
"default": "<unknown>",
"unique": False,
"options": {},
"collection": "<string>",
"on_delete": "<string>",
"pii": False,
"mask_type": "<string>",
"expression": "<string>",
"return_type": "<string>"
}
],
"list_rule": "<string>",
"view_rule": "<string>",
"create_rule": "<string>",
"update_rule": "<string>",
"delete_rule": "<string>",
"list_fields": "*",
"view_fields": "*",
"create_fields": "*",
"update_fields": "*"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
schema: [
{
name: '<string>',
type: '<string>',
required: false,
default: '<unknown>',
unique: false,
options: {},
collection: '<string>',
on_delete: '<string>',
pii: false,
mask_type: '<string>',
expression: '<string>',
return_type: '<string>'
}
],
list_rule: '<string>',
view_rule: '<string>',
create_rule: '<string>',
update_rule: '<string>',
delete_rule: '<string>',
list_fields: '*',
view_fields: '*',
create_fields: '*',
update_fields: '*'
})
};
fetch('https://api.example.com/api/v1/collections', 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://api.example.com/api/v1/collections",
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([
'name' => '<string>',
'schema' => [
[
'name' => '<string>',
'type' => '<string>',
'required' => false,
'default' => '<unknown>',
'unique' => false,
'options' => [
],
'collection' => '<string>',
'on_delete' => '<string>',
'pii' => false,
'mask_type' => '<string>',
'expression' => '<string>',
'return_type' => '<string>'
]
],
'list_rule' => '<string>',
'view_rule' => '<string>',
'create_rule' => '<string>',
'update_rule' => '<string>',
'delete_rule' => '<string>',
'list_fields' => '*',
'view_fields' => '*',
'create_fields' => '*',
'update_fields' => '*'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://api.example.com/api/v1/collections"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"schema\": [\n {\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"required\": false,\n \"default\": \"<unknown>\",\n \"unique\": false,\n \"options\": {},\n \"collection\": \"<string>\",\n \"on_delete\": \"<string>\",\n \"pii\": false,\n \"mask_type\": \"<string>\",\n \"expression\": \"<string>\",\n \"return_type\": \"<string>\"\n }\n ],\n \"list_rule\": \"<string>\",\n \"view_rule\": \"<string>\",\n \"create_rule\": \"<string>\",\n \"update_rule\": \"<string>\",\n \"delete_rule\": \"<string>\",\n \"list_fields\": \"*\",\n \"view_fields\": \"*\",\n \"create_fields\": \"*\",\n \"update_fields\": \"*\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/api/v1/collections")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"schema\": [\n {\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"required\": false,\n \"default\": \"<unknown>\",\n \"unique\": false,\n \"options\": {},\n \"collection\": \"<string>\",\n \"on_delete\": \"<string>\",\n \"pii\": false,\n \"mask_type\": \"<string>\",\n \"expression\": \"<string>\",\n \"return_type\": \"<string>\"\n }\n ],\n \"list_rule\": \"<string>\",\n \"view_rule\": \"<string>\",\n \"create_rule\": \"<string>\",\n \"update_rule\": \"<string>\",\n \"delete_rule\": \"<string>\",\n \"list_fields\": \"*\",\n \"view_fields\": \"*\",\n \"create_fields\": \"*\",\n \"update_fields\": \"*\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/collections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"schema\": [\n {\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"required\": false,\n \"default\": \"<unknown>\",\n \"unique\": false,\n \"options\": {},\n \"collection\": \"<string>\",\n \"on_delete\": \"<string>\",\n \"pii\": false,\n \"mask_type\": \"<string>\",\n \"expression\": \"<string>\",\n \"return_type\": \"<string>\"\n }\n ],\n \"list_rule\": \"<string>\",\n \"view_rule\": \"<string>\",\n \"create_rule\": \"<string>\",\n \"update_rule\": \"<string>\",\n \"delete_rule\": \"<string>\",\n \"list_fields\": \"*\",\n \"view_fields\": \"*\",\n \"create_fields\": \"*\",\n \"update_fields\": \"*\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"table_name": "<string>",
"schema": [
{
"name": "<string>",
"type": "<string>",
"required": false,
"default": "<unknown>",
"unique": false,
"options": {},
"collection": "<string>",
"on_delete": "<string>",
"pii": false,
"mask_type": "<string>",
"expression": "<string>",
"return_type": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
Request body for creating a new collection.
Collection name (3-64 chars, alphanumeric + underscores)
3 - 64List of field definitions (at least one required)
1Show child attributes
Show child attributes
Filter expression for listing records
Filter expression for viewing records
Validation expression for creating records
Filter/validation expression for updates
Filter expression for deletions
Fields visible in list operations
Fields visible in view operations
Fields allowed in create requests
Fields allowed in update requests
Response
Successful Response
Response for a created collection.
Collection ID (UUID)
Collection name
Physical table name in database
Collection schema
Show child attributes
Show child attributes
When the collection was created
When the collection was last updated
curl --request POST \
--url https://api.example.com/api/v1/collections \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"schema": [
{
"name": "<string>",
"type": "<string>",
"required": false,
"default": "<unknown>",
"unique": false,
"options": {},
"collection": "<string>",
"on_delete": "<string>",
"pii": false,
"mask_type": "<string>",
"expression": "<string>",
"return_type": "<string>"
}
],
"list_rule": "<string>",
"view_rule": "<string>",
"create_rule": "<string>",
"update_rule": "<string>",
"delete_rule": "<string>",
"list_fields": "*",
"view_fields": "*",
"create_fields": "*",
"update_fields": "*"
}
'import requests
url = "https://api.example.com/api/v1/collections"
payload = {
"name": "<string>",
"schema": [
{
"name": "<string>",
"type": "<string>",
"required": False,
"default": "<unknown>",
"unique": False,
"options": {},
"collection": "<string>",
"on_delete": "<string>",
"pii": False,
"mask_type": "<string>",
"expression": "<string>",
"return_type": "<string>"
}
],
"list_rule": "<string>",
"view_rule": "<string>",
"create_rule": "<string>",
"update_rule": "<string>",
"delete_rule": "<string>",
"list_fields": "*",
"view_fields": "*",
"create_fields": "*",
"update_fields": "*"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
schema: [
{
name: '<string>',
type: '<string>',
required: false,
default: '<unknown>',
unique: false,
options: {},
collection: '<string>',
on_delete: '<string>',
pii: false,
mask_type: '<string>',
expression: '<string>',
return_type: '<string>'
}
],
list_rule: '<string>',
view_rule: '<string>',
create_rule: '<string>',
update_rule: '<string>',
delete_rule: '<string>',
list_fields: '*',
view_fields: '*',
create_fields: '*',
update_fields: '*'
})
};
fetch('https://api.example.com/api/v1/collections', 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://api.example.com/api/v1/collections",
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([
'name' => '<string>',
'schema' => [
[
'name' => '<string>',
'type' => '<string>',
'required' => false,
'default' => '<unknown>',
'unique' => false,
'options' => [
],
'collection' => '<string>',
'on_delete' => '<string>',
'pii' => false,
'mask_type' => '<string>',
'expression' => '<string>',
'return_type' => '<string>'
]
],
'list_rule' => '<string>',
'view_rule' => '<string>',
'create_rule' => '<string>',
'update_rule' => '<string>',
'delete_rule' => '<string>',
'list_fields' => '*',
'view_fields' => '*',
'create_fields' => '*',
'update_fields' => '*'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://api.example.com/api/v1/collections"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"schema\": [\n {\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"required\": false,\n \"default\": \"<unknown>\",\n \"unique\": false,\n \"options\": {},\n \"collection\": \"<string>\",\n \"on_delete\": \"<string>\",\n \"pii\": false,\n \"mask_type\": \"<string>\",\n \"expression\": \"<string>\",\n \"return_type\": \"<string>\"\n }\n ],\n \"list_rule\": \"<string>\",\n \"view_rule\": \"<string>\",\n \"create_rule\": \"<string>\",\n \"update_rule\": \"<string>\",\n \"delete_rule\": \"<string>\",\n \"list_fields\": \"*\",\n \"view_fields\": \"*\",\n \"create_fields\": \"*\",\n \"update_fields\": \"*\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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://api.example.com/api/v1/collections")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"schema\": [\n {\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"required\": false,\n \"default\": \"<unknown>\",\n \"unique\": false,\n \"options\": {},\n \"collection\": \"<string>\",\n \"on_delete\": \"<string>\",\n \"pii\": false,\n \"mask_type\": \"<string>\",\n \"expression\": \"<string>\",\n \"return_type\": \"<string>\"\n }\n ],\n \"list_rule\": \"<string>\",\n \"view_rule\": \"<string>\",\n \"create_rule\": \"<string>\",\n \"update_rule\": \"<string>\",\n \"delete_rule\": \"<string>\",\n \"list_fields\": \"*\",\n \"view_fields\": \"*\",\n \"create_fields\": \"*\",\n \"update_fields\": \"*\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/collections")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"schema\": [\n {\n \"name\": \"<string>\",\n \"type\": \"<string>\",\n \"required\": false,\n \"default\": \"<unknown>\",\n \"unique\": false,\n \"options\": {},\n \"collection\": \"<string>\",\n \"on_delete\": \"<string>\",\n \"pii\": false,\n \"mask_type\": \"<string>\",\n \"expression\": \"<string>\",\n \"return_type\": \"<string>\"\n }\n ],\n \"list_rule\": \"<string>\",\n \"view_rule\": \"<string>\",\n \"create_rule\": \"<string>\",\n \"update_rule\": \"<string>\",\n \"delete_rule\": \"<string>\",\n \"list_fields\": \"*\",\n \"view_fields\": \"*\",\n \"create_fields\": \"*\",\n \"update_fields\": \"*\"\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"table_name": "<string>",
"schema": [
{
"name": "<string>",
"type": "<string>",
"required": false,
"default": "<unknown>",
"unique": false,
"options": {},
"collection": "<string>",
"on_delete": "<string>",
"pii": false,
"mask_type": "<string>",
"expression": "<string>",
"return_type": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}