Skip to Content
Docs

Version 1 JSON Schemas

Copy the complete JSON Schemas for a Worker's Compose configuration and for managed definitions or organization templates.

These JSON Schemas describe format version 1 of the x-contextual Specification. Copy a complete code block into the named file and use a validator that supports JSON Schema Draft 2020-12.

The schemas check structure. They do not enforce every validation rule, confirm that referenced images exist, or check runtime readiness. A schema-valid configuration can still be rejected by the platform.

The $id values identify the schemas. Copy the JSON below rather than relying on those identifiers as download URLs. Neither schema uses external $ref dependencies.

Compose Schema

Use compose.schema.json for the Compose configuration submitted to the platform. It describes supported document and service fields, including x-contextual settings, ports, dependencies, health checks, volumes, configs, secrets, and networks.

Show Complete compose.schema.json
compose.schema.json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "patternProperties": {
    "^x-": {}
  },
  "additionalProperties": false,
  "type": "object",
  "properties": {
    "name": {
      "type": "string"
    },
    "services": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "maxLength": 63,
        "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
      },
      "additionalProperties": {
        "patternProperties": {
          "^x-": {}
        },
        "additionalProperties": false,
        "type": "object",
        "properties": {
          "image": {
            "type": "string"
          },
          "command": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "entrypoint": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "environment": {
            "type": "object",
            "propertyNames": {
              "type": "string",
              "pattern": "^[A-Za-z_][A-Za-z0-9_]*$"
            },
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "ports": {
            "type": "array",
            "items": {
              "patternProperties": {
                "^x-": {}
              },
              "additionalProperties": false,
              "type": "object",
              "properties": {
                "target": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 65535
                },
                "published": {
                  "type": "string"
                },
                "protocol": {
                  "type": "string",
                  "const": "tcp"
                },
                "mode": {
                  "type": "string",
                  "const": "ingress"
                }
              },
              "required": [
                "target"
              ]
            }
          },
          "expose": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^\\d{1,5}(\\/tcp)?$"
            }
          },
          "depends_on": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "patternProperties": {
                "^x-": {}
              },
              "additionalProperties": false,
              "type": "object",
              "properties": {
                "condition": {
                  "type": "string",
                  "enum": [
                    "service_started",
                    "service_healthy",
                    "service_completed_successfully"
                  ]
                },
                "required": {
                  "type": "boolean",
                  "const": true
                },
                "restart": {
                  "type": "boolean",
                  "const": false
                }
              },
              "required": [
                "condition"
              ]
            }
          },
          "healthcheck": {
            "patternProperties": {
              "^x-": {}
            },
            "additionalProperties": false,
            "type": "object",
            "properties": {
              "test": {
                "minItems": 1,
                "maxItems": 64,
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "interval": {
                "type": "string"
              },
              "timeout": {
                "type": "string"
              },
              "retries": {
                "type": "integer",
                "minimum": 1,
                "maximum": 120
              },
              "start_period": {
                "type": "string"
              },
              "start_interval": {
                "type": "string"
              },
              "disable": {
                "type": "boolean"
              }
            }
          },
          "volumes": {
            "type": "array",
            "items": {
              "patternProperties": {
                "^x-": {}
              },
              "additionalProperties": false,
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "volume"
                },
                "source": {
                  "type": "string"
                },
                "target": {
                  "type": "string",
                  "pattern": "^\\/.*"
                },
                "read_only": {
                  "type": "boolean"
                },
                "volume": {
                  "patternProperties": {
                    "^x-": {}
                  },
                  "additionalProperties": false,
                  "type": "object",
                  "properties": {
                    "nocopy": {
                      "type": "boolean",
                      "const": true
                    },
                    "subpath": {
                      "type": "string",
                      "pattern": "^(?!.*(?:^|\\/)\\.{1,2}(?:\\/|$))[^/][^\\\\]*$"
                    }
                  }
                }
              },
              "required": [
                "type",
                "source",
                "target"
              ]
            }
          },
          "configs": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(?!\\.$)(?!\\.\\.)[A-Za-z0-9._-]{1,253}$"
                },
                {
                  "patternProperties": {
                    "^x-": {}
                  },
                  "additionalProperties": false,
                  "type": "object",
                  "properties": {
                    "source": {
                      "type": "string",
                      "pattern": "^(?!\\.$)(?!\\.\\.)[A-Za-z0-9._-]{1,253}$"
                    },
                    "target": {
                      "type": "string",
                      "minLength": 1
                    },
                    "mode": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 511
                    }
                  },
                  "required": [
                    "source"
                  ]
                }
              ]
            }
          },
          "secrets": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^(?!\\.$)(?!\\.\\.)[A-Za-z0-9._-]{1,253}$"
                },
                {
                  "patternProperties": {
                    "^x-": {}
                  },
                  "additionalProperties": false,
                  "type": "object",
                  "properties": {
                    "source": {
                      "type": "string",
                      "pattern": "^(?!\\.$)(?!\\.\\.)[A-Za-z0-9._-]{1,253}$"
                    },
                    "target": {
                      "type": "string",
                      "minLength": 1
                    },
                    "mode": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 511
                    }
                  },
                  "required": [
                    "source"
                  ]
                }
              ]
            }
          },
          "working_dir": {
            "type": "string",
            "pattern": "^\\/.*"
          },
          "networks": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "null"
            }
          },
          "x-contextual": {
            "patternProperties": {
              "^x-": {}
            },
            "additionalProperties": false,
            "type": "object",
            "properties": {
              "public": {
                "anyOf": [
                  {
                    "type": "boolean"
                  },
                  {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 65535
                  }
                ]
              },
              "container_type": {
                "type": "string",
                "enum": [
                  "primary",
                  "sidecar",
                  "init"
                ]
              },
              "http_healthcheck": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string",
                    "maxLength": 2048,
                    "pattern": "^\\/.*"
                  },
                  "port": {
                    "type": "integer",
                    "minimum": 1024,
                    "maximum": 65535
                  }
                },
                "required": [
                  "path",
                  "port"
                ],
                "additionalProperties": false
              },
              "features": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "messaging",
                    "native-object-api",
                    "logging",
                    "platform-services",
                    "messaging-producer",
                    "keda"
                  ]
                }
              },
              "scaling": {
                "type": "object",
                "properties": {
                  "maxReplicas": {
                    "default": 1,
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100
                  },
                  "pollingInterval": {
                    "default": 20,
                    "type": "integer",
                    "minimum": 5,
                    "maximum": 9007199254740991
                  },
                  "minReplicas": {
                    "default": 0,
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 100
                  },
                  "cooldownPeriod": {
                    "default": 5,
                    "type": "number",
                    "minimum": 0
                  },
                  "lagThreshold": {
                    "default": 100,
                    "type": "number",
                    "minimum": 2
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "required": [
          "image"
        ]
      }
    },
    "volumes": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "maxLength": 63,
        "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
      },
      "additionalProperties": {
        "patternProperties": {
          "^x-": {}
        },
        "additionalProperties": false,
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        }
      }
    },
    "configs": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^(?!\\.$)(?!\\.\\.)[A-Za-z0-9._-]{1,253}$"
      },
      "additionalProperties": {
        "patternProperties": {
          "^x-": {}
        },
        "additionalProperties": false,
        "type": "object",
        "properties": {
          "content": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "file": {
            "not": {}
          },
          "environment": {
            "not": {}
          }
        },
        "required": [
          "content"
        ]
      }
    },
    "secrets": {
      "type": "object",
      "propertyNames": {
        "type": "string",
        "pattern": "^(?!\\.$)(?!\\.\\.)[A-Za-z0-9._-]{1,253}$"
      },
      "additionalProperties": {
        "patternProperties": {
          "^x-": {}
        },
        "additionalProperties": false,
        "type": "object",
        "properties": {
          "environment": {
            "type": "string",
            "pattern": "^[A-Z_][A-Z0-9_]*$"
          },
          "name": {
            "type": "string"
          },
          "file": {
            "not": {}
          }
        },
        "required": [
          "environment"
        ]
      }
    },
    "networks": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "x-contextual": {
      "patternProperties": {
        "^x-": {}
      },
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "version": {
          "type": "number",
          "const": 1
        }
      },
      "required": [
        "version"
      ]
    }
  },
  "required": [
    "services",
    "x-contextual"
  ],
  "$id": "https://contextual.io/schemas/x-contextual/v1/compose.schema.json",
  "description": "A Contextual Worker's Compose file, with x-contextual at its top and on its services.",
  "$comment": "The rules JSON Schema can't express are in the x-contextual Specification."
}

