Skip to main content
A Field is a part of a Database. Learn more about it in the Schema guide.
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();
Response:
{
  "success": true,
  "result": "ok"
}
Primitive Field types
Field typeExampleComments
fibery/int42
fibery/decimal0.33
fibery/booltrue
fibery/textDon't panicUp to 1k characters. Can be styled using ui/type meta flag: text | email | phone | url
~~fibery/email~~contact@megadodo.comDeprecated. Use a fibery/text field with ui/type meta set to "email": {"ui/type": "email"}
fibery/emoji🏏
fibery/date1979-10-12
fibery/date-time2019-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/uuidacb5ef80-9679-11e9-bc42-526af7764f64
fibery/rank1000
fibery/json-value{"paranoid?": true}
Command parameters
Parameter (required in bold)DescriptionExample
fibery/holder-typeHolder Database name in ${space}/${name} formatCricket/Player
fibery/nameField name in ${space}/${name} format.Cricket/Salary
fibery/typeOne 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 UItrue
meta.fibery/default-valueThe 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 exclusivetrue
meta.fibery/case-insensitive-text-unique?makes field values to be unique case insensitive across whole Databasetrue

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();
Response:
{
  "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();
Response:
{
  "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();
Response:
{
  "success": true,
  "result": "ok"
}
Command parameters
Parameter (required in bold)DescriptionExample
fibery/holder-typeHolder Database name in ${space}/${name} formatCricket/Player
fibery/nameField name in ${space}/${name} format.Cricket/Current Team
fibery/typeRelated Database name in ${space}/${name} formatCricket/Team
meta.fibery/relationUUID 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 UItrue

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 (think Self conviction0.01 in GIST) and enables an easy transition to a fully functional Database. To create a single-select Field we should:
  1. Create a new enum Database
  2. Create a Field of the newly created enum Database
  3. Create an Entity for each single-select option
  4. Make the selection required and set the default value
The new 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();
Response:
{
  "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 auxiliary Collaboration~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:
  1. Get fibery/secret of the related Document.
  2. Work with this Document via api/documents Storage 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();
Response:
{
  "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();
Response:
{
  "success": true,
  "result": "ok"
}
Command parameters
Parameter (required in bold)DescriptionExample
holder-typeHolder Database name in ${space}/${name} formatCricket/Player
from-nameCurrent Field name in ${space}/${name} formatCricket/Position
to-nameNew Field name in ${space}/${name} formatCricket/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();
Response:
{
  "success": true,
  "result": "ok"
}

Command parameters

Parameter (required in bold)DefaultDescriptionExample
holder-typeHolder Database name in ${space}/${name} formatCricket/Player
nameField name in ${space}/${name} formatCricket/Role
delete-values?falseSee the behavior in the table belowtrue
To remove a relation, delete both entity [collection] Fields within the same fibery.schema/batch command.
delete-values? parameter behavior
delete-values?
falsetrue
Field typeEmpty primitive FieldField is deletedField is deleted
Non-empty primitive FieldError is thrownField and values are deleted
Empty entity [collection] FieldField is deletedField is deleted
Non-empty entity [collection] FieldError is thrownField and links (but not related Entities) are deleted

FAQ

Is there a way to modify the meta.fibery/readonly? value? Is there any way to convert a field away from read-only?

Use "command": "schema.field/set-meta". So, if you can set the fibery/readonly? meta value to false, that has to work.