Getting started
Back to home
Getting started

Create a backup schedule

Configure a WordPress or supported database backup using the permitted storage destination. Database backups require databaseId. Retention follows the organisation's plan.

POST/api/customer/v1/projects/{projectId}/backups

Path parameters

NameValue
projectIdRequired resource ID from an earlier API response.

Request body

Send JSON with Content-Type: application/json. Nested fields and accepted values are listed in the schema.

FieldTypeRequired
type"database" | "wordpress"Yes
databaseIdstringNo
schedulestringYes
prefixstringNo
destinationIdstringNo
Full request schema
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "database",
        "wordpress"
      ]
    },
    "databaseId": {
      "type": "string",
      "minLength": 1
    },
    "schedule": {
      "type": "string",
      "minLength": 1
    },
    "prefix": {
      "type": "string"
    },
    "destinationId": {
      "type": "string",
      "minLength": 1
    }
  },
  "required": [
    "type",
    "schedule"
  ],
  "additionalProperties": false
}

Example request

Set HCODE_BASE_URL and HCODE_API_KEY as shown in Getting started. Replace resource variables with your own IDs.

curl --request POST "$HCODE_BASE_URL/api/customer/v1/projects/${PROJECT_ID}/backups" \
  --header "Authorization: Bearer $HCODE_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "type": "database",
  "schedule": "0 2 * * *",
  "databaseId": "REPLACE_WITH_DATABASE_ID"
}'

Response

The JSON shape is defined in the response schema.

Response schema
{
  "type": "object",
  "properties": {
    "success": {
      "type": "boolean"
    },
    "backupId": {
      "type": "string"
    },
    "backup": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "projectId": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "schedule": {
          "type": "string"
        },
        "databaseId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "prefix": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "lastBackupAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "createdAt": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "enabled": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        },
        "retentionDays": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "id",
        "type",
        "schedule"
      ],
      "additionalProperties": true
    },
    "operationId": {
      "type": "string"
    },
    "operations": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "href": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "status",
          "href"
        ]
      }
    }
  },
  "required": [],
  "additionalProperties": true
}

See errors and retries for failure responses.