Skip to content
Start here

Create Workers VPC connectivity service

client.Connectivity.Directory.Services.New(ctx, params) (*DirectoryServiceNewResponse, error)
POST/accounts/{account_id}/connectivity/directory/services

Create Workers VPC connectivity service

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
ParametersExpand Collapse
params DirectoryServiceNewParams
AccountID param.Field[string]

Path param: Account identifier

maxLength32
DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraIPv4Host
IPV4 string
Network DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraIPv4HostNetwork
TunnelID string
formatuuid
DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraIPv6Host
IPV6 string
Network DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraIPv6HostNetwork
TunnelID string
formatuuid
DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraDualStackHost
IPV4 string
IPV6 string
Network DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraDualStackHostNetwork
TunnelID string
formatuuid
DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraHostnameHost
Hostname string
ResolverNetwork DirectoryServiceNewParamsInfraHTTPServiceConfigHostInfraHostnameHostResolverNetwork
TunnelID string
formatuuid
ResolverIPs []stringOptional
Name param.Field[string]

Body param

const DirectoryServiceNewParamsInfraHTTPServiceConfigTypeTCP DirectoryServiceNewParamsInfraHTTPServiceConfigType = "tcp"
const DirectoryServiceNewParamsInfraHTTPServiceConfigTypeHTTP DirectoryServiceNewParamsInfraHTTPServiceConfigType = "http"
HTTPPort param.Field[int64]Optional

Body param

formatint32
minimum1
HTTPSPort param.Field[int64]Optional

Body param

formatint32
minimum1

Body param: TLS settings for a connectivity service.

If omitted, the default mode (verify_full) is used.

CERTVerificationMode string

TLS certificate verification mode for the connection to the origin.

  • "verify_full" — verify certificate chain and hostname (default)
  • "verify_ca" — verify certificate chain only, skip hostname check
  • "disabled" — do not verify the server certificate at all
ReturnsExpand Collapse
type DirectoryServiceNewResponse interface{…}
One of the following:
type DirectoryServiceNewResponseInfraHTTPServiceConfig struct{…}
Host DirectoryServiceNewResponseInfraHTTPServiceConfigHost
One of the following:
type DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraIPv4Host struct{…}
IPV4 string
Network DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraIPv4HostNetwork
TunnelID string
formatuuid
type DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraIPv6Host struct{…}
IPV6 string
Network DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraIPv6HostNetwork
TunnelID string
formatuuid
type DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraDualStackHost struct{…}
IPV4 string
IPV6 string
Network DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraDualStackHostNetwork
TunnelID string
formatuuid
type DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraHostnameHost struct{…}
Hostname string
ResolverNetwork DirectoryServiceNewResponseInfraHTTPServiceConfigHostInfraHostnameHostResolverNetwork
TunnelID string
formatuuid
ResolverIPs []stringOptional
Name string
Type DirectoryServiceNewResponseInfraHTTPServiceConfigType
One of the following:
const DirectoryServiceNewResponseInfraHTTPServiceConfigTypeTCP DirectoryServiceNewResponseInfraHTTPServiceConfigType = "tcp"
const DirectoryServiceNewResponseInfraHTTPServiceConfigTypeHTTP DirectoryServiceNewResponseInfraHTTPServiceConfigType = "http"
CreatedAt TimeOptional
formatdate-time
HTTPPort int64Optional
formatint32
minimum1
HTTPSPort int64Optional
formatint32
minimum1
ServiceID stringOptional
formatuuid
TLSSettings DirectoryServiceNewResponseInfraHTTPServiceConfigTLSSettingsOptional

TLS settings for a connectivity service.

If omitted, the default mode (verify_full) is used.

CERTVerificationMode string

TLS certificate verification mode for the connection to the origin.

  • "verify_full" — verify certificate chain and hostname (default)
  • "verify_ca" — verify certificate chain only, skip hostname check
  • "disabled" — do not verify the server certificate at all
