The API uses
type for Database and app for Space. See Terminology.Create Field
Primitive Field
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/create',
args: {
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Salary',
'fibery/type': 'fibery/int',
'fibery/meta': {
'fibery/readonly?': false,
'fibery/default-value': 1000,
'ui/number-unit': 'USD'
}
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Salary",
"fibery/type": "fibery/int",
"fibery/meta": {
"fibery/readonly?": false,
"fibery/default-value": 1000,
"ui/number-unit": "USD"
}
}
}
]
}
}
'
{
"success": true,
"result": "ok"
}
| Field type | Example | Comments |
|---|---|---|
fibery/int | 42 | |
fibery/decimal | 0.33 | |
fibery/bool | true | |
fibery/text | Don't panic | Up to 1k characters. Can be styled using ui/type meta flag: text | email | phone | url |
~~fibery/email~~ | Deprecated. Use a fibery/text field with ui/type meta set to "email": {"ui/type": "email"} | |
fibery/emoji | 🏏 | |
fibery/date | 1979-10-12 | |
fibery/date-time | 2019-06-24T12:25:20.812Z | |
fibery/date-range | {"start": "2019-06-27", "end": "2019-06-30"} | |
fibery/date-time-range | {"start": "2019-06-18T02:40:00.000Z", "end": "2019-07-25T11:40:00.000Z"} | |
fibery/location | {"longitude": 2.349606, "latitude": 48.890764, "fullAddress": "Métro Marcadet Poissonniers, 67 boulevard Barbès, Paris, 75018, France", "addressParts": {"city": "Paris", "country": "France"}} | All address parts are optional. |
fibery/uuid | acb5ef80-9679-11e9-bc42-526af7764f64 | |
fibery/rank | 1000 | |
fibery/json-value | {"paranoid?": true} |
| Parameter (required in bold) | Description | Example |
|---|---|---|
fibery/holder-type | Holder Database name in ${space}/${name} format | Cricket/Player |
fibery/name | Field name in ${space}/${name} format. | Cricket/Salary |
fibery/type | One of the primitive Field types above or a Database for a one-way relation. | fibery/int |
meta.fibery/readonly? | If users are able to change value from UI | true |
meta.fibery/default-value | The value automatically set when a new entity is created | ”(empty)“ |
meta.fibery/unique? | Makes field values to be unique across the whole Database Only one of unique flags can be used at a time as fibery/unique? and fibery/case-insensitive-text-unique? are mutually exclusive | true |
meta.fibery/case-insensitive-text-unique? | makes field values to be unique case insensitive across whole Database | true |
Create unique case insensitive Text Field:
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/create',
args: {
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/SSN',
'fibery/type': 'fibery/text',
'fibery/meta': {
'fibery/readonly?': false,
'fibery/case-insensitive-text-unique?': true
}
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/SSN",
"fibery/type": "fibery/text",
"fibery/meta": {
"fibery/readonly?": false,
"fibery/case-insensitive-text-unique?": true
}
}
}
]
}
}
'
{
"success": true,
"result": "ok"
}
Create unique Int Field:
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/create',
args: {
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Jersey Number',
'fibery/type': 'fibery/int',
'fibery/meta': {
'fibery/readonly?': false,
'fibery/unique?': true
}
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Jersey Number",
"fibery/type": "fibery/int",
"fibery/meta": {
"fibery/readonly?": false,
"fibery/unique?": true
}
}
}
]
}
}
'
{
"success": true,
"result": "ok"
}
Relation (entity [collection] Field)
To create a relation between two Databases, we create a pair of entity [collection] Fields and connect them with a unique identifier. The relation is to-one by default. Set entity Field’s meta.fibery/collection? to true for to-many relation.
const relationId = 'd9e9ec34-9685-11e9-8550-526af7764f64';
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/create',
args: {
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Current Team',
'fibery/type': 'Cricket/Team',
'fibery/meta': {
'fibery/relation': relationId
}
}
},
{
command: 'schema.field/create',
args: {
'fibery/holder-type': 'Cricket/Team',
'fibery/name': 'Cricket/Current Roster',
'fibery/type': 'Cricket/Player',
'fibery/meta': {
'fibery/collection?': true,
'fibery/relation': relationId
}
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Current Team",
"fibery/type": "Cricket/Team",
"fibery/meta": {
"fibery/relation": "d9e9ec34-9685-11e9-8550-526af7764f64"
}
}
},
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Team",
"fibery/name": "Cricket/Current Roster",
"fibery/type": "Cricket/Player",
"fibery/meta": {
"fibery/collection?": true,
"fibery/relation": "d9e9ec34-9685-11e9-8550-526af7764f64"
}
}
}
]
}
}
'
{
"success": true,
"result": "ok"
}
| Parameter (required in bold) | Description | Example |
|---|---|---|
fibery/holder-type | Holder Database name in ${space}/${name} format | Cricket/Player |
fibery/name | Field name in ${space}/${name} format. | Cricket/Current Team |
fibery/type | Related Database name in ${space}/${name} format | Cricket/Team |
meta.fibery/relation | UUID shared between the pair of Fields. | d9e9ec34-96… |
meta.fibery/collection? | true for to-many relation (entity collection Field) | true |
meta.fibery/readonly? | If users are able to change value from UI | true |
Single-select Field
A single-select Field is not what it seems to be. Actually, every single-select option is an Entity of a newly created special Database. This way unlocks ‘name on UI + value in Formula’ scenario (thinkSelf conviction → 0.01 in GIST) and enables an easy transition to a fully functional Database.
To create a single-select Field we should:
- Create a new
enumDatabase - Create a Field of the newly created
enumDatabase - Create an Entity for each single-select option
- Make the selection required and set the default value
enum Database name is built using this format: ${space}/${field}_${app}/${holder-type}.
const enumType = 'Cricket/Batting Hand_Cricket/Player';
const rightId = '4a3ffb10-9747-11e9-9def-016e5ea5e162';
const leftId = '4a402220-9747-11e9-9def-016e5ea5e162';
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.command/batch',
args: {
commands: [
{
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.enum/create',
args: { 'fibery/name': enumType }
},
{
command: 'schema.field/create',
args: {
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Batting Hand',
'fibery/type': enumType
}
}
]
}
},
{
command: 'fibery.entity/create',
args: {
type: enumType,
entity: {
'enum/name': 'Right',
'fibery/id': rightId,
'fibery/rank': 0
}
}
},
{
command: 'fibery.entity/create',
args: {
type: enumType,
entity: {
'enum/name': 'Left',
'fibery/id': leftId,
'fibery/rank': 1000000
}
}
},
{
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/set-meta',
args: {
name: 'Cricket/Batting Hand',
'holder-type': 'Cricket/Player',
key: 'fibery/default-value',
value: { 'fibery/id': rightId }
}
},
{
command: 'schema.field/set-meta',
args: {
name: 'Cricket/Batting Hand',
'holder-type': 'Cricket/Player',
key: 'fibery/required?',
value: true
}
}
]
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.command/batch",
"args": {
"commands": [
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.enum/create",
"args": {
"fibery/name": "Cricket/Batting Hand_Cricket/Player"
}
},
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Batting Hand",
"fibery/type": "Cricket/Batting Hand_Cricket/Player"
}
}
]
}
},
{
"command": "fibery.entity/create",
"args": {
"type": "Cricket/Batting Hand_Cricket/Player",
"entity": {
"enum/name": "Right",
"fibery/id": "4a3ffb10-9747-11e9-9def-016e5ea5e162",
"fibery/rank": 0
}
}
},
{
"command": "fibery.entity/create",
"args": {
"type": "Cricket/Batting Hand_Cricket/Player",
"entity": {
"enum/name": "Left",
"fibery/id": "4a402220-9747-11e9-9def-016e5ea5e162",
"fibery/rank": 1000000
}
}
},
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/set-meta",
"args": {
"name": "Cricket/Batting Hand",
"holder-type": "Cricket/Player",
"key": "fibery/default-value",
"value": {
"fibery/id": "4a3ffb10-9747-11e9-9def-016e5ea5e162"
}
}
},
{
"command": "schema.field/set-meta",
"args": {
"name": "Cricket/Batting Hand",
"holder-type": "Cricket/Player",
"key": "fibery/required?",
"value": true
}
}
]
}
}
]
}
}
'
{
"success": true,
"result": [
{
"success": true,
"result": "ok"
},
{
"success": true,
"result": {
"fibery/id": "4a3ffb10-9747-11e9-9def-016e5ea5e162",
"fibery/public-id": "1",
"enum/name": "Right",
"fibery/rank": 0
}
},
{
"success": true,
"result": {
"fibery/id": "4a402220-9747-11e9-9def-016e5ea5e162",
"fibery/public-id": "2",
"enum/name": "Left",
"fibery/rank": 1000000
}
},
{
"success": true,
"result": "ok"
}
]
}
Rich text Field
In Fibery, every rich text Field instance is, in fact, a collaborative document. It means that for each Entity with N rich text Fields Fibery automatically creates N documents. Each of these documents is stored in Document Storage and is connected to its Entity through an auxiliaryCollaboration~Documents/Document Entity:
Entity --- (magic) ---> Collab Doc/Document --- (fibery/secret) ---> Document in Storage
So to create a rich text Field we just connect our Database with the Collaboration~Documents/Document Database. This Database has a special property: the entities inside it inherit access from their Parent Entity. To indicate that Parent-Child relationship we pass fibery/entity-component? meta flag, but only for ordinary Fields (e.g. not Lookup and not Formula)
Selecting and updating a rich text Field is a two-step process:
- Get
fibery/secretof the related Document. - Work with this Document via
api/documentsStorage endpoint.
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/create',
args: {
'fibery/holder-type': 'Cricket/Player',
'fibery/name': 'Cricket/Bio',
'fibery/type': 'Collaboration~Documents/Document',
'fibery/meta': {
'fibery/entity-component?': true
}
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/create",
"args": {
"fibery/holder-type": "Cricket/Player",
"fibery/name": "Cricket/Bio",
"fibery/type": "Collaboration~Documents/Document",
"fibery/meta": {
"fibery/entity-component?": true
}
}
}
]
}
}
'
{
"success": true,
"result": "ok"
}
Rename Field
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/rename',
args: {
'holder-type': 'Cricket/Player',
'from-name': 'Cricket/Position',
'to-name': 'Cricket/Role'
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/rename",
"args": {
"holder-type": "Cricket/Player",
"from-name": "Cricket/Position",
"to-name": "Cricket/Role"
}
}
]
}
}
'
{
"success": true,
"result": "ok"
}
| Parameter (required in bold) | Description | Example |
|---|---|---|
holder-type | Holder Database name in ${space}/${name} format | Cricket/Player |
from-name | Current Field name in ${space}/${name} format | Cricket/Position |
to-name | New Field name in ${space}/${name} format | Cricket/Role |
Delete Field
const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/commands', {
method: 'POST',
headers: {
'Authorization': 'Token YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
command: 'fibery.schema/batch',
args: {
commands: [
{
command: 'schema.field/delete',
args: {
'holder-type': 'Cricket/Player',
name: 'Cricket/Role',
'delete-values?': true
}
}
]
}
})
});
const data = await response.json();
curl -X POST https://YOUR_ACCOUNT.fibery.io/api/commands \
-H 'Authorization: Token YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '
{
"command": "fibery.schema/batch",
"args": {
"commands": [
{
"command": "schema.field/delete",
"args": {
"holder-type": "Cricket/Player",
"name": "Cricket/Role",
"delete-values?": true
}
}
]
}
}
'
{
"success": true,
"result": "ok"
}
Command parameters
| Parameter (required in bold) | Default | Description | Example |
|---|---|---|---|
holder-type | Holder Database name in ${space}/${name} format | Cricket/Player | |
name | Field name in ${space}/${name} format | Cricket/Role | |
delete-values? | false | See the behavior in the table below | true |
To remove a relation, delete both entity [collection] Fields within the same
fibery.schema/batch command.delete-values? parameter behavior
delete-values? | |||
|---|---|---|---|
| false | true | ||
| Field type | Empty primitive Field | Field is deleted | Field is deleted |
| Non-empty primitive Field | Error is thrown | Field and values are deleted | |
| Empty entity [collection] Field | Field is deleted | Field is deleted | |
| Non-empty entity [collection] Field | Error is thrown | Field and links (but not related Entities) are deleted | |
