## Create Hyperdrive `client.Hyperdrive.Configs.New(ctx, params) (*Hyperdrive, error)` **post** `/accounts/{account_id}/hyperdrive/configs` Creates and returns a new Hyperdrive configuration. ### Parameters - `params ConfigNewParams` - `AccountID param.Field[string]` Path param: Define configurations using a unique string identifier. - `Hyperdrive param.Field[Hyperdrive]` Body param ### Returns - `type Hyperdrive struct{…}` - `ID string` Define configurations using a unique string identifier. - `Name string` The name of the Hyperdrive configuration. Used to identify the configuration in the Cloudflare dashboard and API. - `Origin HyperdriveOrigin` - `type HyperdriveOriginPublicDatabase struct{…}` - `Database string` Set the name of your origin database. - `Host string` Defines the host (hostname or IP) of your origin database. - `Password string` Set the password needed to access your origin database. The API never returns this write-only value. - `Port int64` Defines the port of your origin database. Defaults to 5432 for PostgreSQL or 3306 for MySQL if not specified. - `Scheme HyperdriveOriginPublicDatabaseScheme` Specifies the URL scheme used to connect to your origin database. - `const HyperdriveOriginPublicDatabaseSchemePostgres HyperdriveOriginPublicDatabaseScheme = "postgres"` - `const HyperdriveOriginPublicDatabaseSchemePostgresql HyperdriveOriginPublicDatabaseScheme = "postgresql"` - `const HyperdriveOriginPublicDatabaseSchemeMysql HyperdriveOriginPublicDatabaseScheme = "mysql"` - `User string` Set the user of your origin database. - `type HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnel struct{…}` - `AccessClientID string` Defines the Client ID of the Access token to use when connecting to the origin database. - `AccessClientSecret string` 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 string` Set the name of your origin database. - `Host string` Defines the host (hostname or IP) of your origin database. - `Password string` Set the password needed to access your origin database. The API never returns this write-only value. - `Scheme HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnelScheme` Specifies the URL scheme used to connect to your origin database. - `const HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnelSchemePostgres HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnelScheme = "postgres"` - `const HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnelSchemePostgresql HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnelScheme = "postgresql"` - `const HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnelSchemeMysql HyperdriveOriginAccessProtectedDatabaseBehindCloudflareTunnelScheme = "mysql"` - `User string` Set the user of your origin database. - `Caching HyperdriveCaching` - `type HyperdriveCachingHyperdriveHyperdriveCachingCommon struct{…}` - `Disabled bool` Set to true to disable caching of SQL responses. Default is false. - `type HyperdriveCachingHyperdriveHyperdriveCachingEnabled struct{…}` - `Disabled bool` Set to true to disable caching of SQL responses. Default is false. - `MaxAge int64` Specify the maximum duration (in seconds) items should persist in the cache. Defaults to 60 seconds if not specified. - `StaleWhileRevalidate int64` Specify the number of seconds the cache may serve a stale response. Defaults to 15 seconds if not specified. - `CreatedOn Time` Defines the creation time of the Hyperdrive configuration. - `ModifiedOn Time` Defines the last modified time of the Hyperdrive configuration. - `MTLS HyperdriveMTLS` - `CACertificateID string` Define CA certificate ID obtained after uploading CA cert. - `MTLSCertificateID string` Define mTLS certificate ID obtained after uploading client cert. - `Sslmode string` Set SSL mode to 'require', 'verify-ca', or 'verify-full' to verify the CA. - `OriginConnectionLimit int64` 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. Contact Cloudflare if you need a higher limit. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/hyperdrive" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) hyperdrive, err := client.Hyperdrive.Configs.New(context.TODO(), hyperdrive.ConfigNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Hyperdrive: hyperdrive.HyperdriveParam{ Name: cloudflare.F("example-hyperdrive"), Origin: cloudflare.F[hyperdrive.HyperdriveOriginUnionParam](hyperdrive.HyperdriveOriginPublicDatabaseParam{ Database: cloudflare.F("postgres"), Host: cloudflare.F("database.example.com"), Password: cloudflare.F("password"), Port: cloudflare.F(int64(5432)), Scheme: cloudflare.F(hyperdrive.HyperdriveOriginPublicDatabaseSchemePostgres), User: cloudflare.F("postgres"), }), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", hyperdrive.ID) } ``` #### Response ```json { "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", "name": "example-hyperdrive", "origin": { "database": "postgres", "host": "database.example.com", "port": 5432, "scheme": "postgres", "user": "postgres" }, "caching": { "disabled": true }, "created_on": "2017-01-01T00:00:00Z", "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 }, "success": true } ```