{"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"response-object","__idx":0},"children":["Response Object"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The response object describes a single response in the ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/responses"},"children":["Responses Map"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["It can be described in a separate file or in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["components.responses"]}," section and reused as a reference object."]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":["\nExcerpt from the OpenAPI 3.1 specification about the response object\n"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Describes a single response from an API Operation, including design-time, static"," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["links"]}," to operations based on the response."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"fixed-fields","__idx":1},"children":["Fixed Fields"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field Name"},"children":["Field Name"]},{"$$mdtype":"Tag","name":"th","attributes":{"align":"center","data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["description"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"center"},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["REQUIRED"]},". A description of the response. ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://spec.commonmark.org/"},"children":["CommonMark syntax"]}," MAY be used for rich text representation."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["headers"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"center"},"children":["Map[",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},", ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/header"},"children":["Header Object"]},"  | ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/reference"},"children":["Reference Object"]},"]"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Maps a header name to its definition. ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://tools.ietf.org/html/rfc7230#page-22"},"children":["RFC7230"]}," states header names are case insensitive. If a response header is defined with the name ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"Content-Type\""]},", it SHALL be ignored."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["content"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"center"},"children":["Map[",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},", ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/media-type"},"children":["Media Type Object"]},"]"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A map containing descriptions of potential response payloads. The key is a media type or ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://tools.ietf.org/html/rfc7231#appendix-D"},"children":["media type range"]}," and the value describes it.  For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["links"]},{"$$mdtype":"Tag","name":"td","attributes":{"align":"center"},"children":["Map[",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["string"]},", ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/links"},"children":["Link Object"]}," | ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/reference"},"children":["Reference Object"]},"]"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A map of operations links that can be followed from the response. The key of the map is a short name for the link, following the naming constraints of the names for ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/components"},"children":["Component Objects"]},"."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This object MAY be extended with Specification Extensions."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A response object is connected to the Responses Map which will have possible keys of:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["default, or"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["HTTP codes (such as '200', '201', '400', and so on)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["HTTP ranges ('1XX', '2XX', '3XX', '4XX', or '5XX')"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The examples use '200' as the responses map key."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["(",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Why? Because everything's going to be OK."]},")"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"visuals","__idx":2},"children":["Visuals"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"description","__idx":3},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["description"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["REQUIRED."]}," A description of the response."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"responses:\n  '200':\n    description: OK\n  '201':\n    description: Created\n  '202':\n    description: Accepted\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"Image","attributes":{"src":"/content-assets/responses-success-a5fba4dba683c3ce.png","alt":"success response description"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"headers","__idx":4},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["headers"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The named headers are specific to responses."," ","These are different from request headers which are types of parameters in OpenAPI."," ","The main differences are:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["name"]}," MUST NOT be specified, it is given in the corresponding headers map."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["in"]}," MUST NOT be specified, it is implicitly in header."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["All traits that are affected by the location MUST be applicable to a location of header (for example, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["style"]},")."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Also, a common oversight is that the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Content-Type"]}," header name is ignored."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The headers map is a map of header names as the map keys, and header objects as the values."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"responses:\n  '200':\n    description: OK\n    headers:\n      Pagination-Count:\n        description: The count of items in the collection.\n        schema:\n          type: integer\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"Image","attributes":{"src":"/content-assets/response-header-42ea69b6d4935b2a.png","alt":"pagination-count header"},"children":[]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Learn more about the ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/header"},"children":["Header Object"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"content","__idx":5},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["content"]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A map containing descriptions of potential response payloads. The key is a media type or ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://tools.ietf.org/html/rfc7231#appendix-D"},"children":["media type range"]}," and the value describes it.  For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The \"Accept\" header field can be used by user agents to specify response media types that are acceptable."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Common media types:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["application/json"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["application/xml"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["image/png"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["image/*"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["application/pdf"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["text/plain"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["text/html"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["text/csv"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["application/octet-stream"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["See a list of all ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://www.iana.org/assignments/media-types/media-types.xhtml"},"children":["registered media types"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The value in the content map is a ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/openapi/openapi-visual-reference/media-type"},"children":["Media Type Object"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"yaml","header":{"controls":{"copy":{}}},"source":"responses:\n  200:\n    description: Success\n    content:\n      application/json:\n        schema:\n          $ref: \"#/components/schemas/ChessResult\"\n","lang":"yaml"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"Image","attributes":{"src":"/content-assets/response-content-fa5aefcc20599995.png","alt":"Response content chess result"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"links","__idx":6},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["links"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Links are rarely used."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Redocly doesn't visualize the links."," ","If you have an idea for how to visualize the links, please let us know in a ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://github.com/Redocly/redoc/issues/572"},"children":["GitHub issue comment"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"types","__idx":7},"children":["Types"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Response"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["MediaTypesMap"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"ts","header":{"controls":{"copy":{}}},"source":"const Response: NodeType = {\n  properties: {\n    description: { type: 'string' },\n    headers: mapOf('Header'),\n    content: 'MediaTypesMap',\n    links: mapOf('Link'),\n  },\n  required: ['description'],\n};\n","lang":"ts"},"children":[]}]},"frontmatter":{},"tagList":["html"],"title":"Response Object","lastModified":"2025-05-28T16:01:32.000Z"}