Backups & Restorations Executing Backup Processes via API

Keeping your documentation safe and versioned is critical for any growing project. Using the backup API, you can programmatically configure storage repositories, trigger manual backups, and restore your documentation whenever needed.

Authentication Required

All endpoints on this page require a valid API key. Ensure you include your Bearer token in the Authorization header of your requests.

How the backup process works

Before you can create a backup, you must tell the system where to store it by configuring a backup repository. Once configured, you can trigger backups and restore from them at any time.

sequenceDiagram
    participant Client
    participant API
    participant Storage as Backup Repository
    
    Client->>API: 1. PUT /backup/repository
    API-->>Client: Repository Configured
    
    Client->>API: 2. POST /backup
    API->>Storage: Save Documentation State
    API-->>Client: Backup Created Successfully
    
    Client->>API: 3. POST /backup/restore
    API->>Storage: Retrieve Backup Data
    API-->>Client: Documentation Restored

Backup API Endpoints

Here is a quick reference of the available endpoints for managing your documentation backups. All endpoints are prefixed with /v1/documentation/{organization_id}/{documentation_id}.

ActionMethodEndpointDescription
List BackupsGET/backupRetrieves a list of all historical backups.
Create BackupPOST/backupTriggers a new manual backup.
Get RepositoryGET/backup/repositoryReturns the currently configured storage location.
Set RepositoryPUT/backup/repositoryUpdates where your backups are stored.
Restore BackupPOST/backup/restoreRestores documentation to a previous state.

Step-by-Step: Automating your backups

Follow this workflow to set up and execute your first backup via the API.

  1. 1

    Configure your backup repository

    First, define where your backups will be saved. Send a PUT request to configure your storage destination.

    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": "s3://my-doc-backups",
        "provider": "aws_s3"
      }'
  2. 2

    Trigger a manual backup

    With your repository configured, you can now capture the current state of your documentation. Send a POST request to the backup endpoint.

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

    You can set up a cron job or a CI/CD pipeline step to call this endpoint automatically, ensuring you always have daily or weekly snapshots of your docs.

  3. 3

    Verify your backup

    To ensure your backup was created successfully, retrieve a list of all available backups for your documentation project.

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

Restoring from a backup

If you ever need to roll back to a previous version of your documentation, you can use the restore endpoint. You will need the ID of the specific backup you wish to restore (which you can find using the List Backups endpoint).

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": "bck_123456789"
  }'

Data Overwrite Warning
Restoring a backup will overwrite your current live documentation. Any changes made after the selected backup was created will be permanently lost. We highly recommend triggering a fresh backup right before performing a restore.

Event Monitoring API

To monitor system actions—such as backup completions, initializations, or other automated processes—you can utilize the Events API endpoints.

ActionMethodEndpoint
List events (simplified)POST/v1/event/list
Delete an event (simplified)DELETE/v1/event
Get VAPID public keyGET/v1/event/vapid-public-key
List project eventsGET/v1/organizations/{organization_id}/projects/{project_id}/events
Create project eventPOST/v1/organizations/{organization_id}/projects/{project_id}/events
Delete project eventDELETE/v1/organizations/{organization_id}/projects/{project_id}/events/{event_id}

Frequently Asked Questions

Can I change my backup repository later?

Yes. You can update your backup repository at any time by sending another PUT request to the /backup/repository endpoint. Future backups will be routed to the new destination.

How do I find my organization and documentation IDs?

Your organization_id and documentation_id can be found in the URL of your GitDocAI dashboard, or by querying the main Projects API endpoint.