# Manifest schema

> Every field of manifest version 1 and its constraints, from the JSON Schema the platform validates against.

Source: https://developers-staging.foodpilot.tech/reference/manifest-schema

What each field is for, with an example, is in [The manifest](/build/manifest). A manifest that does not match this schema is refused when you save a version. Submission adds rules of its own: see [The review](/launch/review).

## Fields

| Field | Required | Value |
|---|---|---|
| `manifest_version` | Yes | always `1` |
| `name` | Yes | string, at most 100 characters |
| `handle` | Yes | string, matching `^[a-z0-9]+(-[a-z0-9]+)*$`, at most 64 characters |
| `install_url` | Yes | URL: HTTPS, or HTTP on localhost, 127.0.0.1 or [::1]; no fragment, no `*`; at most 2048 characters |
| `app_url` | No | URL: HTTPS, or HTTP on localhost, 127.0.0.1 or [::1]; no fragment, no `*`; at most 2048 characters |
| `redirect_urls` | Yes | list of URL: HTTPS, or HTTP on localhost, 127.0.0.1 or [::1]; no fragment, no `*`; at most 2048 characters, at least 1, at most 10, no duplicates |
| `scopes` | Yes | list of one of `read_products`, `write_products`, `read_ingredients`, `write_ingredients`, `read_packagings`, `write_packagings`, `read_questionnaires`, `write_questionnaires`, `read_organizations`, no duplicates |
| `embedded` | No | boolean |
| `navigation` | No | list of object, with `label`, `path`, at most 10 |
| `extensions` | No | list of object, with `slot`, `label`, `path`, at most 10 |
| `support_url` | No | URL: HTTPS, or HTTP on localhost, 127.0.0.1 or [::1]; no fragment, no `*`; at most 2048 characters |
| `privacy_url` | No | URL: HTTPS, or HTTP on localhost, 127.0.0.1 or [::1]; no fragment, no `*`; at most 2048 characters |
| `webhooks` | No | list of object, with `topic`, `uri`, at most 20 |

### Each entry of `navigation`

| Field | Required | Value |
|---|---|---|
| `label` | Yes | object, with `en`, `fr` |
| `path` | Yes | string, matching the pattern of the JSON Schema, at most 200 characters |

### Each entry of `extensions`

| Field | Required | Value |
|---|---|---|
| `slot` | Yes | one of `product.details.tab`, `organization.overview.card` |
| `label` | Yes | object, with `en`, `fr` |
| `path` | Yes | string, matching the pattern of the JSON Schema, at most 200 characters |

### Each entry of `webhooks`

| Field | Required | Value |
|---|---|---|
| `topic` | Yes | one of `scores/updated`, `questionnaires/answered`, `app/scopes_updated`, `app/uninstalled`, `app_subscription/updated`, `app_charge/updated` |
| `uri` | Yes | HTTPS URL; no fragment, no `*`; at most 2048 characters |

## Conditions

- When `navigation` is present: `embedded` must be `true`, `app_url` is required.
- When `extensions` is present: `embedded` must be `true`, `app_url` is required.
- When `embedded` is `true`: `app_url` is required.

## The JSON Schema

<details>
<summary>manifest.v1.schema.json</summary>