UpdatedAt TimeOptional
formatdate-time
type DirectoryServiceNewResponseInfraTCPServiceConfig struct{…}
Host DirectoryServiceNewResponseInfraTCPServiceConfigHost
One of the following:
type DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraIPv4Host struct{…}
IPV4 string
Network DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraIPv4HostNetwork
TunnelID string
formatuuid
type DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraIPv6Host struct{…}
IPV6 string
Network DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraIPv6HostNetwork
TunnelID string
formatuuid
type DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraDualStackHost struct{…}
IPV4 string
IPV6 string
Network DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraDualStackHostNetwork
TunnelID string
formatuuid
type DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraHostnameHost struct{…}
Hostname string
ResolverNetwork DirectoryServiceNewResponseInfraTCPServiceConfigHostInfraHostnameHostResolverNetwork
TunnelID string
formatuuid
ResolverIPs []stringOptional
Name string
Type DirectoryServiceNewResponseInfraTCPServiceConfigType
One of the following:
const DirectoryServiceNewResponseInfraTCPServiceConfigTypeTCP DirectoryServiceNewResponseInfraTCPServiceConfigType = "tcp"
const DirectoryServiceNewResponseInfraTCPServiceConfigTypeHTTP DirectoryServiceNewResponseInfraTCPServiceConfigType = "http"
AppProtocol DirectoryServiceNewResponseInfraTCPServiceConfigAppProtocolOptional
One of the following:
const DirectoryServiceNewResponseInfraTCPServiceConfigAppProtocolPostgresql DirectoryServiceNewResponseInfraTCPServiceConfigAppProtocol = "postgresql"
const DirectoryServiceNewResponseInfraTCPServiceConfigAppProtocolMysql DirectoryServiceNewResponseInfraTCPServiceConfigAppProtocol = "mysql"
CreatedAt TimeOptional
formatdate-time
ServiceID stringOptional
formatuuid
TCPPort int64Optional
formatint32
minimum1
TLSSettings DirectoryServiceNewResponseInfraTCPServiceConfigTLSSettingsOptional

TLS settings for a connectivity service.

If omitted, the default mode (verify_full) is used.

CERTVerificationMode string

TLS certificate verification mode for the connection to the origin.

  • "verify_full" — verify certificate chain and hostname (default)
  • "verify_ca" — verify certificate chain only, skip hostname check
  • "disabled" — do not verify the server certificate at all
UpdatedAt TimeOptional
formatdate-time

Create Workers VPC connectivity service

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/connectivity"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  service, err := client.Connectivity.Directory.Services.New(context.TODO(), connectivity.DirectoryServiceNewParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Body: connectivity.DirectoryServiceNewParamsBodyInfraHTTPServiceConfig{
      Host: cloudflare.F[connectivity.DirectoryServiceNewParamsBodyInfraHTTPServiceConfigHostUnion](connectivity.DirectoryServiceNewParamsBodyInfraHTTPServiceConfigHostInfraHostnameHost{
        Hostname: cloudflare.F("api.example.com"),
        ResolverNetwork: cloudflare.F(connectivity.DirectoryServiceNewParamsBodyInfraHTTPServiceConfigHostInfraHostnameHostResolverNetwork{
          TunnelID: cloudflare.F("0191dce4-9ab4-7fce-b660-8e5dec5172da"),
        }),
      }),
      Name: cloudflare.F("web-server"),
      Type: cloudflare.F(connectivity.DirectoryServiceNewParamsBodyInfraHTTPServiceConfigTypeHTTP),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", service)
}
{
  "errors": [],
  "messages": [],
  "result": {
    "created_at": "2024-01-15T09:30:00Z",
    "host": {
      "hostname": "api.example.com",
      "resolver_network": {
        "tunnel_id": "0191dce4-9ab4-7fce-b660-8e5dec5172da"
      }
    },
    "name": "web-server",
    "service_id": "550e8400-e29b-41d4-a716-446655440000",
    "type": "http",
    "updated_at": "2024-01-15T09:30:00Z"
  },
  "success": true
}
{
  "errors": [],
  "messages": [],
  "result": {
    "created_at": "2024-01-15T09:30:00Z",
    "host": {
      "ipv4": "10.0.0.1",
      "network": {
        "tunnel_id": "0191dce4-9ab4-7fce-b660-8e5dec5172da"
      }
    },
    "name": "postgres-db",
    "service_id": "550e8400-e29b-41d4-a716-446655440001",
    "tcp_port": 5432,
    "type": "tcp",
    "updated_at": "2024-01-15T09:30:00Z"
  },
  "success": true
}
Returns Examples
{
  "errors": [],
  "messages": [],
  "result": {
    "created_at": "2024-01-15T09:30:00Z",
    "host": {
      "hostname": "api.example.com",
      "resolver_network": {
        "tunnel_id": "0191dce4-9ab4-7fce-b660-8e5dec5172da"
      }
    },
    "name": "web-server",
    "service_id": "550e8400-e29b-41d4-a716-446655440000",
    "type": "http",
    "updated_at": "2024-01-15T09:30:00Z"
  },
  "success": true
}
{
  "errors": [],
  "messages": [],
  "result": {
    "created_at": "2024-01-15T09:30:00Z",
    "host": {
      "ipv4": "10.0.0.1",
      "network": {
        "tunnel_id": "0191dce4-9ab4-7fce-b660-8e5dec5172da"
      }
    },
    "name": "postgres-db",
    "service_id": "550e8400-e29b-41d4-a716-446655440001",
    "tcp_port": 5432,
    "type": "tcp",
    "updated_at": "2024-01-15T09:30:00Z"
  },
  "success": true
}