> ## Documentation Index
> Fetch the complete documentation index at: https://developers.fibery.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integration Schema types

> Learn how to map integration field types to Fibery Field types.

You can create your own [Integration templates](https://the.fibery.io/@public/User_Guide/Guide/Integration-templates-68) and sync data from any external system.

In terms of integration, a Fibery Field type is represented as pair of parameters in the integration schema:

* `type`
* `subType`

Below the list of available combinations.

<table className="schema-types-table">
  <colgroup>
    <col />

    <col />

    <col />

    <col />
  </colgroup>

  <thead>
    <tr>
      <th>Fibery field type</th>
      <th>Integration type</th>
      <th>subType</th>
      <th>Comments</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`fibery/decimal`</td>
      <td>`number`</td>

      <td />

      <td>
        <p>It's possible to apply number optional formatting though field configuration. Formatting is applied only for newly created fields. Formatting can be changed via default Fibery fields UI once field is created.</p>

        <p><strong>Money</strong></p>

        ```json theme={null}
        {
          "id": "amount",
          "name": "Amount",
          "type": "number",
          "format": {
            "format": "Money",
            "currencyCode": "EUR",
            "hasThousandSeparator": true,
            "precision": 2
          }
        }
        ```

        <p><strong>Percent</strong></p>

        ```json theme={null}
        {
          "id": "percent",
          "name": "Percent",
          "type": "number",
          "format": {
            "format": "Percent",
            "precision": 2
          }
        }
        ```

        <p><strong>Number</strong></p>

        ```json theme={null}
        {
          "id": "value",
          "name": "Value",
          "type": "number",
          "format": {
            "format": "Number",
            "unit": "ea",
            "hasThousandSeparator": true,
            "precision": 2
          }
        }
        ```
      </td>
    </tr>

    <tr>
      <td>`fibery/integer`</td>
      <td>`number`</td>
      <td>`integer`</td>

      <td />
    </tr>

    <tr>
      <td>`fibery/text`</td>
      <td>`text`</td>

      <td />

      <td>
        <p>It's possible to apply text optional formatting though field configuration. Formatting is applied only for newly created fields. Formatting can be changed via default Fibery fields UI once field is created.</p>

        <p><strong>Phone</strong></p>

        ```json theme={null}
        {
          "id": "phone",
          "name": "Phone",
          "type": "text",
          "format": {
            "format": "phone"
          }
        }
        ```
      </td>
    </tr>

    <tr>
      <td>`fibery/url`</td>
      <td>`text`</td>
      <td>`url`</td>

      <td />
    </tr>

    <tr>
      <td>`fibery/email`</td>
      <td>`text`</td>
      <td>`email`</td>

      <td />
    </tr>

    <tr>
      <td>`fibery/bool`</td>
      <td>`text`</td>
      <td>`boolean`</td>

      <td>
        <p>The conversion from text to boolean is as follows:</p>

        ```json theme={null}
        {
          "true": true,
          "yes": true,
          "on": true,
          "1": true,
          "false": false,
          "no": false,
          "off": false,
          "0": false,
          "checked": true,
          "": false
        }
        ```
      </td>
    </tr>

    <tr>
      <td className="schema-types-break">`fibery/date-range`</td>
      <td>`text`</td>
      <td className="schema-types-break">`date-range`</td>

      <td>
        <p>The value is a <strong>stringified</strong> object with <code>start</code> and <code>end</code> fields.</p>

        ```json theme={null}
        {
          "start": "2020-01-22",
          "end": "2020-08-19"
        }
        ```
      </td>
    </tr>

    <tr>
      <td className="schema-types-break">`fibery/date-time-range`</td>
      <td>`text`</td>
      <td className="schema-types-break">`date-time-range`</td>

      <td>
        <p>The value is a <strong>stringified</strong> object with <code>start</code> and <code>end</code> fields.</p>

        ```json theme={null}
        {
          "start": "2020-01-22T01:02:23.977Z",
          "end": "2020-08-18T06:02:23.977Z"
        }
        ```
      </td>
    </tr>

    <tr>
      <td className="schema-types-break">`Collaboration~Documents/Document`</td>
      <td>`text`</td>
      <td>`html`</td>
      <td>Replaces content of rich text field converting value from `html` format.</td>
    </tr>

    <tr>
      <td className="schema-types-break">`Collaboration~Documents/Document`</td>
      <td>`text`</td>
      <td>`md`</td>
      <td>Replaces content of rich text field converting value from `md` format.</td>
    </tr>

    <tr>
      <td>Icons extension</td>
      <td>`text`</td>
      <td>`icon`</td>
      <td>Can be used to set Icon of entity. At the moment it works only with Emojis. The value should be either a native emoji (i.e. 👋🏻) or its alias (i.e. `:wave::skin-tone-2:`).</td>
    </tr>

    <tr>
      <td>Single Select Enum</td>
      <td>`text`</td>
      <td>`single-select`</td>

      <td>
        <p>It's possible to specify options by adding <code>options</code> field into schema field configuration.</p>

        ```json theme={null}
        {
          "options": [
            {
              "name": "Open",
              "icon": "laughing",
              "color": "#f2e2f4"
            },
            {
              "name": "In Progress"
            },
            {
              "name": "Closed"
            }
          ]
        }
        ```

        <p>If <code>options</code> property is missing then the integration module will infer the options automatically based on your data.</p>
      </td>
    </tr>

    <tr>
      <td>Workflow</td>
      <td>`text`</td>
      <td>`workflow`</td>

      <td>
        <p>It's possible to specify options by adding <code>options</code> field into schema field configuration. Options must include record with <code>default: true</code> and <code>final: true</code> records. It could optionally include <code>type: "Not started" | "Started" | "Finished"</code>.</p>

        ```json theme={null}
        {
          "options": [
            {
              "name": "Open",
              "icon": "laughing",
              "color": "#f2e2f4",
              "default": true
            },
            {
              "name": "In Progress",
              "type": "Started"
            },
            {
              "final": true,
              "name": "Closed"
            }
          ]
        }
        ```

        <p>If <code>options</code> property is missing then the integration module will infer the options automatically based on your data, including start and final options.</p>
      </td>
    </tr>

    <tr>
      <td>Multi Select Enum</td>
      <td>`text` or `array[text]`</td>
      <td>`multi-select`</td>

      <td>
        <p>It's possible to specify options by adding <code>options</code> field into schema field configuration.</p>

        ```json theme={null}
        {
          "options": [
            {
              "name": "JS",
              "icon": "laughing",
              "color": "#f2e2f4"
            },
            {
              "name": "Java"
            },
            {
              "name": "Closure"
            }
          ]
        }
        ```

        <p>If <code>options</code> property is missing then the integration module will infer the options automatically based on your data.</p>

        <p>Values can be passed differently depending on <code>type</code> value. It can be either a JSON array <code>\["JS", "Java"]</code> of selected options or a comma-separated string of selected options <code>"JS,Java"</code>.</p>
      </td>
    </tr>

    <tr>
      <td>`fibery/date-time`</td>
      <td>`date`</td>

      <td />

      <td>Value format: `2020-01-22T01:02:23.977Z`.</td>
    </tr>

    <tr>
      <td>`fibery/date`</td>
      <td>`date`</td>
      <td>`day`</td>
      <td>Value format: `2020-08-22`.</td>
    </tr>

    <tr>
      <td>Files</td>
      <td>`array[text]` — for multiple files, `text` — for single file</td>
      <td>`file`</td>

      <td>
        <p>Array of links to files. The integration service will download files from the links and upload them into Fibery. If access to file content requires authentication then the url should be provided in special format via <code>app\://resource</code> and connector should implement <code>POST /api/v1/synchronizer/resource</code> endpoint. <a href="/guides/integrations/rest-endpoints">See here for more info</a>.</p>

        <p>By default, files are treated as unique by provided URL. So if file url is changed during next sync then previous file will be deleted and new file will be uploaded. Unfortunately, it's rather common practice to provide temporary file URL. In this case Fibery will be constantly remove and add the same file during each sync. Luckily, Fibery provides a way to add an unique key for each file. Connector developers may add a special query parameter <code>\_\_file-key</code> into file url. It's also works with authenticated access by adding the same query parameter (<code>\_\_file-key</code>).</p>

        <p>Example: <code>[https://myapp/files/temp-file-access-token?\_\_file-key=file-id](https://myapp/files/temp-file-access-token?__file-key=file-id)</code> and on next sync <code>[https://myapp/files/temp-file-access-token-2?\_\_file-key=file-id](https://myapp/files/temp-file-access-token-2?__file-key=file-id)</code>.</p>
      </td>
    </tr>

    <tr>
      <td>Avatar extension</td>
      <td>`text`</td>
      <td>`avatar`</td>
      <td>Link to file. Integration will download the file from the link and upload it into Fibery.</td>
    </tr>

    <tr>
      <td>`fibery/location`</td>
      <td>`text`</td>
      <td>`location`</td>

      <td>
        <p>Location field. Supported values are:</p>

        <p><strong>Coordinates</strong></p>

        ```
        40.123, -74.123
        40.123° N 74.123° W
        40° 7´ 22.8" N 74° 7´ 22.8" W
        40° 7.38’ , -74° 7.38’
        N40°7’22.8, W74°7’22.8"
        40°7’22.8"N, 74°7’22.8"W
        40 7 22.8, -74 7 22.8
        40.123 -74.123
        40.123°,-74.123°
        144442800, -266842800
        40.123N74.123W
        4007.38N7407.38W
        40°7’22.8"N, 74°7’22.8"W
        400722.8N740722.8W
        N 40 7.38 W 74 7.38
        40:7:23N,74:7:23W
        40:7:22.8N 74:7:22.8W
        40°7’23"N 74°7’23"W
        40°7’23" -74°7’23"
        40d 7’ 23" N 74d 7’ 23" W
        40.123N 74.123W
        40° 7.38, -74° 7.38
        ```

        <p><strong>Stringified JSON</strong></p>

        ```json theme={null}
        {
          "longitude": "52.2297",
          "latitude": "21.0122",
          "fullAddress": "Warsaw, Poland"
        }
        ```
      </td>
    </tr>
  </tbody>
</table>

## Special cases

### Title field

By default, the integration will use the Field with id `name` as the title field (equivalent to the Name Field in standard databases) but it is possible to override this by adding the `subType: title` annotation.

```json theme={null}
{
  "commitName": {
    "type": "text",
    "name": "Commit Name",
    "subType": "title"
  }
}
```

### People relations

```json theme={null}
{
  "project": {
    "id": {
      "name": "Id",
      "type": "id"
    },
    "owner": {
      "name": "Owner",
      "type": "text",
      "relation": {
        "kind": "native",
        "targetType": "fibery/user",
        "cardinality": "many-to-one",
        "targetName": "My Projects",
        "targetFieldId": "user/email"
      }
    },
    "assignees": {
      "name": "Assignees",
      "type": "array[text]",
      "relation": {
        "kind": "native",
        "targetType": "fibery/user",
        "cardinality": "many-to-many",
        "targetName": "Assigned To",
        "targetFieldId": "user/email"
      }
    }
  }
}
```

`targetFieldId` possible values:

* `user/email` - finds users by email address (case sensitive)
* in all other case will use `Name` field to find a user

### Integration relations

Let's assume that there are two types: `Branch` and `Project`. So `Project` includes many `Branches`. It can be configured in the following way

```json theme={null}
{
  "project": {
    "id": {
      "name": "Id",
      "type": "id"
    }
    // other fields
  },
  "branch": {
    "id": {
      "name": "Id",
      "type": "id"
    },
    "projectId": {
      "name": "Project Id",
      "type": "text",
      "relation": {
        "cardinality": "many-to-one",
        "name": "Project",
        "targetType": "project",
        "targetFieldId": "id",
        "targetName": "Branches"
      }
    }
    // other fields
  }
}
```

In this case, the integration will create following fields:

* `Project Id` field with `text` type in the `Branch` type. This field is hidden field and used for auto-linking relations.
* `Project` field in `Branch` type. It's a relation field to the `Project` type.
* `Branches` collection field in the `Project` type. It's another side of `Project` → `Branch` relation.

Possible cardinalities:

* `many-to-one`
* `many-to-many`
* `one-to-one`
