> For the complete documentation index, see [llms.txt](https://docs.formsort.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.formsort.com/json-schemas.md).

# JSON schemas

Every variant revision is available as a [JSON schema](https://json-schema.org/) (Draft 07), which describes the possible answer payloads that a flow may produce. Exporting this JSON allows you to write validators on your end, or understand the possible payloads that a flow may produce using the many tools that use the JSON Schema format.

### Sample form schemas

Each of these examples shows how a form that only collected a single answer would be respresented in a JSON schema

{% tabs %}
{% tab title="string" %}

```javascript
{
  '$schema': 'http://json-schema.org/draft-07/schema#',
  'type': 'object',
  'properties': {
    'user_fname': {
      'type': 'string',
      'description': 'The first name of the user'
    }
  }
}
```

{% endtab %}

{% tab title="select (single)" %}

```javascript
{
  '$schema': 'http://json-schema.org/draft-07/schema#',
  'type': 'object',
  'properties': {
    'A choice': {
      'oneOf': [
        {'const': 'Value A'},
        {'const': 'Value B'}
      ]
    }
  }
}
```

{% endtab %}

{% tab title="select (multiple)" %}

```javascript
{
  '$schema': 'http://json-schema.org/draft-07/schema#',
  'type': 'object',
  'properties': {
    'A choice': {
      'type': 'array',
      'items': {
        'oneOf': [
          {'const': 'Value A'},
          {'const': 'Value B'}
        ]
      }
    }
  }
}
```

{% endtab %}

{% tab title="address" %}
Note that **address** is the only current object answer type with a distinct object type definition. Custom object types will be supported in the future.

```javascript
{
   "$schema":"http://json-schema.org/draft-07/schema#",
   "type":"object",
   "definitions":{
      "address":{
         "type":"object",
         "properties":{
            "raw":{
               "type":"string"
            },
            "address_1":{
               "type":"string"
            },
            "address_2":{
               "type":"string"
            },
            "city":{
               "type":"string"
            },
            "state":{
               "type":"string"
            },
            "postal_code":{
               "type":"string"
            },
            "country":{
               "type":"string"
            }
         },
         "required":[
            "address_1",
            "city",
            "state",
            "postal_code"
         ]
      }
   },
   "properties":{
      "An address":{
         "type":"array",
         "items":{
            "$ref":"#/definitions/address"
         }
      }
   }
}
```

{% endtab %}
{% endtabs %}

Note that none of the root object properties are marked required: if you are receiving events with answers on every step, you may receive partial payloads, so you cannot assume the presence of any answer.

### Accessing the JSON schema for a flow

The JSON schema for a given flow, variant, and revision combination is available at the following URL:

```
https://variant.formsort.com/flow-api/client/{CLIENT_ID}/flow/{FLOW_LABEL}/variant/{VARIANT_LABEL}/revision/{VARIANT_REVISION_UUID}/schema.json
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.formsort.com/json-schemas.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
