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.
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 RestoredBackup 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}.
| Action | Method | Endpoint | Description |
|---|---|---|---|
| List Backups | GET | /backup | Retrieves a list of all historical backups. |
| Create Backup | POST | /backup | Triggers a new manual backup. |
| Get Repository | GET | /backup/repository | Returns the currently configured storage location. |
| Set Repository | PUT | /backup/repository | Updates where your backups are stored. |
| Restore Backup | POST | /backup/restore | Restores 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
Configure your backup repository
First, define where your backups will be saved. Send a
PUTrequest 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
Trigger a manual backup
With your repository configured, you can now capture the current state of your documentation. Send a
POSTrequest 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
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.
| Action | Method | Endpoint |
|---|---|---|
| List events (simplified) | POST | /v1/event/list |
| Delete an event (simplified) | DELETE | /v1/event |
| Get VAPID public key | GET | /v1/event/vapid-public-key |
| List project events | GET | /v1/organizations/{organization_id}/projects/{project_id}/events |
| Create project event | POST | /v1/organizations/{organization_id}/projects/{project_id}/events |
| Delete project event | DELETE | /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.