> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/developers/gitbook-api/api-reference/openapi.md). Agents can also search and read this documentation through its [MCP server](https://gitbook.com/docs/~gitbook/mcp).

# OpenAPI

Upload, access, or version-control your OpenAPI specifications directly in GitBook.

The OpenAPI endpoints let you integrate your existing or newly generated OpenAPI definitions into GitBook. This includes uploading, updating, and retrieving specs.

## The OpenAPISpec object

```json
{"openapi":"3.1.0","info":{"title":"GitBook API","version":"0.0.1-beta"},"components":{"schemas":{"OpenAPISpec":{"type":"object","allOf":[{"type":"object","properties":{"object":{"description":"The object type, which is always \"openapi-spec\"","type":"string","enum":["openapi-spec"]},"id":{"description":"Unique identifier","type":"string"},"createdAt":{"description":"Date of creation","$ref":"#/components/schemas/Timestamp"},"updatedAt":{"description":"Date of the last update","$ref":"#/components/schemas/Timestamp"},"slug":{"$ref":"#/components/schemas/OpenAPISpecSlug"},"site":{"type":"string","description":"ID of the site that owns the OpenAPI spec: only that site's members can manage it, and its content can be used across the organization. Absent when the organization owns it."},"processingState":{"$ref":"#/components/schemas/OpenAPISpecProcessingState"},"visibility":{"$ref":"#/components/schemas/OpenAPISpecVisibility"},"lastVersion":{"type":"string","description":"ID of the latest version of the OpenAPI specification"},"lastProcessedAt":{"description":"Date of the last processing","$ref":"#/components/schemas/Timestamp"},"lastProcessErrorCode":{"$ref":"#/components/schemas/OpenAPISpecProcessingErrorCode"},"lastProcessedErrors":{"type":"array","items":{"$ref":"#/components/schemas/OpenAPIErrorObject"}},"lastProcessedErrorCount":{"type":"integer","minimum":0,"description":"Total number of processing errors before truncation of lastProcessedErrors."},"permissions":{"type":"object","description":"The set of permissions for the OpenAPI specification.","required":["view","edit"],"properties":{"view":{"type":"boolean","description":"Can the user view the specification."},"edit":{"type":"boolean","description":"Can the user edit the specification."}}},"urls":{"type":"object","description":"URLs associated with the object","properties":{"location":{"description":"URL of the OpenAPI specification in the API","$ref":"#/components/schemas/URL"},"app":{"description":"URL of the OpenAPI specification in the application","$ref":"#/components/schemas/URL"},"published":{"type":"string","description":"URL of the published spec. Only defined when visibility is \"published.\"","format":"uri"}},"required":["app","location"]}},"required":["object","id","createdAt","updatedAt","slug","processingState","lastProcessedErrorCount","permissions","urls"]},{"oneOf":[{"type":"object","title":"URL source","properties":{"source":{"type":"string","description":"The spec's versions are fetched from `sourceURL`.","enum":["url"]},"sourceURL":{"$ref":"#/components/schemas/URL"}},"required":["source","sourceURL"]},{"type":"object","title":"File source","properties":{"source":{"type":"string","description":"Where the spec's files come from.\n* `upload`: uploaded through the app, the API or the CLI.\n* `git`: imported by Git Sync from a site's repository.\n","enum":["upload","git"]}},"required":["source"]}]}]},"Timestamp":{"type":"string","format":"date-time"},"OpenAPISpecSlug":{"description":"Slug used as reference","type":"string","minLength":1,"maxLength":100,"pattern":"^[a-zA-Z0-9]+(?:-[a-zA-Z0-9]+)*$"},"OpenAPISpecProcessingState":{"description":"Processing state","enum":["pending","progress","complete"]},"OpenAPISpecVisibility":{"type":"string","description":"The visibility setting of the OpenAPI spec.\n* `private`: The spec is not publicly available.\n* `public`: The spec is available to anyone with a public link.\n","enum":["private","public"]},"OpenAPISpecProcessingErrorCode":{"description":"OpenAPI processing error code","enum":["FETCH_TIMEOUT","FETCH_ERROR","PARSE_ERROR","PROCESSING_ERROR"]},"OpenAPIErrorObject":{"type":"object","description":"OpenAPI error object.","properties":{"message":{"type":"string","description":"Description of the error."},"code":{"type":"string","description":"Unique code of the error."}},"required":["message"]},"URL":{"type":"string","format":"uri","maxLength":2048}}}}
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/developers/gitbook-api/api-reference/openapi.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
