Working with Fields

Records stored in your app are indexed by the field key (e.g. field_1) and include a unique record ID which you can use to specify that record in subsequent requests.

You can determine the field key of any field by clicking the id icon in the top navigation of the Schema section of the Builder to display the field key below the field names. This will also enable searching by field key from the keyword search in the Builder.

1170

Field Types

The information and examples below demonstrate how each of Knack's field types is formatted in the JSON you will send and receive.

Short Text

Short text values are stored as strings.

"Knack"

Paragraph Text

Paragraph text values are stored as strings.

"Knack is the easiest way to build online database apps."

Number

Number fields are stored as numbers.

201519

Yes/No

Yes/no fields store boolean values, though you can use either strings or booleans in your PUT and POST requests. Note that you can use "yes," "on," "false," or "off," as well, and that the API is not case-sensitive with these values.

true

Name

Name fields are stored as objects with a title, first, middle, and last name, each of which is a string.

{
  "title":"Mr.",
  "first":"Brandon",
  "middle":"R",
  "last":"Griggs"
}

Email

Email fields are stored as objects with an email and label, each of which is a string.

{
  "email":"[email protected]",
  "label":"Knack Support"
}

Multiple Choice

Multiple choice fields come in two variants: one selection (string) and multiple selections (array of strings).

// One selection
"Large"

// Multiple selections
["Option 1", "Option 2"]

Date/Time

Date/time fields have four variants, each of which is an object with its own type of formatting: single date as object, single date as string, from-to date/all day, and time-only. See below for an example of each.

Note that the type of date format selected for the field in question (in the Builder) will determine the format in which you should enter the date. String dates will also be parsed and converted into the correct object.

Read more about these settings here.

// Single date as an object:
  {
    "date":"02/08/2013",
    "hours":11,
    "minutes":47,
    "am_pm":"pm"
  }

// Single date as string:
"03/28/2014 10:30pm"

// From-to date, all-day, as an object:
{
  "date":"02/08/2013",
  "to":{
    "date":"02/11/2013"
  },
  "all_day":true
}

// From-to date, all-day, as a string:
"02/08/2013 to 02/11/2013"

// From-to date, specific times, as an object:
{
  "date":"02/08/2013",
  "hours":5,
  "minutes":0,
  "am_pm":"pm",
  "to":{
    "date":"02/11/2013",
    "hours":3,
    "minutes":0,
    "am_pm":"pm"
  }
}

// From-to date, specific times, as a string:
"02/08/2013 5:00pm to 02/11/2013 3:00pm"

// Time-only, as an object:
{
  "hours":2,
  "minutes":0,
  "am_pm":"pm"
}

// Time-only, as a string:
"2:00pm"

Address

Address fields are stored as objects with string values for street, street2, city, state, zip code, and, if international, country.

The settings which determine this format are set in the Builder and explained in further detail here.

// US address
{
  "street": "123 Fake St",
  "street2": "Apt 2",
  "city": "Amonate",
  "state": "VA",
  "zip": "24601"
}

// International address with country
{
  "country": "United States",
  "zip": "24601",
  "state": "VA",
  "city": "Amonate",
  "street2": "Apt 2",
  "street": "123 Fake St., Apt 2"
}

// Latitude and Longitude
{
  "latitude": "20.9140114",
  "longitude": "-100.7465256"
}

Link

Link fields are stored as objects with a URL and, if applicable, a label.

{
  "url":"https://www.knack.com",
  "label":"Knack"
}

Rich Text

Rich text fields are stored as strings.

"<h1>I'm a Title</h1><p>I'm some <strong>bold</strong> text</p>"

Currency

Currency fields are stored as numbers (note that the type of currency is therefore not included).

9.99

Auto Increment

Auto increment fields are stored as numbers. Note that auto increment fields are read-only.

1081

Rating

Rating fields are stored as numbers.

4.5

Timer

Timer fields are stored as an object with an array, "times", which consists of of an object for the "from" and "to" time, each.

{
  "times":[
    {
      "from":{
        "date":"02/09/2013",
        "hours":"04",
        "minutes":"45",
        "am_pm":"PM"
      },
      "to":{
        "date":"02/09/2013",
        "hours":"05",
        "minutes":"45",
        "am_pm":"PM"
      }
    }
  ]
}

Formula

Formulas - counts, sums, etc. - are stored as numbers. Note that formula fields are read-only.

25

Connection

Connections are stored as arrays of record IDs (strings), even when there is only one connected record. Each of these is the ID of a record of the object to which this field connects.

// More than one connected record
["4fea069e9e8246001d000698", "4fea069e9e8246001d000699"]

// One connected record
["4fea069e9e8246001d000699"]

Image

Image fields are stored as objects with their ID, application ID, file name, thumbnail URL, and other information. Read more about uploading images here.

{
  "id": "5579d9b1ca0f5a3f09efd93d",
  "application_id": "557786eacc034e367eb71e79",
  "s3": true,
  "type": "image",
  "filename": "logo.png",
  "url": "http://assets.knack.com/assets/5579d9b1ca0f5a3f09efd93d/original/logo.png",
  "thumb_url": "http://assets.knack.com/assets/5579d9b1ca0f5a3f09efd93d/thumb/logo.png",
  "size": 3588
}

File

Files are stored just like images. Read more about uploading files here.

{
  "id": "5579dde5ca0f5a3f09efd93f",
  "application_id": "557786eacc034e367eb71e79",
  "s3": true,
  "type": "file",
  "filename": "dates.csv",
  "url": "http://assets.knack.com/assets/5579dde5ca0f5a3f09efd93f/original/dates.csv",
  "thumb_url": "http://assets.knack.com/assets/5579dde5ca0f5a3f09efd93f/thumb/dates.csv",
  "size": 721
}