API Reference: Core Documentation Utilizing AI-Powered Editing Features via API

GitDocAI provides powerful AI endpoints to help you generate, refine, and enrich your documentation programmatically. Whether you are bootstrapping a new project from a prompt, refining existing paragraphs, or generating custom assets, these tools streamline your content creation workflow.

Initialize

Bootstrap entire documentation structures from a single text prompt.

Edit & Refine

Polish existing content, fix grammar, or adjust the tone of your text.

Generate Assets

Create custom AI images that are automatically saved to your workspace.

All AI endpoints require a valid API key passed in the Authorization header as a Bearer token. Ensure your organization has sufficient AI credits before making bulk requests.

AI Endpoints Overview

CapabilityMethodEndpoint Path
Initialize from AIPOST/v1/documentation/{organization_id}/{documentation_id}/initialize-from-ai
Edit ContentPOST/documentation/{organization_id}/{documentation_id}/ai/edit
Generate ImagePOST/documentation/{organization_id}/{documentation_id}/ai/generate-image

Core AI Workflows

1. Bootstrapping Documentation

If you have an empty documentation project, you can use the AI initialization endpoint to generate a complete scaffold based on a descriptive prompt.

curl -X POST "https://api.gitdocai.com/v1/documentation/org_123/doc_456/initialize-from-ai" 
  -H "Authorization: Bearer YOUR_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "prompt": "Create a developer guide for a REST API that manages a bookstore, including authentication, listing books, and processing orders."
  }'

2. Refining Content

The AI edit endpoint acts as your programmatic copyeditor. You can pass existing markdown content along with specific instructions (e.g., "make this sound more professional", "translate to Spanish", or "fix grammatical errors").

curl -X POST "https://api.gitdocai.com/documentation/org_123/doc_456/ai/edit" 
  -H "Authorization: Bearer YOUR_API_KEY" 
  -H "Content-Type: application/json" 
  -d '{
    "content": "the api returns a 200 when it works good.",
    "instruction": "Improve grammar and make the tone professional."
  }'

3. Generating Images

Visuals make documentation much easier to digest. The image generation endpoint allows you to create custom diagrams or illustrations. GitDocAI automatically stores the generated image as an asset within your documentation workspace and returns the asset details so you can immediately embed it in your pages.

Be as descriptive as possible in your image prompts. Specify the style (e.g., "flat vector illustration", "minimalist isometric diagram") for the best results.

4. Managing Assets and Resources

Because the generate-image endpoint automatically saves the resulting file to your documentation's asset library, you may need to retrieve, update, or delete these files. You can manage all documentation assets and file resources using the following endpoints:

CapabilityMethodEndpoint Path
Get all assetsGET/v1/documentation/{organization_id}/{documentation_id}/asset
Upload an assetPOST/v1/documentation/{organization_id}/{documentation_id}/asset
Get asset by IDGET/v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id}
Update asset metadataPUT/v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id}
Delete an assetDELETE/v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id}
Serve asset fileGET/v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id}/file
Import asset from URLPOST/v1/documentation/{organization_id}/{documentation_id}/asset/import
Request file upload URLPOST/v1/documentation/{organization_id}/{documentation_id}/file-resources/upload-url
Finalize direct uploadPOST/v1/documentation/{organization_id}/{documentation_id}/file-resources/finalize

Example: The AI Content Lifecycle

Here is how these endpoints typically interact when building out a new page programmatically:

sequenceDiagram
    participant Client
    participant API as GitDocAI API
    participant AI as AI Engine

    Client->>API: POST /initialize-from-ai
    API->>AI: Request structure based on prompt
    AI-->>API: Returns scaffolded Markdown
    API-->>Client: 200 OK (Documentation Created)

    Client->>API: POST /ai/edit (Draft text)
    API->>AI: Apply formatting/grammar rules
    AI-->>API: Returns polished Markdown
    API-->>Client: 200 OK (Updated Content)

    Client->>API: POST /ai/generate-image
    API->>AI: Generate visual asset
    AI-->>API: Returns image data
    API-->>Client: 200 OK (Asset ID & URL)

Putting it all together

Ready to automate your documentation? Follow this standard sequence to build a page from scratch:

  1. 1

    Initialize the project

    Call the initialize-from-ai endpoint with a broad prompt to let GitDocAI generate your folders, sections, and initial entries.

  2. 2

    Refine specific entries

    Iterate over the generated doc entries. If any section needs a specific tone or expansion, pass the text to the ai/edit endpoint with targeted instructions.

  3. 3

    Add visual assets

    Identify concepts that need visual explanation. Call ai/generate-image, retrieve the resulting Asset ID, and inject the markdown image link (![Alt text](asset_url)) into your doc entry.

Additional Organization Endpoints

If you are building custom onboarding or setup flows, you can also manage the documentation wizard progress programmatically:

CapabilityMethodEndpoint Path
Delete wizard progressDELETE/v1/organization/{organization_id}/wizard-progress/{documentation_id}

Frequently Asked Questions

Do AI image generations count against my storage limits?

Yes. Because the generate-image endpoint automatically saves the resulting file to your documentation's asset library, the file size will count toward your organization's total storage quota.

Can I use the edit endpoint on non-Markdown text?

While the endpoint is optimized for Markdown (and will preserve your formatting), you can pass plain text or HTML. However, the AI will generally return the refined content in Markdown format.

What happens if the AI initialization fails?

If the AI times out or fails to generate a scaffold, the API will return a 4xx or 5xx error, and your documentation state will remain unchanged. You will not be charged AI credits for failed generations.