# Field Representation

The following guidelines apply for the values of object fields in the API (see [Field Types](https://docs.journeyapps.com/reference/build/data-model-configuration/model/field) for the full list of field types supported by JourneyApps).

<table><thead><tr><th width="199.33333333333331">Type</th><th>Format returned in API response</th><th>Format accepted for create and update</th></tr></thead><tbody><tr><td><code>text</code></td><td>The text in standard JSON. Example: <code>"Nokia"</code></td><td>Any string in standard JSON format. Example: <code>"Nokia"</code></td></tr><tr><td><code>integer</code></td><td>The number in standard JSON format. Example: <code>42</code>.</td><td>Any integer in standard JSON format. Example: <code>42</code>.</td></tr><tr><td><code>number</code></td><td>The number in standard JSON format. Example: <code>3.1428</code>.</td><td>Any decimal number in standard JSON format. Example: <code>3.1428</code>.</td></tr><tr><td><code>date</code></td><td>A date in the format <code>YYYY-MM-DD</code>, as defined by the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> specification. Example: <code>"2016-02-27"</code>.</td><td>Any valid date according to the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> specification. Any time or timezone components will be stripped. The <code>YYYY-MM-DD</code> format is recommended. Example: <code>"2016-02-27"</code></td></tr><tr><td><code>datetime</code></td><td>A date and time in the format <code>YYYY-MM-DDTHH:MM:SSZ</code>, as defined by the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> specification. Note that the time is specified in the UTC/GMT timezone. Example: <code>"2016-02-22T14:00:53Z"</code>.</td><td>Any valid date and time according to the <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a> specification. The <code>YYYY-MM-DDTHH:MM:SSZ</code> format is recommended. Example: <code>"2016-02-22T14:00:53Z".</code></td></tr><tr><td><code>single-choice</code></td><td>The key and display label of option. Example: <code>{"key": "soccer", "display": "Soccer"}</code></td><td>The string key of the option. Example: <code>"soccer"</code></td></tr><tr><td><code>single-choice-integer</code></td><td>The key and display label of option. Example: <code>{"key": 3, "display": "Soccer"}</code></td><td>The integer key of the option. Example: <code>3</code></td></tr><tr><td><code>boolean</code></td><td>The key and display label of option. Example: <code>{"key": true, "display": "Yes"}</code></td><td>The boolean key of the option. Example: <code>true</code></td></tr><tr><td><code>multiple-choice</code></td><td>An array of keys and display labels of the selected options. Example: <code>[{"key": "soccer", "display": "Soccer"}, {"key": "tennis", "display": "Tennis"}]</code></td><td>An array of keys, as explained above. Example: <code>["soccer", "tennis"]</code>.</td></tr><tr><td><code>multiple-choice-integer</code></td><td>An array of keys and display labels of the selected options. Example: <code>[{"key": 3, "display": "Soccer"}, {"key": 4, "display": "Tennis"}]</code></td><td>An array of keys, as explained above. Example: <code>[3, 4]</code>.</td></tr><tr><td><code>location</code></td><td>Hash with fields <em>latitude</em>, <em>longitude</em>, <em>altitude</em>, <em>horizontal_accuracy</em>, <em>vertical_accuracy</em> and <em>timestamp</em>. Note that <em>altitude</em> and <em>vertical_accuracy</em> are typically not reported by mobile devices, and only <em>latitude</em> and longitude can currently be edited on the JourneyApps Backend data browser. The <em>timestamp</em> is automatically populated when the location is captured.<br><br>See: <a href="#location-api-response-example">Location API Response Example</a></td><td>A hash with fields <em>latitude</em> and <em>longitude</em> (both decimal numbers), and optionally <em>altitude</em>, <em>horizontal_accuracy</em>, <em>vertical_accuracy</em> (all decimal numbers) and <em>timestamp</em> (a date and time in the format <code>YYYY-MM-DDTHH:MM:SSZ</code>, as defined by <a href="http://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>). Leaving the <em>timestamp</em> blank will cause the current time to be used. If you update an existing GPS <em>location</em> and omit the <em>altitude</em>, <em>horizontal_accuracy</em> or <em>vertical_accuracy</em> fields, any existing values in those fields will be set to <code>null</code>.<br><br>See: <a href="#location-api-update-object-example">Location API Update Object Example</a></td></tr><tr><td><code>attachment</code></td><td>A hash with fields <em>state</em>, <em>id</em> and <em>original</em>. The attachment's object id is a separate field, where the key is the attachment's field name plus <code>_id</code>.<br><br>See: <a href="#attachment-api-response-example">Attachment API Response Example</a></td><td>A hash with fields <em>base64</em>, containing the <a href="http://en.wikipedia.org/wiki/Base64">Base64</a> representation of the attachment file, and <em>filename</em>, containing the name of the file.<br><br>See: <a href="#attachment-api-update-object-example">Attachment API Update Object Example</a></td></tr><tr><td>Photos</td><td>A hash with fields <em>state</em>, <em>thumbnail</em>, <em>fullscreen</em> and <em>original</em>. The photo's object id is a separate field, where the key is the photo's field name plus <code>_id</code>.<br><br>See: <a href="#photos-api-response-example">Photos API Response Example</a></td><td>A hash with fields <em>base64</em>, containing the <a href="http://en.wikipedia.org/wiki/Base64">Base64</a> representation of the attachment file, and <em>filename</em>, containing the name of the file.<br><br>See: <a href="#photos-and-signatures-api-update-object-example">Photos and signatures API Update Object Example</a></td></tr><tr><td>Signatures</td><td>A hash with fields <em>state</em>, <em>thumbnail</em>, <em>fullscreen</em>, <em>original</em> and <em>svg</em>. The signature's object id is a separate field, where the key is the signature's field name plus <code>_id</code>.<br><br>See: <a href="#signatures-api-response-example">Signatures API Response Example</a></td><td>A hash with fields <em>base64</em>, containing the <a href="http://en.wikipedia.org/wiki/Base64">Base64</a> representation of the attachment file, and <em>filename</em>, containing the name of the file.<br><br>See: <a href="#photos-and-signatures-api-update-object-example">Photos and signatures API Update Object Example</a></td></tr><tr><td>Relationships</td><td>Relationships use the relationship name plus <code>_id</code> as the key, with the related object id as the value. Only <em>belongs to</em> relationships are included in the object itself, <em>has many</em> relationships should be queried and/or set from the other side of the relationship. Example: <code>building_id: "9913706a-179b-11e2-aaff-0026189d9dc0"</code>.</td><td>The same format is used for setting relationships. Example: <code>building_id: "9913706a-179b-11e2-aaff-0026189d9dc0"</code>.</td></tr></tbody></table>

### Examples

#### Location API Response Example

```json
{
  "latitude": -33.913147447989644,
  "longitude": 18.882385137695337,
  "altitude": null,
  "horizontal_accuracy": null,
  "vertical_accuracy": null,
  "timestamp": "2013-02-22T14:00:53Z"
}
```

#### Location API Update Object Example

```json
{
  "latitude": -33.913147447989644,
  "longitude": 18.882385137695337,
  "altitude": 16.43133544921875,
  "horizontal_accuracy": 10.0,
  "vertical_accuracy": 6.0,
  "timestamp": "2014-06-22T13:45:39Z"
}
```

#### Attachment API Response Example

```json
"sample_file_id": "ffca93d4-690c-4563-9d38-42c97b51443b",
"sample_file": {
    "state": "uploaded",
    "original": "https://run.journeyapps.com/media/W1siZiI/sample.pdf?sha=ee3b"
}
```

#### Attachment API Update Object Example

```json
sample_file: {
    "base64": "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
    "filename": "cover-letter.pdf"
}
```

{% hint style="info" %}
**Note**: `base64` must not contain any newline characters.

Only the following characters are allowed in `filename`:

* Lowercase alphanumeric characters
* Under score (`_`), hyphen (`-`), period (`.`) and space ( )
  {% endhint %}

#### Photos API Response Example

```json
"sample_photo_id": "ffca93d4-690c-4563-9d38-42c97b51443b",
"sample_photo": {
    "state": "uploaded",
    "thumbnail": "https://run.journeyapps.com/media/W1siZd/photo-2021Z.jpg?sha=9b16",
    "fullscreen": "https://run.journeyapps.com/media/W1siZQ/photo-2021Z.jpg?sha=70dc",
    "original": "https://run.journeyapps.com/media/W1siZw/photo-2021Z.jpg?sha=5085"
}
```

**Note**: The *state* field can be `uploaded`,`pending`, `missing`, or `untrusted`. The *thumbnail*, *fullscreen* and *original* fields are only present if state is `uploaded`.

#### Signatures API Response Example

```json
"sample_signature_id": "ffca93d4-690c-4563-9d38-42c97b51443b",
"sample_signature": {
    "state": "uploaded",
    "thumbnail": "https://run.journeyapps.com/media/W1siK0/signature-2021Z.svg?sha=48b3",
    "fullscreen": "https://run.journeyapps.com/media/W1siZiIsI/signature-2021Z.svg?sha=7231",
    "original": "https://run.journeyapps.com/media/W1siZiIsI/signature-2021Z.svg?sha=7231",
    "svg": "https://run.journeyapps.com/media/W1siZQ/signature-2021Z.svg?sha=28f"
}
```

**Note**: The *state* field can be `uploaded` or `pending`. The *thumbnail*, *fullscreen*, *original* and *svg* fields are only present if state is `uploaded`.

#### Photos and signatures API Update Object Example

```json
photo: {
    "base64": "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==",
    "filename": "small-red-dot.png"
}
```

{% hint style="info" %}
**Note**: `base64` must not contain any newline characters.

Only the following characters are allowed in `filename`:

* Lowercase alphanumeric characters
* Under score (`_`), hyphen (`-`), period (`.`) and space ( )
  {% endhint %}

### Values Not Present

When retrieving objects, a field not present should be interpreted the same as a `null` value for that field. This applies to all field types, as well as relationships.

When updating an object with Update a Single Object, setting the field to `null` will clear that field. On the other hand, omitting the field will leave its value unchanged. This applies to all field types, as well as relationships.
