Collections
Update Collection
Update collection schema.
Allows adding new fields and modifying field properties (except type changes). Only superadmins (users in the system account) can update collections.
PUT
/
api
/
v1
/
collections
/
{collection_id}
Update Collection
curl --request PUT \
--url https://api.example.com/api/v1/collections/{collection_id} \
--header 'Content-Type: application/json' \
--data '
{
"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>"
}
]
}
'import requests
url = "https://api.example.com/api/v1/collections/{collection_id}"
payload = { "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>"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
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>'
}
]
})
};
fetch('https://api.example.com/api/v1/collections/{collection_id}', 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/{collection_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'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>'
]
]
]),
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/{collection_id}"
payload := strings.NewReader("{\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}")
req, _ := http.NewRequest("PUT", 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.put("https://api.example.com/api/v1/collections/{collection_id}")
.header("Content-Type", "application/json")
.body("{\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}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/collections/{collection_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\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}"
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>"
}
]
}Path Parameters
Body
application/json
Request body for updating a collection schema.
Updated list of field definitions (at least one required)
Minimum array length:
1Show child attributes
Show child attributes
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
Previous
Delete CollectionDelete collection and drop its physical table.
Uses a two-phase approach to avoid transaction deadlocks on PostgreSQL:
1. Prepare deletion and generate migration (read-only)
2. Close session and apply migration (no locks held)
3. Delete collection record in new session
Only superadmins (users in the system account) can delete collections.
Next
⌘I
Update Collection
curl --request PUT \
--url https://api.example.com/api/v1/collections/{collection_id} \
--header 'Content-Type: application/json' \
--data '
{
"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>"
}
]
}
'import requests
url = "https://api.example.com/api/v1/collections/{collection_id}"
payload = { "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>"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
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>'
}
]
})
};
fetch('https://api.example.com/api/v1/collections/{collection_id}', 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/{collection_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'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>'
]
]
]),
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/{collection_id}"
payload := strings.NewReader("{\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}")
req, _ := http.NewRequest("PUT", 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.put("https://api.example.com/api/v1/collections/{collection_id}")
.header("Content-Type", "application/json")
.body("{\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}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/collections/{collection_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\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}"
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>"
}
]
}