Managed-Definition Schema

Use managed-definition.schema.json for a managed definition or organization template before its options are substituted. It describes the x-contextual.version and x-contextual.options declarations and the service image fields. Follow the specification's option rules as well.

The platform substitutes selected option values and validates the resulting Compose configuration. The managed-definition schema alone does not check the rendered configuration.

Show Complete managed-definition.schema.json
managed-definition.schema.json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "services": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {
        "type": "object",
        "properties": {
          "image": {
            "type": "string"
          }
        },
        "additionalProperties": {}
      }
    },
    "x-contextual": {
      "patternProperties": {
        "^x-": {}
      },
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "version": {
          "type": "number",
          "const": 1
        },
        "options": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {
            "patternProperties": {
              "^x-": {}
            },
            "additionalProperties": false,
            "type": "object",
            "properties": {
              "description": {
                "type": "string"
              },
              "required": {
                "type": "boolean"
              },
              "native_object": {
                "type": "string",
                "allOf": [
                  {
                    "pattern": "^[a-z0-9_-]+"
                  },
                  {
                    "pattern": "^[a-z0-9_-]+$"
                  }
                ]
              }
            }
          }
        }
      },
      "required": [
        "version"
      ]
    }
  },
  "required": [
    "services",
    "x-contextual"
  ],
  "additionalProperties": {},
  "$id": "https://contextual.io/schemas/x-contextual/v1/managed-definition.schema.json",
  "description": "A managed Worker definition or template, with its options declared in x-contextual.",
  "$comment": "The rules JSON Schema can't express are in the x-contextual Specification."
}