Backups & Restorations Creating Documentation Snapshots via API

Protect your hard work by creating point-in-time snapshots of your documentation. Using the backup API, you can easily save your current documentation state to a repository, list your available backups, and restore previous versions if something goes wrong.

Whether you want to automate daily backups or just save a quick snapshot before a major rewrite, these endpoints give you full control over your documentation's history.

sequenceDiagram
    participant User
    participant API as GitDocAI API
    participant Repo as Backup Repository

    User->>API: 1. Set Backup Repo (PUT)
    API-->>User: Success
    User->>API: 2. Create Backup (POST)
    API->>Repo: Save Snapshot
    API-->>User: Backup ID returned
    User->>API: 3. Restore Backup (POST)
    API->>Repo: Fetch Snapshot
    API-->>User: Documentation Restored

Prerequisites

Before you begin, make sure you have:

  • A valid API key passed in your request headers.

  • Your organization_id.

  • The documentation_id you want to back up.

We highly recommend setting up an automated script (like a cron job or GitHub Action) to trigger the backup endpoint regularly. This ensures you always have a recent snapshot available.

Managing your snapshots

Follow these steps to configure your backup environment, generate new snapshots, and restore them when needed.

  1. 1

    Configure your backup repository

    Before creating a snapshot, you need to tell the system where to store it. Use the PUT method to define your backup repository settings.

    curl -X PUT "https://api.gitdocai.com/v1/documentation/{organization_id}/{documentation_id}/backup/repository" 
      -H "Authorization: Bearer YOUR_API_KEY" 
      -H "Content-Type: application/json" 
      -d '{"repository_url": "your-repo-url"}'

    Note: You can always verify your current configuration by making a GET request to the same /backup/repository endpoint.

  2. 2

    Create a new snapshot

    Once your repository is configured, you can generate a backup at any time. This captures the exact state of your documentation at the moment the request is made.

    curl -X POST "https://api.gitdocai.com/v1/documentation/{organization_id}/{documentation_id}/backup" 
      -H "Authorization: Bearer YOUR_API_KEY"
  3. 3

    List available backups

    Need to find a specific snapshot? Retrieve a complete list of all backups associated with your documentation project.

    curl -X GET "https://api.gitdocai.com/v1/documentation/{organization_id}/{documentation_id}/backup" 
      -H "Authorization: Bearer YOUR_API_KEY"

    This will return a list of your snapshots, including their unique IDs and creation timestamps.

  4. 4

    Restore from a snapshot

    If you need to roll back to a previous version, use the restore endpoint. You will typically need to provide the specific backup ID you retrieved in the previous step.

    curl -X POST "https://api.gitdocai.com/v1/documentation/{organization_id}/{documentation_id}/backup/restore" 
      -H "Authorization: Bearer YOUR_API_KEY" 
      -H "Content-Type: application/json" 
      -d '{"backup_id": "your-target-backup-id"}'

Restoring a backup will overwrite your current live documentation state. Make sure you actually want to revert your changes, or consider taking a fresh snapshot of your current state before initiating a restore.

API Endpoint Quick Reference

Here is a quick summary of the endpoints available for managing documentation snapshots:

ActionMethodEndpoint Path
List BackupsGET/v1/documentation/{org_id}/{doc_id}/backup
Create BackupPOST/v1/documentation/{org_id}/{doc_id}/backup
Get RepositoryGET/v1/documentation/{org_id}/{doc_id}/backup/repository
Set RepositoryPUT/v1/documentation/{org_id}/{doc_id}/backup/repository
Restore BackupPOST/v1/documentation/{org_id}/{doc_id}/backup/restore

Additional Documentation Endpoints

While managing your documentation, you may also need to interact with individual assets or utilize AI features. Here are the endpoints available for those tasks:

Asset Management

ActionMethodEndpoint Path
List AssetsGET/v1/documentation/{organization_id}/{documentation_id}/asset
Upload 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 AssetDELETE/v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id}
Serve Asset FileGET/v1/documentation/{organization_id}/{documentation_id}/asset/{asset_id}/file

AI Features

ActionMethodEndpoint Path
Generate ImagePOST/documentation/{organization_id}/{documentation_id}/ai/generate-image

Need API Keys?

Learn how to generate and securely manage your API keys to authenticate your backup requests.