Skip to content
Start here

Replace Hyperdrive

hyperdrive.configs.update(strhyperdrive_id, ConfigUpdateParams**kwargs) -> ConfigUpdateResponse
PUT/accounts/{account_id}/hyperdrive/configs/{hyperdrive_id}

Replaces and returns the specified Hyperdrive configuration. The request must include the name and complete origin connection details. Omitted caching settings are reset to their defaults, while omitted mTLS settings and origin connection limits are preserved. Use the update operation to modify only selected fields.

Security
API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Hyperdrive Write
ParametersExpand Collapse
account_id: str

Define configurations using a unique string identifier.

maxLength32
hyperdrive_id: str

Define configurations using a unique string identifier.

maxLength32
name: str

The name of the Hyperdrive configuration. Used to identify the configuration in the Cloudflare dashboard and API.

maxLength2048
origin: Origin

Combines database connection fields with exactly one supported network location.

One of the following:
class OriginPublicDatabase: …
database: str

Set the name of your origin database.

maxLength2048
host: str

Defines the publicly reachable hostname or IP of your origin database. Private, loopback, and link-local IP addresses are not allowed.

password: str

Set the password needed to access your origin database. The API never returns this write-only value.

maxLength2048
port: int

Defines the port of your origin database. Defaults to 5432 for PostgreSQL or 3306 for MySQL if not specified.

maximum65535
minimum1
scheme: Literal["postgres", "postgresql", "mysql"]

Specifies the URL scheme used to connect to your origin database.

One of the following:
"postgres"
"postgresql"
"mysql"
user: str

Set the user of your origin database.

maxLength2048
class OriginAccessProtectedDatabaseBehindCloudflareTunnel: …
access_client_id: str

Defines the Client ID of the Access token to use when connecting to the origin database.

access_client_secret: str

Defines the Client Secret of the Access Token to use when connecting to the origin database. The API never returns this write-only value.

database: str

Set the name of your origin database.

maxLength2048
host: str

Defines the host (hostname or IP) of your origin database.

password: str

Set the password needed to access your origin database. The API never returns this write-only value.

maxLength2048
scheme: Literal["postgres", "postgresql", "mysql"]

Specifies the URL scheme used to connect to your origin database.

One of the following:
"postgres"
"postgresql"
"mysql"
user: str

Set the user of your origin database.

maxLength2048
class OriginDatabaseReachableThroughAWorkersVPC: …
database: str

Set the name of your origin database.

maxLength2048
password: str

Set the password needed to access your origin database. The API never returns this write-only value.

maxLength2048
scheme: Literal["postgres", "postgresql", "mysql"]

Specifies the URL scheme used to connect to your origin database.

One of the following:
"postgres"
"postgresql"
"mysql"
service_id: str

The identifier of the Workers VPC Service to connect through. Hyperdrive will egress through the specified VPC Service to reach the origin database.

user: str

Set the user of your origin database.

maxLength2048
caching: Optional[Caching]
One of the following:
class CachingHyperdriveHyperdriveCachingCommon: …
disabled: Optional[bool]

Set to true to disable caching of SQL responses. Default is false.

class CachingHyperdriveHyperdriveCachingEnabled: …
disabled: Optional[bool]

Set to true to disable caching of SQL responses. Default is false.

max_age: Optional[int]

Specify the maximum duration (in seconds) items should persist in the cache. Defaults to 60 seconds if not specified.

stale_while_revalidate: Optional[int]

Specify the number of seconds the cache may serve a stale response. Defaults to 15 seconds if not specified.

mtls: Optional[MTLS]

mTLS configuration for the origin connection. Cannot be used with VPC Service origins; TLS must be managed on the VPC Service.

ca_certificate_id: Optional[str]

Define CA certificate ID obtained after uploading CA cert.

mtls_certificate_id: Optional[str]

Define mTLS certificate ID obtained after uploading client cert.

sslmode: Optional[str]

