Manage your documentation's lifecycle programmatically using the GitDocAI API. This guide covers how to create and manage versions, organize content into sections, and trigger automated publishing workflows.
Documentation Lifecycle
The typical flow for managing documentation via the API involves creating a version, populating it with sections, and then publishing the changes.
flowchart TD
A["Create Version"] --> B["Create Sections"]
B --> C["Reorder Sections"]
C --> D["Trigger Publish Job"]
D --> E["Monitor Publish Status"]Managing Versions
Versions allow you to maintain multiple iterations of your documentation (e.g., v1.0, v2.0, beta). All version endpoints are scoped to an organization and a specific documentation project.
Core Version Endpoints
| Action | Method | Endpoint |
|---|---|---|
| List versions | GET | /v1/documentation/{organization_id}/{documentation_id}/version |
| Create version | POST | /v1/documentation/{organization_id}/{documentation_id}/version |
| Get version | GET | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id} |
| Update version | PUT | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id} |
| Delete version | DELETE | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id} |
Deleting a version is a destructive action that will also remove all sections and content associated with that version.
Version States
You can programmatically control the lifecycle state of a version using dedicated endpoints. This is useful for automating release pipelines.
| State Action | Method | Endpoint |
|---|---|---|
| Set Default | POST | .../version/{version_id}/set-default |
| Set Latest | POST | .../version/{version_id}/set-latest |
| Set Deprecated | POST | .../version/{version_id}/set-deprecated |
What is the difference between Default and Latest?
The Default version is the one automatically shown to users when they visit the root URL of your documentation. The Latest version typically represents the most recent stable release, which might be different from the default if you are soft-launching a new version.
What happens when a version is deprecated?
Marking a version as Deprecated flags it in the UI, warning readers that the content is no longer actively maintained. It does not delete the content or remove it from the web.
Managing Sections
Sections act as the organizational folders or categories within a specific documentation version.
Core Section Endpoints
| Action | Method | Endpoint |
|---|---|---|
| List sections | GET | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id}/section |
| Create section | POST | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id}/section |
| Get section | GET | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id}/section/{section_id} |
| Update section | PUT | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id}/section/{section_id} |
| Delete section | DELETE | /v1/documentation/{organization_id}/{documentation_id}/version/{version_id}/section/{section_id} |
Advanced Section Management
Beyond basic CRUD operations, the API provides endpoints for organizing and verifying your sections:
Reorder Sections (
POST .../section/reorder): Update the display order of sections within the navigation menu.Get Source Summary (
GET .../section/{section_id}/source): Retrieve a source-of-truth summary for a specific section, which is helpful for auditing content synchronization.
When creating a new section, you can optionally pass a parent_id in the request body to nest the section inside an existing folder, creating a hierarchical documentation structure.
Managing Assets and Files
You can also manage file resources and import assets directly via the API to support your documentation content.
| Action | Method | Endpoint |
|---|---|---|
| Import asset from URL | POST | /v1/documentation/{organization_id}/{documentation_id}/asset/import |
| Request file upload URL | POST | /v1/documentation/{organization_id}/{documentation_id}/file-resources/upload-url |
Accessing Changelogs
If your documentation includes automated changelogs, you can retrieve them using the tasks endpoints.
| Action | Method | Endpoint |
|---|---|---|
| Get all changelogs | GET | /tasks/changelogs |
| Get changelog by version | GET | /tasks/changelogs/version/{version_id} |
Publishing Workflows
Once your versions and sections are configured, you need to publish the documentation to make the changes live. Publishing is handled asynchronously via a job queue.
- 1
Start a publish job
Trigger a new build and publish process for your documentation.
curl -X POST https://api.gitdocai.com/documentations/{documentation_id}/publish -H "Authorization: Bearer $YOUR_API_TOKEN" - 2
Monitor job status
Because publishing happens asynchronously, use the status endpoint to poll for completion.
curl https://api.gitdocai.com/documentations/{documentation_id}/publish/status -H "Authorization: Bearer $YOUR_API_TOKEN" - 3
Review publish history
You can audit past publish jobs or retrieve the details of the most recent successful deployment.
Get publish history:
GET /documentations/{documentation_id}/publish/historyGet latest publish:
GET /documentations/{documentation_id}/publish/latest
If you need to search through published documentation programmatically, you can use the POST /documentations/{organization_id}/{documentation_id}/search endpoint to query your content index.