API
On this page
Expand Collapse BorgBackup server control via REST API now available with BorgWarehouse !
BorgWarehouse’s API makes it even more powerful ! Generate easily API tokens from the web interface and retrieve information from your repositories, create new ones, modify them…
To create new tokens, go to Account > Integrations in BorgWarehouse. The permissions are simple :
create : you can add new repositoriesread : you can retrieve informations about your repositoriesupdate : you can modify some informations on a repositorydelete : you can delete repositoriesThe authentication is a Bearer authentication , it should be passed as HTTP HEADER and the content type for data is application/json :
Authorization: Bearer <YOUR_API_KEY>
Content-Type: application/json
Examples of curl commands are provided in the endpoint documentation below.
💡
You can globally disable the ability to delete a repository in BorgWarehouse using the environment variable DISABLE_DELETE_REPO=true
💡
You can disable this feature using the environment variable DISABLE_INTEGRATIONS=true
API v1 Version # GET
/api/v1/version
(BorgWarehouse version number)
Parameters # None
Responses # http code content-type response 200application/json{"version":"3.0.0"}
Example cURL # curl -X GET -H "Content-Type: application/json" https://localhost:3000/api/v1/version
Scheduled Tasks # POST
/api/v1/cron/status
(Check status and send alerts)
Parameters # None
key value AuthorizationBearer CRONJOB_KEY
Responses # http code content-type response 200application/json{"success":""Status cron executed successfully"}
Example cURL # curl -i --request POST --url 'https://localhost:3000/api/v1/cron/status' --header 'Authorization: Bearer CRONJOB_KEY'
POST
/api/v1/cron/storage
(Refresh storage of repositories)
Parameters # None
key value AuthorizationBearer CRONJOB_KEY
Responses # http code content-type response 200application/json{"success":"Storage cron executed successfully"}
Example cURL # curl -i --request POST --url 'https://localhost:3000/api/v1/cron/storage' --header 'Authorization: Bearer CRONJOB_KEY'
Repositories actions # GET
/api/v1/repositories
Parameters # None
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"repoList": [ ... ]}
Example cURL # curl -X GET -H "Authorization: Bearer YOUR_API_KEY" https://localhost:3000/api/v1/repositories
POST
/api/v1/repositories
Body Parameters # key type required description aliasstringyes The new alias for the repository. sshPublicKeystringyes The new SSH public key for the repository. storageSizenumberyes The new storage size for the repository (must be an integer > 0). commentstringno An optional comment about the repository, it can be an empty string. alertnumberno The alert option (must be a valid value from the alert array below). lanCommandbooleanno Indicates if LAN command is enabled. appendOnlyModebooleanno Indicates if append-only mode is enabled.
Alert Options # The alert parameter must be one of the following values:
Valid values Time (for information only) 0Disabled 36001 hour 216006 hours 4320012 hours 900001 day 1728002 days 2592003 days 3456004 days 4320005 days 5184006 days 6048007 days 86400010 days 120960014 days 259200030 days
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"id": 2, "repositoryName": "c1ddd097"}
Example cURL # curl -i --request POST --url 'https://localhost:3000/api/v1/repositories' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"alias": "MyRepoAlias",
"sshPublicKey": "ssh-rsa AAAA...",
"storageSize": 100,
"comment": "This is my new repo",
"alert": 3600,
"lanCommand": true,
"appendOnlyMode": false
}'
GET
/api/v1/repositories/{repositoryName}
Parameters # key type required description repositoryNamestringyes The name of the repository to retrieve.
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"repo": { ... }}
Example cURL # curl -X GET -H "Authorization: Bearer YOUR_API_KEY" https://localhost:3000/api/v1/repositories/6edb4d1e
PATCH
/api/v1/repositories/{repositoryName}
Parameters # key type required description repositoryNamestringyes The name of the repository to update.
Body Parameters # key type required description aliasstringno The new alias for the repository. sshPublicKeystringno The new SSH public key for the repository. storageSizenumberno The new storage size for the repository (must be an integer > 0). commentstringno An optional comment about the repository. alertnumberno The alert option ID (must be a valid value from the alert array below). lanCommandbooleanno Indicates if LAN command is enabled. appendOnlyModebooleanno Indicates if append-only mode is enabled.
Alert Options # The alert parameter must be one of the following values:
Valid values Time 0Disabled 36001 hour 216006 hours 4320012 hours 900001 day 1728002 days 2592003 days 3456004 days 4320005 days 5184006 days 6048007 days 86400010 days 120960014 days 259200030 days
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"message":"Repository 5ecb2d6e has been edited"}
Example cURL # curl -X PATCH -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" \
--data-raw '{
"alias": "UpdatedRepoAlias",
"sshPublicKey": "ssh-rsa AAAA...",
"storageSize": 200,
"comment": "Updated comment",
"alert": 3600,
"lanCommand": false,
"appendOnlyMode": true
}' https://localhost:3000/api/v1/repositories/5ecb2d6e
DELETE
/api/v1/repositories/{repositoryName}
Parameters # key type required description idstringyes The ID of the repository to delete.
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"message":"Repository 5ecb2d6e deleted"}
Example cURL # curl -X DELETE -H "Authorization: Bearer YOUR_API_KEY" https://localhost:3000/api/v1/repositories/5ecb2d6e
API v0 (legacy) ⚠️
This API is deprecated and was used with Borgwarehouse v2
Version # GET
/api/version
(Get the version number)
Parameters # None
Responses # http code content-type response 200application/json{"version":"2.1.0"}
Example cURL # curl -X GET -H "Content-Type: application/json" https://localhost:3000/api/version
Scheduled Tasks # POST
/api/cronjob/checkStatus
(Check status and send alerts)
Parameters # None
key value AuthorizationBearer CRONJOB_KEY
Responses # http code content-type response 200application/json{"success":"Status cron has been executed."}401application/json{"status":401,"message":"Unauthorized"}
Example cURL # curl -i --request POST --url 'https://localhost:3000/api/cronjob/checkStatus' --header 'Authorization: Bearer CRONJOB_KEY'
POST
/api/cronjob/getStorageUsed
(Retrieve storage of repositories)
Parameters # None
key value AuthorizationBearer CRONJOB_KEY
Responses # http code content-type response 200application/json{"success":"Storage cron has been executed."}401application/json{"status":401,"message":"Unauthorized"}
Example cURL # curl -i --request POST --url 'https://localhost:3000/api/cronjob/getStorageUsed' --header 'Authorization: Bearer CRONJOB_KEY'
Repositories actions # GET
/api/repo
(Retrieve a list of repositories)
Parameters # None
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"repoList": [ ... ]}401application/json{"message":"Unauthorized"}403application/json{"message":"Invalid API key"}500application/json{"message":"Internal Server Error"}
Example cURL # curl -X GET -H "Authorization: Bearer YOUR_API_KEY" https://localhost:3000/api/repo
GET
/api/repo/id/[id]
(Retrieve details of a specific repository by ID)
Parameters # key type required description idstringyes The ID of the repository to retrieve.
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"repo": { ... }}401application/json{"message":"Unauthorized"}403application/json{"message":"Invalid API key"}404application/json{"message":"No repository with id #ID"}500application/json{"status":500,"message":"Internal Server Error"}
Example cURL # curl -X GET -H "Authorization: Bearer YOUR_API_KEY" https://localhost:3000/api/repo/id/1
POST
/api/repo/add
(Create a new repository)
Body Parameters # key type required description aliasstringyes The new alias for the repository. sshPublicKeystringyes The new SSH public key for the repository. storageSizenumberyes The new storage size for the repository (must be an integer > 0). commentstringyes An optional comment about the repository, it can be an empty string. alertnumberyes The alert option ID (must be a valid value from the alert array below). lanCommandbooleanyes Indicates if LAN command is enabled. appendOnlyModebooleanyes Indicates if append-only mode is enabled.
Alert Options # The alert parameter must be one of the following values:
Valid values Time (for information only) 0Disabled 36001 hour 216006 hours 4320012 hours 900001 day 1728002 days 2592003 days 3456004 days 4320005 days 5184006 days 6048007 days 86400010 days 120960014 days 259200030 days
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"id": 2, "repositoryName": "c1ddd097"}401application/json{"message":"Unauthorized"}409application/json{"message":"The SSH key is already used in another repository."}422application/json{"message":"Unexpected data"}
Example cURL # curl -i --request POST --url 'https://localhost:3000/api/repo/add' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"alias": "MyRepoAlias",
"sshPublicKey": "ssh-rsa AAAA...",
"storageSize": 100,
"comment": "This is my new repo",
"alert": 1,
"lanCommand": true,
"appendOnlyMode": false
}'
PATCH
/api/repo/id/[id]/edit
(Update a specific repository by ID)
Parameters # key type required description idstringyes The ID of the repository to update.
Body Parameters # key type required description aliasstringno The new alias for the repository. sshPublicKeystringno The new SSH public key for the repository. storageSizenumberno The new storage size for the repository (must be an integer > 0). commentstringno An optional comment about the repository. alertnumberno The alert option ID (must be a valid value from the alert array below). lanCommandbooleanno Indicates if LAN command is enabled. appendOnlyModebooleanno Indicates if append-only mode is enabled.
Alert Options # The alert parameter must be one of the following values:
Valid values Time 0Disabled 36001 hour 216006 hours 4320012 hours 900001 day 1728002 days 2592003 days 3456004 days 4320005 days 5184006 days 6048007 days 86400010 days 120960014 days 259200030 days
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"message":"success"}400application/json{"message":"Invalid request body"}401application/json{"message":"Unauthorized"}403application/json{"message":"Invalid API key"}404application/json{"message":"No repository with id #ID"}409application/json{"message":"The SSH key is already used in another repository."}422application/json{"message":"Unexpected data"}500application/json{"message":"Internal Server Error"}
Example cURL # curl -X PATCH -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" \
--data-raw '{
"alias": "UpdatedRepoAlias",
"sshPublicKey": "ssh-rsa AAAA...",
"storageSize": 200,
"comment": "Updated comment",
"alert": 3600,
"lanCommand": false,
"appendOnlyMode": true
}' https://localhost:3000/api/repo/id/1/edit
DELETE
/api/repo/id/[id]/delete
(Delete a specific repository by ID)
Parameters # key type required description idstringyes The ID of the repository to delete.
key value AuthorizationBearer YOUR_API_KEY
Responses # http code content-type response 200application/json{"message":"success"}401application/json{"message":"Unauthorized"}403application/json{"message":"Invalid API key"}404application/json{"message":"No repository with id #ID"}405application/json{"message":"Method Not Allowed"}500application/json{"status":500,"message":"Internal Server Error"}
Example cURL # curl -X DELETE -H "Authorization: Bearer YOUR_API_KEY" https://localhost:3000/api/repo/id/1234/delete