PostgreSQL accepts require, verify-ca, and verify-full. MySQL accepts REQUIRED, VERIFY_CA, and VERIFY_IDENTITY. The verify modes require a CA certificate; the require modes cannot be used with a CA certificate.

origin_connection_limit: Optional[int]

The (soft) maximum number of connections the Hyperdrive is allowed to make to the origin database.

Maximum allowed: 20 for free tier accounts, 100 for paid tier accounts. If not specified, defaults to 20 for free tier and 60 for paid tier. Certain Cloudflare-managed origins may be permitted a higher limit. Contact Cloudflare if you need a higher limit.

minimum5
ReturnsExpand Collapse
class ConfigUpdateResponse: …
id: str

Define configurations using a unique string identifier.

maxLength32
caching: Caching
disabled: bool

Defines whether caching is disabled.

max_age: Optional[int]

Defines the maximum duration (in seconds) items persist in the cache.

maximum3600
minimum1
stale_while_revalidate: Optional[int]

Defines the number of seconds the cache may serve a stale response.

minimum0
name: str

The name of the Hyperdrive configuration. Used to identify the configuration in the Cloudflare dashboard and API.

maxLength2048
origin: Origin

Combines database connection fields with exactly one supported network location.

One of the following:
class OriginPublicDatabase: …
database: str

Set the name of your origin database.

maxLength2048
host: str

Defines the publicly reachable hostname or IP of your origin database. Private, loopback, and link-local IP addresses are not allowed.

password: str

Set the password needed to access your origin database. The API never returns this write-only value.

maxLength2048
port: int

Defines the port of your origin database. Defaults to 5432 for PostgreSQL or 3306 for MySQL if not specified.

maximum65535
minimum1
scheme: Literal["postgres", "postgresql", "mysql"]

Specifies the URL scheme used to connect to your origin database.

One of the following:
"postgres"
"postgresql"
"mysql"
user: str

Set the user of your origin database.

maxLength2048
class OriginAccessProtectedDatabaseBehindCloudflareTunnel: …
access_client_id: str

Defines the Client ID of the Access token to use when connecting to the origin database.

access_client_secret: str

Defines the Client Secret of the Access Token to use when connecting to the origin database. The API never returns this write-only value.

database: str

Set the name of your origin database.

maxLength2048
host: str

Defines the host (hostname or IP) of your origin database.

password: str

Set the password needed to access your origin database. The API never returns this write-only value.

maxLength2048
scheme: Literal["postgres", "postgresql", "mysql"]

Specifies the URL scheme used to connect to your origin database.

One of the following:
"postgres"
"postgresql"
"mysql"
user: str

Set the user of your origin database.

maxLength2048
class OriginDatabaseReachableThroughAWorkersVPC: …
database: str

Set the name of your origin database.

maxLength2048
password: str

Set the password needed to access your origin database. The API never returns this write-only value.

maxLength2048
scheme: Literal["postgres", "postgresql", "mysql"]

Specifies the URL scheme used to connect to your origin database.

One of the following:
"postgres"
"postgresql"
"mysql"
service_id: str

The identifier of the Workers VPC Service to connect through. Hyperdrive will egress through the specified VPC Service to reach the origin database.

user: str

Set the user of your origin database.

maxLength2048
created_on: Optional[datetime]

Defines the creation time of the Hyperdrive configuration.

formatdate-time
integration: Optional[Integration]

Connects to a PlanetScale database using credentials managed by Cloudflare. The Cloudflare account must already be linked to PlanetScale in the Hyperdrive dashboard.

database_branch_name: str

The name of the PlanetScale database branch.

maxLength2048
minLength1
database_name: str

The name of the PlanetScale database.

maxLength2048
minLength1
organization_name: str

The name of the PlanetScale organization.

maxLength2048
minLength1
provider: Literal["planetscale"]

The database integration provider used by this operation.

scheme: Literal["postgres", "postgresql", "mysql"]

Specifies the URL scheme used to connect to your origin database.