```json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://dev.positive-app.fr/schemas/manifest.v1.schema.json",
  "title": "Foodpilot marketplace app manifest, version 1",
  "type": "object",
  "required": [
    "manifest_version",
    "name",
    "handle",
    "install_url",
    "redirect_urls",
    "scopes"
  ],
  "properties": {
    "manifest_version": {
      "const": 1
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "handle": {
      "type": "string",
      "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
      "maxLength": 64
    },
    "install_url": {
      "$ref": "#/definitions/appUrl"
    },
    "app_url": {
      "$ref": "#/definitions/appUrl"
    },
    "redirect_urls": {
      "type": "array",
      "minItems": 1,
      "maxItems": 10,
      "uniqueItems": true,
      "items": {
        "$ref": "#/definitions/appUrl"
      }
    },
    "scopes": {
      "type": "array",
      "uniqueItems": true,
      "items": {
        "enum": [
          "read_products",
          "write_products",
          "read_ingredients",
          "write_ingredients",
          "read_packagings",
          "write_packagings",
          "read_questionnaires",
          "write_questionnaires",
          "read_organizations"
        ]
      }
    },
    "embedded": {
      "type": "boolean"
    },
    "navigation": {
      "type": "array",
      "maxItems": 10,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label",
          "path"
        ],
        "properties": {
          "label": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "en"
            ],
            "properties": {
              "en": {
                "$ref": "#/definitions/navLabel"
              },
              "fr": {
                "$ref": "#/definitions/navLabel"
              }
            }
          },
          "path": {
            "type": "string",
            "maxLength": 200,
            "pattern": "^(?!.*/\\.\\.?(/|$))/[A-Za-z0-9._~!$&'()*+,=:@%/-]*$",
            "not": {
              "pattern": "%(2[eEfF]|5[cC])|//"
            }
          }
        }
      }
    },
    "extensions": {
      "type": "array",
      "maxItems": 10,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "slot",
          "path",
          "label"
        ],
        "properties": {
          "slot": {
            "enum": [
              "product.details.tab",
              "organization.overview.card"
            ]
          },
          "label": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "en"
            ],
            "properties": {
              "en": {
                "$ref": "#/definitions/navLabel"
              },
              "fr": {
                "$ref": "#/definitions/navLabel"
              }
            }
          },
          "path": {
            "type": "string",
            "maxLength": 200,
            "pattern": "^(?!.*/\\.\\.?(/|$))/[A-Za-z0-9._~!$&'()*+,=:@%/-]*$",
            "not": {
              "pattern": "%(2[eEfF]|5[cC])|//"
            }
          }
        }
      }
    },
    "support_url": {
      "$ref": "#/definitions/appUrl"
    },
    "privacy_url": {
      "$ref": "#/definitions/appUrl"
    },
    "webhooks": {
      "type": "array",
      "maxItems": 20,
      "items": {
        "type": "object",
        "required": [
          "topic",
          "uri"
        ],
        "additionalProperties": false,
        "properties": {
          "topic": {
            "enum": [
              "scores/updated",
              "questionnaires/answered",
              "app/scopes_updated",
              "app/uninstalled",
              "app_subscription/updated",
              "app_charge/updated"
            ]
          },
          "uri": {
            "$ref": "#/definitions/httpsUrl"
          }
        }
      }
    }
  },
  "definitions": {
    "appUrl": {
      "type": "string",
      "maxLength": 2048,
      "pattern": "^(https://[^\\s/#*@?:]+(:[0-9]{1,5})?|http://(localhost|127\\.0\\.0\\.1|\\[::1\\])(:[0-9]{1,5})?)(/[^\\s#*]*)?$"
    },
    "httpsUrl": {
      "type": "string",
      "maxLength": 2048,
      "pattern": "^https://[^\\s/#*@?:]+(:[0-9]{1,5})?(/[^\\s#*]*)?$"
    },
    "navLabel": {
      "type": "string",
      "minLength": 1,
      "maxLength": 40
    }
  },
  "allOf": [
    {
      "if": {
        "required": [
          "navigation"
        ]
      },
      "then": {
        "required": [
          "embedded",
          "app_url"
        ],
        "properties": {
          "embedded": {
            "const": true
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "extensions"
        ]
      },
      "then": {
        "required": [
          "embedded",
          "app_url"
        ],
        "properties": {
          "embedded": {
            "const": true
          }
        }
      }
    },
    {
      "if": {
        "required": [
          "embedded"
        ],
        "properties": {
          "embedded": {
            "const": true
          }
        }
      },
      "then": {
        "required": [
          "app_url"
        ]
      }
    }
  ]
}
```

</details>
