GitBook API API reference OpenAPIUpload, 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.
object string · enum required
The object type, which is always "openapi-spec"
Options: openapi-spec
createdAt string · date-time required
updatedAt string · date-time required
slug string · min: 1 · max: 100 required
Pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
sourceURL string · uri · max: 2048 optional
processingState undefined · enum required
Options: pending
, progress
, complete
lastVersion string optional
ID of the latest version of the OpenAPI specification
lastProcessedAt string · date-time optional
Date of the last processing
lastProcessErrorCode undefined · enum optional
OpenAPI processing error code
Options: FETCH_TIMEOUT
, FETCH_ERROR
, PARSE_ERROR
permissions object required
The set of permissions for the OpenAPI specification.
urls object required
URLs associated with the object
List all OpenAPI spec
get
https://api.gitbook.com/v1 /orgs/ {organizationId} /openapi
organizationId string required
The unique id of the organization
page string optional
Identifier of the page results to fetch.
limit number · max: 1000 optional
The number of results per page
Copy curl -L \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Copy {
"next": {
"page": "text"
},
"count": 1,
"items": [
{
"object": "openapi-spec",
"id": "text",
"createdAt": "2025-04-18T22:59:05.324Z",
"updatedAt": "2025-04-18T22:59:05.324Z",
"slug": "text",
"sourceURL": "https://example.com",
"processingState": "pending",
"lastVersion": "text",
"lastProcessedAt": "2025-04-18T22:59:05.324Z",
"lastProcessErrorCode": "FETCH_TIMEOUT",
"permissions": {
"edit": true
},
"urls": {
"location": "https://example.com",
"app": "https://example.com"
}
}
]
}
Create an OpenAPI spec
post
https://api.gitbook.com/v1 /orgs/ {organizationId} /openapi
organizationId string required
The unique id of the organization
slug string · min: 1 · max: 100 required
Pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$
Create a specification from an URL
Create a specification from a text string
Copy curl -L \
--request POST \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"slug": "text",
"source": {
"url": "https://example.com"
}
}'
Copy {
"object": "openapi-spec",
"id": "text",
"createdAt": "2025-04-18T22:59:05.324Z",
"updatedAt": "2025-04-18T22:59:05.324Z",
"slug": "text",
"sourceURL": "https://example.com",
"processingState": "pending",
"lastVersion": "text",
"lastProcessedAt": "2025-04-18T22:59:05.324Z",
"lastProcessErrorCode": "FETCH_TIMEOUT",
"permissions": {
"edit": true
},
"urls": {
"location": "https://example.com",
"app": "https://example.com"
}
}
Get an OpenAPI spec by its slug
get
https://api.gitbook.com/v1 /orgs/ {organizationId} /openapi/ {specSlug}
organizationId string required
The unique id of the organization
specSlug string required
Slug of the OpenAPI specification
Copy curl -L \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi/{specSlug}' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'
Copy {
"object": "openapi-spec",
"id": "text",
"createdAt": "2025-04-18T22:59:05.324Z",
"updatedAt": "2025-04-18T22:59:05.324Z",
"slug": "text",
"sourceURL": "https://example.com",
"processingState": "pending",
"lastVersion": "text",
"lastProcessedAt": "2025-04-18T22:59:05.324Z",
"lastProcessErrorCode": "FETCH_TIMEOUT",
"permissions": {
"edit": true
},
"urls": {
"location": "https://example.com",
"app": "https://example.com"
}
}
Create or update an OpenAPI spec
put
https://api.gitbook.com/v1 /orgs/ {organizationId} /openapi/ {specSlug}
organizationId string required
The unique id of the organization
specSlug string required
Slug of the OpenAPI specification
Create a specification from an URL
Create a specification from a text string
Copy curl -L \
--request PUT \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi/{specSlug}' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
--header 'Content-Type: application/json' \
--data '{
"source": {
"url": "https://example.com"
}
}'
Copy {
"object": "openapi-spec",
"id": "text",
"createdAt": "2025-04-18T22:59:05.324Z",
"updatedAt": "2025-04-18T22:59:05.324Z",
"slug": "text",
"sourceURL": "https://example.com",
"processingState": "pending",
"lastVersion": "text",
"lastProcessedAt": "2025-04-18T22:59:05.324Z",
"lastProcessErrorCode": "FETCH_TIMEOUT",
"permissions": {
"edit": true
},
"urls": {
"location": "https://example.com",
"app": "https://example.com"
}
}
Delete an OpenAPI spec
delete
https://api.gitbook.com/v1 /orgs/ {organizationId} /openapi/ {specSlug}
organizationId string required
The unique id of the organization
specSlug string required
Slug of the OpenAPI specification
Copy curl -L \
--request DELETE \
--url 'https://api.gitbook.com/v1/orgs/{organizationId}/openapi/{specSlug}' \
--header 'Authorization: Bearer YOUR_SECRET_TOKEN'