{
  "$schema": "https://json-schema.org/draft/2019-09/schema",
  "$id": "https://www.krakend.io/schema/v2.13/backend.json",
  "title": "Backend Object",
  "description": "A backend object is an array of all the services that an endpoint connects to. It defines the list of hostnames that connects to and the URL to send or receive the data.",
  "type": "object",
  "required": [ "url_pattern" ],
  "properties": {
    "allow": {
      "title": "Allow (data manipulation)",
      "description": "**Only return the fields in the list**. Only the matching fields (case-sensitive) are returned in the final response. Use a dot `.` separator to define nested attributes, e.g.: `a.b` returns `{\"a\":{\"b\": true}}` \n\nSee: https://www.krakend.io/docs/backends/data-manipulation/",
      "examples": [
        [ "user_id", "field1.subfield2" ]
      ],
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string"
      }
    },
    "deny": {
      "title": "Deny (data manipulation)",
      "description": "**Don't return the fields in the list**. All matching fields (case-sensitive) defined in the list, are removed from the response. Use a dot `.` separator to define nested attributes, e.g.: `a.b` removes `{\"a\":{\"b\": true}}`.\n\nSee: https://www.krakend.io/docs/backends/data-manipulation/",
      "examples": [
        [ "token", "CVV", "password" ]
      ],
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string"
      }
    },
    "disable_host_sanitize": {
      "title": "Disable host sanitize",
      "description": "Set it to `true` when the host doesn't need to be checked for an HTTP protocol. This is the case of `sd=dns` or when using other protocols like `amqp://`, `nats://`, `kafka://`, etc. When set to true, and the protocol is not HTTP, KrakenD fails with an `invalid host` error.",
      "default": false,
      "type": "boolean"
    },
    "encoding": {
      "title": "Backend Encoding",
      "description": "Defines your [needed encoding](https://www.krakend.io/docs/backends/supported-encodings/) to set how to parse the response. Defaults to the value of its endpoint's `encoding`, or to `json` if not defined anywhere else. Notice that `fast-json` and `yaml` are for Enterprise only.\n\nSee: https://www.krakend.io/docs/backends/supported-encodings/",
      "default": "json",
      "enum": [
        "json",
        "safejson",
        "fast-json",
        "xml",
        "rss",
        "string",
        "no-op",
        "yaml"
      ]
    },
    "extra_config": {
      "title": "Backend Extra configuration",
      "description": "When there is additional configuration related to a specific component or middleware (like a circuit breaker, rate limit, etc.), it is declared under this section.",
      "$ref": "backend_extra_config.json",
      "type": "object"
    },
    "group": {
      "title": "Group (data manipulation)",
      "description": "Instead of placing all the response attributes in the root of the response, create a new key and encapsulate the response inside.\n\nSee: https://www.krakend.io/docs/backends/data-manipulation/",
      "default": "backend1",
      "type": "string"
    },
    "host": {
      "title": "Host array",
      "description": "An array with all the available hosts to [load balance](https://www.krakend.io/docs/throttling/load-balancing/#balancing-egress-traffic-to-upstream) requests, including the schema (when possible) `schema://host:port`. E.g.: ` https://my.users-ms.com`. If you are in a platform where hosts or services are balanced (e.g., a K8S service), write a single entry in the array with the service name/balancer address. Defaults to the `host` declaration at the configuration's root level, and the service fails starting when there is none.",
      "type": "array",
      "items": {
        "type": "string",
        "pattern": ".+",
        "minLength": 1
      }
    },
    "input_headers": {
      "title": "Allowed Headers In",
      "description": "A second level of header filtering that defines the list of all headers allowed to reach this backend when different than the endpoint.\nBy default, all headers in the endpoint `input_headers` reach the backend, unless otherwise specified here. An empty list `[]` is considered a zero-value and allows all headers to pass. Use `[\"\"]` to explicitly remove all headers. See [headers forwarding](https://www.krakend.io/docs/endpoints/parameter-forwarding/#headers-forwarding)",
      "examples": [
        [ "" ],
        [ "User-Agent", "Accept" ]
      ],
      "default": [],
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string"
      }
    },
    "input_query_strings": {
      "title": "Allowed Querystrings In",
      "description": "A second level of query string filtering that defines the list of all query strings allowed to reach this backend when different than the endpoint.\nBy default, all query strings in the endpoint `input_query_strings` reach the backend, unless otherwise specified here. An empty list `[]` is considered a zero-value and allows all headers to pass. Use `[\"\"]` to explicitly remove all query strings. See [query strings forwarding](https://www.krakend.io/docs/endpoints/parameter-forwarding/#query-string-forwarding)",
      "examples": [
        [ "" ],
        [ "page", "limit" ]
      ],
      "default": [],
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "string"
      }
    },
    "is_collection": {
      "title": "Is a collection/array",
      "description": "Set to true when your API does not return an object {} but a collection []\n\nSee: https://www.krakend.io/docs/backends/data-manipulation/",
      "default": true,
      "type": "boolean"
    },
    "mapping": {
      "title": "Mapping",
      "description": "Mapping, or also known as renaming, let you change the name of the fields of the generated responses, so your composed response would be as close to your use case as possible without changing a line on any backend.\n\nSee: https://www.krakend.io/docs/backends/data-manipulation/",
      "examples": [
        {
          "from": "to"
        }
      ],
      "type": "object"
    },
    "method": {
      "title": "Method",
      "description": "The method sent to this backend in **uppercase**. The method does not need to match the endpoint's method. When the value is omitted, it uses the same endpoint's method. Some special methods will require you to use no-op encoding (like HEAD or OPTIONS) when these return an empty body.\n\nSee: https://www.krakend.io/docs/backends/",
      "default": "GET",
      "enum": [
        "GET",
        "POST",
        "PUT",
        "PATCH",
        "DELETE",
        "OPTIONS",
        "HEAD",
        "CONNECT",
        "TRACE"
      ]
    },
    "sd": {
      "title": "Service Discovery",
      "description": "The [Service Discovery](https://www.krakend.io/docs/backends/service-discovery/) system to resolve your backend services. Defaults to `static` (no external Service Discovery). Use `dns` to use DNS SRV records. Use `dns-shared` to share the DNS resolution between backends using the same hosts.\n\nSee: https://www.krakend.io/docs/backends/",
      "default": "static",
      "enum": [ "static", "dns", "dns-shared" ]
    },
    "sd_scheme": {
      "title": "Service Discovery Scheme",
      "description": "The [Service Discovery](https://www.krakend.io/docs/backends/service-discovery/) scheme to connect to your backend services.\n\nSee: https://www.krakend.io/docs/backends/",
      "examples": [ "http", "https" ],
      "default": "http",
      "type": "string"
    },
    "target": {
      "title": "Target (data manipulation)",
      "description": "Removes the matching object from the reponse and returns only its contents.\n\nSee: https://www.krakend.io/docs/backends/data-manipulation/",
      "examples": [ "data", "content", "response" ],
      "type": "string"
    },
    "url_pattern": {
      "title": "URL Pattern",
      "description": "The path inside the service (no protocol, no host, no method). E.g: `/users`. Some functionalities under `extra_config` might drop the requirement of declaring a valid `url_pattern`, but they are exceptions. The URL must be RESTful, if it is not (e.g.: `/url.{some_variable}.json`), then see how to [disable RESTful checking](#disable-restful-checking).\n\nSee: https://www.krakend.io/docs/backends/",
      "examples": [ "/users", "/user/{id_user}" ],
      "type": "string"
    }
  },
  "patternProperties": {
    "^[@$_#]": true
  },
  "additionalProperties": false
}