One of the following:
"postgres"
"postgresql"
"mysql"
custom_database_name: Optional[str]

The database name to use when connecting. Defaults to postgres for PostgreSQL and mysql for MySQL.

maxLength2048
modified_on: Optional[datetime]

Defines the last modified time of the Hyperdrive configuration.

formatdate-time
mtls: Optional[MTLS]

mTLS configuration for the origin connection. Cannot be used with VPC Service origins; TLS must be managed on the VPC Service.

ca_certificate_id: Optional[str]

Define CA certificate ID obtained after uploading CA cert.

mtls_certificate_id: Optional[str]

Define mTLS certificate ID obtained after uploading client cert.

sslmode: Optional[str]

PostgreSQL accepts require, verify-ca, and verify-full. MySQL accepts REQUIRED, VERIFY_CA, and VERIFY_IDENTITY. The verify modes require a CA certificate; the require modes cannot be used with a CA certificate.

origin_connection_limit: Optional[int]

The (soft) maximum number of connections the Hyperdrive is allowed to make to the origin database.

Maximum allowed: 20 for free tier accounts, 100 for paid tier accounts. If not specified, defaults to 20 for free tier and 60 for paid tier. Certain Cloudflare-managed origins may be permitted a higher limit. Contact Cloudflare if you need a higher limit.

minimum5
restarted_on: Optional[datetime]

Defines the last time the Hyperdrive connection pool was explicitly restarted via the restart endpoint. Omitted if the pool has never been explicitly restarted.

formatdate-time

Replace Hyperdrive

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
config = client.hyperdrive.configs.update(
    hyperdrive_id="023e105f4ecef8ad9ca31a8372d0c353",
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
    name="example-hyperdrive",
    origin={
        "database": "postgres",
        "host": "database.example.com",
        "password": "password",
        "port": 5432,
        "scheme": "postgres",
        "user": "postgres",
    },
)
print(config.id)
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "023e105f4ecef8ad9ca31a8372d0c353",
    "caching": {
      "disabled": true,
      "max_age": 1,
      "stale_while_revalidate": 0
    },
    "name": "example-hyperdrive",
    "origin": {
      "database": "postgres",
      "host": "database.example.com",
      "port": 5432,
      "scheme": "postgres",
      "user": "postgres"
    },
    "created_on": "2017-01-01T00:00:00Z",
    "integration": {
      "database_branch_name": "x",
      "database_name": "x",
      "organization_name": "x",
      "provider": "planetscale",
      "scheme": "postgres",
      "custom_database_name": "custom_database_name"
    },
    "modified_on": "2017-01-01T00:00:00Z",
    "mtls": {
      "ca_certificate_id": "00000000-0000-0000-0000-0000000000",
      "mtls_certificate_id": "00000000-0000-0000-0000-0000000000",
      "sslmode": "verify-full"
    },
    "origin_connection_limit": 60,
    "restarted_on": "2017-01-01T00:00:00Z"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "id": "023e105f4ecef8ad9ca31a8372d0c353",
    "caching": {
      "disabled": true,
      "max_age": 1,
      "stale_while_revalidate": 0
    },
    "name": "example-hyperdrive",
    "origin": {
      "database": "postgres",
      "host": "database.example.com",
      "port": 5432,
      "scheme": "postgres",
      "user": "postgres"
    },
    "created_on": "2017-01-01T00:00:00Z",
    "integration": {
      "database_branch_name": "x",
      "database_name": "x",
      "organization_name": "x",
      "provider": "planetscale",
      "scheme": "postgres",
      "custom_database_name": "custom_database_name"
    },
    "modified_on": "2017-01-01T00:00:00Z",
    "mtls": {
      "ca_certificate_id": "00000000-0000-0000-0000-0000000000",
      "mtls_certificate_id": "00000000-0000-0000-0000-0000000000",
      "sslmode": "verify-full"
    },
    "origin_connection_limit": 60,
    "restarted_on": "2017-01-01T00:00:00Z"
  },
  "success": true
}