### Get Cloud Integration Initial Setup Source: https://github.com/cloudflare/cloudflare-go/blob/main/magic_cloud_networking/api.md Obtain the initial setup information for a cloud integration. This requires the provider ID and specific query parameters. ```go client.MagicCloudNetworking.CloudIntegrations.InitialSetup(ctx context.Context, providerID string, query magic_cloud_networking.CloudIntegrationInitialSetupParams) (*magic_cloud_networking.CloudIntegrationInitialSetupResponse, error) ``` -------------------------------- ### Get Initial Setup for Cloud Integration Source: https://github.com/cloudflare/cloudflare-go/blob/main/magic_cloud_networking/api.md Retrieves the initial setup information for a cloud integration. ```APIDOC ## GET /accounts/{account_id}/magic/cloud/providers/{provider_id}/initial_setup ### Description Retrieves the initial setup information for a cloud integration. ### Method GET ### Endpoint `/accounts/{account_id}/magic/cloud/providers/{provider_id}/initial_setup` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **provider_id** (string) - Required - The ID of the cloud provider. #### Query Parameters - **query** (CloudIntegrationInitialSetupParams) - Required - Parameters for the initial setup. ``` -------------------------------- ### Run Example Source: https://github.com/cloudflare/cloudflare-go/blob/main/CONTRIBUTING.md Execute your added example using the go run command. ```sh go run ./examples/ ``` -------------------------------- ### Add Example to Project Source: https://github.com/cloudflare/cloudflare-go/blob/main/CONTRIBUTING.md Create a new Go file in the examples directory to add a new example. The generator will not modify files in this directory. ```go package main func main() { // ... } ``` -------------------------------- ### Install Specific Version of Cloudflare Go Library Source: https://github.com/cloudflare/cloudflare-go/blob/main/README.md Use 'go get' to install a specific version of the Cloudflare Go library. This is useful for pinning dependencies. ```sh go get -u 'github.com/cloudflare/cloudflare-go/v6@v6.10.0' ``` -------------------------------- ### Bootstrap and Build Project Source: https://github.com/cloudflare/cloudflare-go/blob/main/CONTRIBUTING.md Run these scripts to install dependencies and build the SDK. Ensure Go 1.22+ is installed manually if needed. ```sh ./scripts/bootstrap ./scripts/build ``` -------------------------------- ### Start Track Recording Source: https://github.com/cloudflare/cloudflare-go/blob/main/realtime_kit/api.md Starts a recording for a specific track within a Realtime Kit application. ```APIDOC ## StartTrackRecording ### Description Initiates a recording for a specific track within a Realtime Kit application. ### Method POST ### Endpoint `/accounts/{account_id}/realtime/kit/{app_id}/recordings/track` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **app_id** (string) - Required - The ID of the Realtime Kit application. #### Request Body - **track_id** (string) - Required - The ID of the track to record. - **recording_name** (string) - Optional - A name for the recording. - **metadata** (object) - Optional - Additional metadata to associate with the recording. ### Request Example ```json { "track_id": "track_xyz789", "recording_name": "Track Recording", "metadata": { "source": "camera" } } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the operation was successful. - **errors** (array) - A list of errors encountered during the operation. - **messages** (array) - A list of messages related to the operation. #### Response Example ```json { "success": true, "errors": [], "messages": ["Track recording started successfully"] } ``` ``` -------------------------------- ### Start a Tracked Realtime Kit Recording Source: https://github.com/cloudflare/cloudflare-go/blob/main/realtime_kit/api.md Starts a recording that tracks specific data. This method requires parameters defining the tracked recording configuration. ```go client.RealtimeKit.Recordings.StartTrackRecording(ctx context.Context, appID string, params realtime_kit.RecordingStartTrackRecordingParams) error ``` -------------------------------- ### Start Livestreaming a Meeting - Go Source: https://github.com/cloudflare/cloudflare-go/blob/main/realtime_kit/api.md Initiates livestreaming for a given meeting. Requires context, app ID, meeting ID, and parameters for starting the livestream. ```go client.RealtimeKit.Livestreams.StartLivestreamingAMeeting(ctx context.Context, appID string, meetingID string, params realtime_kit.LivestreamStartLivestreamingAMeetingParams) (*realtime_kit.LivestreamStartLivestreamingAMeetingResponse, error) ``` -------------------------------- ### Get Brand Protection Matches Source: https://github.com/cloudflare/cloudflare-go/blob/main/brand_protection/api.md Use this method to retrieve a list of brand protection matches. It requires context and get parameters. ```go client.BrandProtection.Matches.Get(ctx, params) ``` -------------------------------- ### Get Configuration Source: https://github.com/cloudflare/cloudflare-go/blob/main/magic_network_monitoring/api.md Retrieves a Magic Network Monitoring configuration. ```APIDOC ## GET /accounts/{account_id}/mnm/config ### Description Retrieves a Magic Network Monitoring configuration. ### Method GET ### Endpoint /accounts/{account_id}/mnm/config ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. #### Query Parameters - **query** (magic_network_monitoring.ConfigGetParams) - Required - Parameters for retrieving the configuration. ``` -------------------------------- ### Get Custom Nameservers Source: https://github.com/cloudflare/cloudflare-go/blob/main/zones/api.md Retrieves the custom nameservers configured for a zone. This is useful for verifying the current custom nameserver setup. ```APIDOC ## Get Custom Nameservers ### Description Retrieves the custom nameservers configured for a zone. ### Method GET ### Endpoint `/zones/{zone_id}/custom_ns` ### Parameters #### Path Parameters - **zone_id** (string) - Required - The ID of the zone to retrieve custom nameservers for. ### Response #### Success Response (200) - **custom_nameservers** (array of strings) - A list of the custom nameservers for the zone. #### Response Example ```json { "custom_nameservers": ["ns1.example.com", "ns2.example.com"] } ``` ``` -------------------------------- ### Start Realtime Kit Recordings Source: https://github.com/cloudflare/cloudflare-go/blob/main/realtime_kit/api.md Initiates new recordings for a specified application. This method requires parameters defining the recording configuration. ```go client.RealtimeKit.Recordings.StartRecordings(ctx context.Context, appID string, params realtime_kit.RecordingStartRecordingsParams) (*realtime_kit.RecordingStartRecordingsResponse, error) ``` -------------------------------- ### Get KV Namespace Information Source: https://github.com/cloudflare/cloudflare-go/blob/main/kv/api.md Use Get to retrieve information about a specific KV namespace. Requires a namespace ID and get parameters. ```go client.KV.Namespaces.Get(ctx context.Context, namespaceID string, query kv.NamespaceGetParams) (*kv.Namespace, error) ``` -------------------------------- ### Initialize Cloudflare Client and Create Zone Source: https://github.com/cloudflare/cloudflare-go/blob/main/README.md Demonstrates initializing the Cloudflare client with an API token and creating a new zone. Ensure the CLOUDFLARE_API_TOKEN environment variable is set or provide the token directly. ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go/v6" "github.com/cloudflare/cloudflare-go/v6/option" "github.com/cloudflare/cloudflare-go/v6/zones" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), // defaults to os.LookupEnv("CLOUDFLARE_API_TOKEN") ) zone, err := client.Zones.New(context.TODO(), zones.ZoneNewParams{ Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), Type: cloudflare.F(zones.TypeFull), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", zone.ID) } ``` -------------------------------- ### Run Mock Server Source: https://github.com/cloudflare/cloudflare-go/blob/main/CONTRIBUTING.md Set up a mock server against the OpenAPI spec to run tests. This script starts the mock server. ```sh ./scripts/mock ``` -------------------------------- ### Get DNSSEC Record Source: https://github.com/cloudflare/cloudflare-go/blob/main/dns/api.md Retrieves the DNSSEC configuration for a zone. Requires DNSSEC get parameters. ```APIDOC ## GET /zones/{zone_id}/dnssec ### Description Retrieves the DNSSEC configuration for a zone. ### Method GET ### Endpoint /zones/{zone_id}/dnssec ### Parameters #### Query Parameters - **query** (dns.DNSSECGetParams) - Required - Parameters for getting DNSSEC. ### Response #### Success Response (200) - **dns.DNSSEC** - The DNSSEC configuration. #### Response Example { "example": { "dnssec_enabled": true } } ``` -------------------------------- ### Start Recordings Source: https://github.com/cloudflare/cloudflare-go/blob/main/realtime_kit/api.md Initiates new recordings for a specified Realtime Kit application. ```APIDOC ## StartRecordings ### Description Starts one or more new recordings for a given Realtime Kit application. ### Method POST ### Endpoint `/accounts/{account_id}/realtime/kit/{app_id}/recordings` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **app_id** (string) - Required - The ID of the Realtime Kit application. #### Request Body - **recording_name** (string) - Optional - A name for the recording. - **metadata** (object) - Optional - Additional metadata to associate with the recording. ### Request Example ```json { "recording_name": "My First Recording", "metadata": { "user_id": "user123" } } ``` ### Response #### Success Response (200) - **recording_id** (string) - The ID of the newly created recording. - **success** (boolean) - Indicates if the operation was successful. - **errors** (array) - A list of errors encountered during the operation. - **messages** (array) - A list of messages related to the operation. #### Response Example ```json { "recording_id": "rec_abc123", "success": true, "errors": [], "messages": ["Recording started successfully"] } ``` ``` -------------------------------- ### Get SSL Verification Source: https://github.com/cloudflare/cloudflare-go/blob/main/ssl/api.md Retrieves a list of SSL verification records. This method corresponds to a GET request. ```APIDOC ## GET /zones/{zone_id}/ssl/verification ### Description Retrieves a list of SSL verification records for a zone. ### Method GET ### Endpoint /zones/{zone_id}/ssl/verification ### Parameters #### Path Parameters - **zone_id** (string) - Required - The ID of the zone. #### Query Parameters - **params** (ssl.VerificationGetParams) - Required - Parameters for retrieving verification records. ### Request Example ```json { "example": "request body for VerificationGetParams" } ``` ### Response #### Success Response (200) - **Response** ([]ssl.Verification) - A list of SSL verification records. #### Response Example ```json { "example": "response body for list of Verification" } ``` ``` -------------------------------- ### Launch a browser instance Source: https://github.com/cloudflare/cloudflare-go/blob/main/browser_rendering/api.md Launches a new browser instance. This method is used to start a browser process that can then be used to create sessions. ```APIDOC ## GET /accounts/{account_id}/browser-rendering/devtools/browser ### Description Launches a new browser instance. ### Method GET ### Endpoint /accounts/{account_id}/browser-rendering/devtools/browser ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account to launch the browser instance for. #### Query Parameters - **params** (object) - Optional - Parameters for launching the browser instance. - **url** (string) - Optional - The URL to navigate to when the browser instance starts. - **browser_params** (object) - Optional - Parameters for configuring the browser instance. - **args** (array of strings) - Optional - Command-line arguments to pass to the browser. - **env** (object) - Optional - Environment variables to set for the browser process. ### Response #### Success Response (200) - This endpoint returns an error object if the launch fails. A successful launch is typically indicated by the absence of an error. #### Response Example (No specific JSON response body is defined for a successful launch. An error response would be a JSON object describing the error.) ```json { "error": "Failed to launch browser" } ``` ``` -------------------------------- ### Manage DNS Records with Go Source: https://context7.com/cloudflare/cloudflare-go/llms.txt This snippet demonstrates how to create, batch update, import, and list DNS records for a given zone. It includes examples for A records and BIND zone file import. Auto-paging is used for listing records. ```go package main import ( "context" "fmt" "strings" "github.com/cloudflare/cloudflare-go/v6" "github.com/cloudflare/cloudflare-go/v6/option" "github.com/cloudflare/cloudflare-go/v6/dns" ) func main() { client := cloudflare.NewClient(option.WithAPIToken("YOUR_TOKEN")) ctx := context.TODO() zoneID := "023e105f4ecef8ad9ca31a8372d0c353" // Create an A record rec, err := client.DNS.Records.New(ctx, dns.RecordNewParams{ ZoneID: cloudflare.F(zoneID), Name: cloudflare.F("api.example.com"), Type: cloudflare.F(dns.RecordNewParamsTypeA), Content: cloudflare.F("192.0.2.10"), TTL: cloudflare.F(dns.TTLUnion(dns.TTL1)), Proxied: cloudflare.F(true), }) if err != nil { panic(err.Error()) } fmt.Printf("Created record %s → %s\n", rec.Name, rec.Content) // Batch create/update/delete in one request _, err = client.DNS.Records.Batch(ctx, dns.RecordBatchParams{ ZoneID: cloudflare.F(zoneID), Posts: cloudflare.F([]dns.BatchPutUnionParam{ dns.ARecordParam{ Name: cloudflare.F("www.example.com"), Type: cloudflare.F(dns.ARecordTypeA), Content: cloudflare.F("192.0.2.20"), TTL: cloudflare.F(dns.TTLUnion(dns.TTL1)), }, }), }) if err != nil { panic(err.Error()) } // Import a BIND zone file zoneFile := strings.NewReader("www 300 IN A 192.0.2.30\n") result, err := client.DNS.Records.Import(ctx, dns.RecordImportParams{ ZoneID: cloudflare.F(zoneID), File: cloudflare.F[interface{}](zoneFile), }) if err != nil { panic(err.Error()) } fmt.Printf("Imported %d records\n", result.RecsAdded) // List all records (auto-paging) iter := client.DNS.Records.ListAutoPaging(ctx, dns.RecordListParams{ ZoneID: cloudflare.F(zoneID), }) for iter.Next() { r := iter.Current() fmt.Printf(" %s %s %s\n", r.Name, r.Type, r.Content) } _ = iter.Err() } ``` -------------------------------- ### Get Subscription Source: https://github.com/cloudflare/cloudflare-go/blob/main/zones/api.md Retrieves the subscription details for a zone. This method corresponds to the GET /zones/{zone_id}/subscription endpoint. ```APIDOC ## GET /zones/{zone_id}/subscription ### Description Retrieves the subscription details for a zone. ### Method GET ### Endpoint /zones/{zone_id}/subscription ### Parameters #### Path Parameters - **zone_id** (string) - Required - The ID of the zone to retrieve the subscription for. #### Query Parameters - **query** (zones.SubscriptionGetParams) - Required - Parameters for retrieving subscription details. ### Request Example ```json { "example": "SubscriptionGetParams object" } ``` ### Response #### Success Response (200) - **SubscriptionGetResponse** (zones.SubscriptionGetResponse) - Details of the zone's subscription. ### Response Example ```json { "example": "SubscriptionGetResponse object" } ``` ``` -------------------------------- ### Get Messages Source: https://github.com/cloudflare/cloudflare-go/blob/main/cloudforce_one/api.md Retrieves messages for a given request. This operation corresponds to the `Get` method in the Cloudforce One SDK. ```APIDOC ## POST /accounts/{account_id}/cloudforce-one/requests/{request_id}/message ### Description Retrieves a list of messages associated with a specific request. ### Method POST ### Endpoint /accounts/{account_id}/cloudforce-one/requests/{request_id}/message ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **request_id** (string) - Required - The ID of the request. #### Request Body - **params** (cloudforce_one.RequestMessageGetParams) - Required - Parameters for retrieving messages. ### Response #### Success Response (200) - **SinglePage[Message]** (pagination.SinglePage[cloudforce_one.Message]) - A paginated response containing a list of messages. - **error** (error) - An error object if the operation failed. ``` -------------------------------- ### Implementing Pagination in Go with Cloudflare SDK Source: https://context7.com/cloudflare/cloudflare-go/llms.txt Use `ListAutoPaging` for automatic iteration over all pages or `List` with `.GetNextPage()` for manual control. Ensure the client is initialized with valid API credentials. ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go/v6" "github.com/cloudflare/cloudflare-go/v6/option" "github.com/cloudflare/cloudflare-go/v6/accounts" ) func main() { client := cloudflare.NewClient(option.WithAPIToken("YOUR_TOKEN")) // Auto-paging — fetches all pages transparently iter := client.Accounts.ListAutoPaging(context.TODO(), accounts.AccountListParams{}) for iter.Next() { acct := iter.Current() fmt.Printf("Account: %s (%s)\n", acct.Name, acct.ID) } if err := iter.Err(); err != nil { panic(err.Error()) } // Manual paging — inspect each page page, err := client.Accounts.List(context.TODO(), accounts.AccountListParams{}) if err != nil { panic(err.Error()) } for page != nil { for _, acct := range page.Result { fmt.Printf("Account: %s\n", acct.Name) } page, err = page.GetNextPage() if err != nil { panic(err.Error()) } } } ``` -------------------------------- ### Get NetFlows Summary Source: https://github.com/cloudflare/cloudflare-go/blob/main/radar/api.md Retrieves a summary of NetFlow data. This endpoint is useful for getting an overview of network traffic patterns. ```APIDOC ## Get NetFlows Summary ### Description Retrieves a summary of NetFlow data. ### Method GET ### Endpoint /radar/netflows/summary ### Parameters #### Query Parameters - **query** (radar.NetFlowsSummaryParams) - Required - Parameters for filtering and shaping the summary response. ### Response #### Success Response (200) - **response** (radar.NetFlowsSummaryResponse) - The summary data for NetFlows. ``` -------------------------------- ### Get Deployment Source: https://github.com/cloudflare/cloudflare-go/blob/main/workers/api.md Retrieves details for a specific deployment of a Workers script. This operation corresponds to the `Get` method in the workers package. ```APIDOC ## GET /accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id} ### Description Fetches the details of a specific deployment for a given Workers script. ### Method GET ### Endpoint `/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **script_name** (string) - Required - The name of the Workers script. - **deployment_id** (string) - Required - The ID of the deployment to retrieve. #### Query Parameters - **query** (workers.ScriptDeploymentGetParams) - Optional - Parameters for retrieving deployment details. ### Request Example ```go // Example usage of Get method // deployment, err := client.Workers.Scripts.Deployments.Get(ctx, "my-script", "deployment-id", workers.ScriptDeploymentGetParams{...}) ``` ### Response #### Success Response (200) - **Deployment** (workers.Deployment) - The details of the requested deployment. ``` -------------------------------- ### Client Initialization — cloudflare.NewClient Source: https://context7.com/cloudflare/cloudflare-go/llms.txt Creates the root API client. All credentials and global defaults are supplied here using `option.*` functions. The `CLOUDFLARE_API_TOKEN` environment variable is read automatically when `option.WithAPIToken` is not called. ```APIDOC ## Client Initialization — cloudflare.NewClient Creates the root API client. All credentials and global defaults are supplied here using `option.*` functions. The `CLOUDFLARE_API_TOKEN` environment variable is read automatically when `option.WithAPIToken` is not called. ```go package main import ( "context" "fmt" "net/http" "time" "github.com/cloudflare/cloudflare-go/v6" "github.com/cloudflare/cloudflare-go/v6/option" "github.com/cloudflare/cloudflare-go/v6/zones" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), option.WithMaxRetries(3), option.WithHeader("X-Custom-Header", "my-app/1.0"), ) // Access a raw HTTP response alongside the typed response var rawResp *http.Response zone, err := client.Zones.New( context.TODO(), zones.ZoneNewParams{ Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), Type: cloudflare.F(zones.TypeFull), }, option.WithResponseInto(&rawResp), ) if err != nil { panic(err.Error()) } fmt.Printf("Zone ID: %s\n", zone.ID) fmt.Printf("HTTP Status: %d\n", rawResp.StatusCode) // Output: // Zone ID: 023e105f4ecef8ad9ca31a8372d0c353 // HTTP Status: 200 } ``` ``` -------------------------------- ### Get Firewall Rule Source: https://github.com/cloudflare/cloudflare-go/blob/main/firewall/api.md Use Get to retrieve a specific firewall rule by its ID. Requires RuleGetParams for query options. ```go client.Firewall.Rules.Get(ctx context.Context, ruleID string, query firewall.RuleGetParams) (*firewall.FirewallRule, error) ``` -------------------------------- ### Get Request Constants Source: https://github.com/cloudflare/cloudflare-go/blob/main/cloudforce_one/api.md Retrieves constants related to Cloudforce One requests. This can be used to get available types or other configuration values. ```APIDOC ## GET /accounts/{account_id}/cloudforce-one/requests/constants ### Description Retrieves constants for Cloudforce One requests. ### Method GET ### Endpoint `/accounts/{account_id}/cloudforce-one/requests/constants` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. #### Query Parameters - **query** (cloudforce_one.RequestConstantsParams) - Optional - Parameters for fetching constants. ### Response #### Success Response (200) - **body** (cloudforce_one.RequestConstants) - The response body containing request constants. #### Error Response - **error** (error) - An error object if fetching constants fails. ``` -------------------------------- ### List Prebuilt Policies Source: https://github.com/cloudflare/cloudflare-go/blob/main/magic_cloud_networking/api.md Retrieves a list of prebuilt policies for a given account. This method allows fetching all available prebuilt policies. ```APIDOC ## GET /accounts/{account_id}/magic/cloud/catalog-syncs/prebuilt-policies ### Description Retrieves a list of prebuilt policies. ### Method GET ### Endpoint /accounts/{account_id}/magic/cloud/catalog-syncs/prebuilt-policies ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. #### Query Parameters - **params** (magic_cloud_networking.CatalogSyncPrebuiltPolicyListParams) - Required - Parameters for listing prebuilt policies. ### Response #### Success Response (200) - **response** (magic_cloud_networking.CatalogSyncPrebuiltPolicyListResponse) - The list of prebuilt policies. #### Response Example { "example": "{\"result\": [{\"id\": \"policy-id-1\", \"name\": \"Example Policy 1\"}, {\"id\": \"policy-id-2\", \"name\": \"Example Policy 2\"}]}" } ``` -------------------------------- ### Create Load Balancer Monitor Preview Source: https://github.com/cloudflare/cloudflare-go/blob/main/load_balancers/api.md Creates a preview of a new load balancer monitor configuration. This is useful for testing monitor settings before applying them. ```APIDOC ## POST /accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview ### Description Creates a preview of a new load balancer monitor configuration. ### Method POST ### Endpoint /accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **monitor_id** (string) - Required - The ID of the monitor to preview. #### Request Body - **params** (load_balancers.MonitorPreviewNewParams) - Required - The parameters for the monitor preview. ### Response #### Success Response (200) - **response** (load_balancers.MonitorPreviewNewResponse) - The response containing the monitor preview details. ``` -------------------------------- ### List Zero Trust Infrastructure Targets Source: https://github.com/cloudflare/cloudflare-go/blob/main/zero_trust/api.md Use this method to list all infrastructure targets. Requires context and list parameters. Supports pagination. ```go client.ZeroTrust.Access.Infrastructure.Targets.List(ctx, params) ``` -------------------------------- ### SFU Get Source: https://github.com/cloudflare/cloudflare-go/blob/main/calls/api.md Retrieves information about an SFU application. This method allows you to get details of a specific SFU configuration within your account. ```APIDOC ## SFU Get ### Description Retrieves information about an SFU application. ### Method GET ### Endpoint `/accounts/{account_id}/calls/apps/{app_id}` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the Cloudflare account. - **app_id** (string) - Required - The ID of the SFU application. #### Query Parameters - **query** (calls.SFUGetParams) - Required - Parameters for fetching SFU details. ### Response #### Success Response (200) - **SFUGetResponse** (calls.SFUGetResponse) - Details of the SFU application. ``` -------------------------------- ### Manage Cloudflare R2 Buckets with Go Source: https://context7.com/cloudflare/cloudflare-go/llms.txt This code demonstrates how to create R2 buckets, set lifecycle rules for object deletion, configure CORS policies, and list existing buckets. Ensure you replace 'YOUR_TOKEN' with your actual API token. ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go/v6" "github.com/cloudflare/cloudflare-go/v6/option" "github.com/cloudflare/cloudflare-go/v6/r2" ) func main() { client := cloudflare.NewClient(option.WithAPIToken("YOUR_TOKEN")) ctx := context.TODO() accountID := "023e105f4ecef8ad9ca31a8372d0c353" // Create a bucket in the EU bucket, err := client.R2.Buckets.New(ctx, r2.BucketNewParams{ AccountID: cloudflare.F(accountID), Name: cloudflare.F("my-assets-bucket"), LocationHint: cloudflare.F(r2.BucketNewParamsLocationHintEu), StorageClass: cloudflare.F(r2.BucketNewParamsStorageClassStandard), }) if err != nil { panic(err.Error()) } fmt.Printf("Bucket: %s (location: %s)\n", bucket.Name, bucket.Location) // Set lifecycle rules — delete objects after 90 days _, err = client.R2.Buckets.Lifecycle.Update(ctx, bucket.Name, r2.BucketLifecycleUpdateParams{ AccountID: cloudflare.F(accountID), Rules: cloudflare.F([]r2.BucketLifecycleUpdateParamsRule{ { ID: cloudflare.F("expire-old-uploads"), Enabled: cloudflare.F(true), Conditions: cloudflare.F(r2.BucketLifecycleUpdateParamsRulesConditions{ Prefix: cloudflare.F("uploads/"), }), Actions: cloudflare.F(r2.BucketLifecycleUpdateParamsRulesActions{ DeleteObjectsAfterDays: cloudflare.F(int64(90)), }), }, }), }) if err != nil { panic(err.Error()) } // Configure CORS _, err = client.R2.Buckets.CORS.Update(ctx, bucket.Name, r2.BucketCORSUpdateParams{ AccountID: cloudflare.F(accountID), Rules: cloudflare.F([]r2.BucketCORSUpdateParamsRule{ { AllowedOrigins: cloudflare.F([]string{"https://example.com"}), AllowedMethods: cloudflare.F([]r2.BucketCORSUpdateParamsRulesAllowedMethod{ r2.BucketCORSUpdateParamsRulesAllowedMethodGet, r2.BucketCORSUpdateParamsRulesAllowedMethodPut, }), }, }), }) if err != nil { panic(err.Error()) } // List all buckets buckets, err := client.R2.Buckets.List(ctx, r2.BucketListParams{ AccountID: cloudflare.F(accountID), }) if err != nil { panic(err.Error()) } for _, b := range buckets.Buckets { fmt.Printf("Bucket: %s\n", b.Name) } } ``` -------------------------------- ### Get Device Settings Source: https://github.com/cloudflare/cloudflare-go/blob/main/zero_trust/api.md Retrieves the current device settings for an account. This operation uses a GET request to the /accounts/{account_id}/devices/settings endpoint. ```APIDOC ## GET /accounts/{account_id}/devices/settings ### Description Retrieves the current device settings for the specified account. ### Method GET ### Endpoint /accounts/{account_id}/devices/settings ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. #### Query Parameters - **query** (zero_trust.DeviceSettingGetParams) - Optional - Parameters to filter or specify the settings to retrieve. ### Response #### Success Response (200) - **zero_trust.DeviceSettings** - The current device settings. #### Error Response - **error** - An error object if the retrieval fails. ``` -------------------------------- ### Create Browser Rendering Snapshot Source: https://github.com/cloudflare/cloudflare-go/blob/main/browser_rendering/api.md Generates a snapshot of a URL. Provide the context and snapshot parameters to use this method. ```go client.BrowserRendering.Snapshot.New(ctx context.Context, params browser_rendering.SnapshotNewParams) (*browser_rendering.SnapshotNewResponse, error) ``` -------------------------------- ### Import Cloudflare Go Library Source: https://github.com/cloudflare/cloudflare-go/blob/main/README.md Import the Cloudflare Go library for use in your project. This is the standard import path. ```go import ( "github.com/cloudflare/cloudflare-go/v6" ) // imported as cloudflare ``` -------------------------------- ### Get Load Balancer Source: https://github.com/cloudflare/cloudflare-go/blob/main/load_balancers/api.md Retrieves details for a specific load balancer by its ID. Requires context, load balancer ID, and get parameters. ```go client.LoadBalancers.Get(ctx context.Context, loadBalancerID string, query load_balancers.LoadBalancerGetParams) (*load_balancers.LoadBalancer, error) ``` -------------------------------- ### NetworkPath Get Source: https://github.com/cloudflare/cloudflare-go/blob/main/zero_trust/api.md Retrieves the network path details for a specific traceroute test result. This endpoint is used to get detailed information about the network path. ```APIDOC ## GET /accounts/{account_id}/dex/traceroute-test-results/{test_result_id}/network-path ### Description Retrieves the network path for a traceroute test result. ### Method GET ### Endpoint /accounts/{account_id}/dex/traceroute-test-results/{test_result_id}/network-path ### Parameters #### Path Parameters - **testResultID** (string) - Required - The ID of the test result. #### Query Parameters - **query** (zero_trust.DEXTracerouteTestResultNetworkPathGetParams) - Required - Parameters for retrieving the network path. ### Response #### Success Response (200) - **DEXTracerouteTestResultNetworkPathGetResponse** (zero_trust.DEXTracerouteTestResultNetworkPathGetResponse) - The network path details. ``` -------------------------------- ### Run Tests Source: https://github.com/cloudflare/cloudflare-go/blob/main/CONTRIBUTING.md Execute the project's tests. Ensure the mock server is running if required by the tests. ```sh ./scripts/test ``` -------------------------------- ### Initialize Cloudflare Client with Options Source: https://context7.com/cloudflare/cloudflare-go/llms.txt Create a new Cloudflare API client using functional options for authentication, retries, and custom headers. The API token can be automatically read from the CLOUDFLARE_API_TOKEN environment variable if not explicitly provided. ```go package main import ( "context" "fmt" "net/http" "time" "github.com/cloudflare/cloudflare-go/v6" "github.com/cloudflare/cloudflare-go/v6/option" "github.com/cloudflare/cloudflare-go/v6/zones" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), option.WithMaxRetries(3), option.WithHeader("X-Custom-Header", "my-app/1.0"), ) // Access a raw HTTP response alongside the typed response var rawResp *http.Response zone, err := client.Zones.New( context.TODO(), zones.ZoneNewParams{ Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), Type: cloudflare.F(zones.TypeFull), }, option.WithResponseInto(&rawResp), ) if err != nil { panic(err.Error()) } fmt.Printf("Zone ID: %s\n", zone.ID) fmt.Printf("HTTP Status: %d\n", rawResp.StatusCode) // Output: // Zone ID: 023e105f4ecef8ad9ca31a8372d0c353 // HTTP Status: 200 } ``` -------------------------------- ### Get Web Crawler Summary Source: https://github.com/cloudflare/cloudflare-go/blob/main/radar/api.md Retrieves a summary of web crawler data for a specified dimension. This can be used to get aggregated information about web crawlers. ```APIDOC ## Get Web Crawler Summary ### Description Retrieves a summary of web crawler data for a specified dimension. ### Method GET ### Endpoint /radar/bots/crawlers/summary/{dimension} ### Parameters #### Path Parameters - **dimension** (radar.BotWebCrawlerSummaryParamsDimension) - Required - The dimension for which to retrieve the summary. #### Query Parameters - **query** (radar.BotWebCrawlerSummaryParams) - Required - Parameters for the summary query. ### Response #### Success Response (200) - **response** (radar.BotWebCrawlerSummaryResponse) - The summary data for web crawlers. #### Response Example { "example": "response body" } ``` -------------------------------- ### Get Session Details Source: https://github.com/cloudflare/cloudflare-go/blob/main/realtime_kit/api.md Fetches detailed information about a specific Realtime Kit session. Requires context, application ID, session ID, and optional parameters. ```go client.RealtimeKit.Sessions.GetSessionDetails(ctx context.Context, appID string, sessionID string, params realtime_kit.SessionGetSessionDetailsParams) (*realtime_kit.SessionGetSessionDetailsResponse, error) ``` -------------------------------- ### Get Waiting Room Source: https://github.com/cloudflare/cloudflare-go/blob/main/waiting_rooms/api.md Retrieves the details of a specific waiting room. Use this endpoint to get information about a waiting room's configuration and status. ```APIDOC ## GET /zones/{zone_id}/waiting_rooms/{waiting_room_id} ### Description Retrieves a specific waiting room. ### Method GET ### Endpoint /zones/{zone_id}/waiting_rooms/{waiting_room_id} ### Parameters #### Path Parameters - **zone_id** (string) - Required - The ID of the zone. - **waiting_room_id** (string) - Required - The ID of the waiting room to retrieve. #### Query Parameters - **query** (waiting_rooms.WaitingRoomGetParams) - Optional - Parameters for retrieving a waiting room. ``` -------------------------------- ### Create a Custom Zero Trust Device Policy Source: https://github.com/cloudflare/cloudflare-go/blob/main/zero_trust/api.md Use this method to create a new custom device policy. Requires a context and parameters defining the policy. ```go client.ZeroTrust.Devices.Policies.Custom.New(ctx context.Context, params zero_trust.DevicePolicyCustomNewParams) (*zero_trust.SettingsPolicy, error) ``` -------------------------------- ### Get Content Scanning Status Source: https://github.com/cloudflare/cloudflare-go/blob/main/content_scanning/api.md Retrieves the current status and settings of content scanning for a zone. This operation uses a GET request to the settings endpoint. ```APIDOC ## Get Content Scanning Status ### Description Retrieves the current status and settings of content scanning for a zone. ### Method GET ### Endpoint /zones/{zone_id}/content-upload-scan/settings ### Parameters #### Path Parameters - **zone_id** (string) - Required - The ID of the zone to retrieve settings for. ### Response #### Success Response (200) - **result** (ContentScanningGetResponse) - The response object containing the content scanning settings and status. ### Response Example ```json { "example": "response body for ContentScanningGetResponse" } ``` ``` -------------------------------- ### Create Configuration Source: https://github.com/cloudflare/cloudflare-go/blob/main/magic_network_monitoring/api.md Creates a new Magic Network Monitoring configuration for a given account. ```APIDOC ## POST /accounts/{account_id}/mnm/config ### Description Creates a new Magic Network Monitoring configuration. ### Method POST ### Endpoint /accounts/{account_id}/mnm/config ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. #### Request Body - **params** (magic_network_monitoring.ConfigNewParams) - Required - Parameters for creating the configuration. ``` -------------------------------- ### Get Speed Test Source: https://github.com/cloudflare/cloudflare-go/blob/main/speed/api.md Retrieves details of a specific speed test by its ID for a given URL. This method sends a GET request to the speed API endpoint. ```APIDOC ## GET /zones/{zone_id}/speed_api/pages/{url}/tests/{test_id} ### Description Retrieves details of a specific speed test by its ID. ### Method GET ### Endpoint /zones/{zone_id}/speed_api/pages/{url}/tests/{test_id} ### Parameters #### Path Parameters - **zone_id** (string) - Required - The ID of the zone. - **url** (string) - Required - The URL associated with the test. - **test_id** (string) - Required - The ID of the specific test to retrieve. #### Query Parameters - **query** (speed.PageTestGetParams) - Required - Parameters for retrieving a specific page test. ``` -------------------------------- ### Initiate Direct Upload (V2) Source: https://github.com/cloudflare/cloudflare-go/blob/main/images/api.md Initiates a direct upload for an image in V2. Returns details needed to complete the upload. ```APIDOC ## POST /accounts/{account_id}/images/v2/direct_upload ### Description Initiates a direct upload for an image in V2. This method returns the necessary information to proceed with the actual image upload. ### Method POST ### Endpoint `/accounts/{account_id}/images/v2/direct_upload` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the Cloudflare account. #### Request Body - **params** (images.V2DirectUploadNewParams) - Required - Parameters for initiating the direct upload. ``` -------------------------------- ### Get Abuse Report Source: https://github.com/cloudflare/cloudflare-go/blob/main/abuse_reports/api.md Retrieves details of a specific abuse report for a given account. Requires context, a report parameter, and abuse report get parameters. ```APIDOC ## Get Abuse Report ### Description Retrieves details of a specific abuse report. ### Method GET ### Endpoint `/accounts/{account_id}/abuse-reports/{report_param}` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. - **report_param** (string) - Required - The parameter identifying the report. #### Query Parameters - **query** (abuse_reports.AbuseReportGetParams) - Required - Parameters for retrieving the abuse report. ``` -------------------------------- ### Get AI Inference Summary by Dimension Source: https://github.com/cloudflare/cloudflare-go/blob/main/radar/api.md Retrieves a summary of AI inference data for a specified dimension. This can be used to get aggregated insights across different categories. ```APIDOC ## GET /radar/ai/inference/summary/{dimension} ### Description Retrieves a summary of AI inference data for a specified dimension. ### Method GET ### Endpoint `/radar/ai/inference/summary/{dimension}` ### Parameters #### Path Parameters - **dimension** (radar.AIInferenceSummaryV2ParamsDimension) - Required - The dimension to filter the summary by. #### Query Parameters - **query** (radar.AIInferenceSummaryV2Params) - Required - Parameters for the query, such as time range and filters. ### Response #### Success Response (200) - **response** (radar.AIInferenceSummaryV2Response) - The AI inference summary data. #### Response Example { "example": "{\"data\": {}}" } ``` -------------------------------- ### Get Realtime Kit Session Summary Source: https://github.com/cloudflare/cloudflare-go/blob/main/realtime_kit/api.md Retrieves a summary for a specific Realtime Kit session. Requires the application ID and session ID. ```go client.RealtimeKit.Sessions.GetSessionSummary(ctx context.Context, appID string, sessionID string, query realtime_kit.SessionGetSessionSummaryParams) (*realtime_kit.SessionGetSessionSummaryResponse, error) ``` -------------------------------- ### Get Insight Type Source: https://github.com/cloudflare/cloudflare-go/blob/main/security_center/api.md Retrieves the type of security insights for a given account or zone. This method corresponds to the HTTP GET request on the /accounts_or_zones/{account_or_zone_id}/security-center/insights/type endpoint. ```APIDOC ## Get Insight Type ### Description Retrieves the type of security insights for a given account or zone. ### Method GET ### Endpoint `/{accounts_or_zones}/{account_or_zone_id}/security-center/insights/type` ### Parameters #### Query Parameters - **params** (security_center.InsightTypeGetParams) - Required - Parameters for fetching insight type. ### Response #### Success Response (200) - **response** (*[]security_center.InsightTypeGetResponse) - A list of security insight types. #### Error Response - **error** (error) - An error object if the request fails. ``` -------------------------------- ### Create Finetune Source: https://github.com/cloudflare/cloudflare-go/blob/main/ai/api.md Initiates a new finetuning job for an AI model. This allows for custom model training based on specific datasets. ```APIDOC ## Create Finetune ### Description Initiates a new finetuning job for an AI model. ### Method POST ### Endpoint /accounts/{account_id}/ai/finetunes ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the Cloudflare account. #### Request Body - **params** (ai.FinetuneNewParams) - Required - Parameters for creating the finetune job. ### Request Example ```json { "example": "request body for FinetuneNewParams" } ``` ### Response #### Success Response (200) - **response** (ai.FinetuneNewResponse) - Details of the newly created finetune job. #### Response Example ```json { "example": "response body for FinetuneNewResponse" } ``` ``` -------------------------------- ### Create New Pipeline (v1) Source: https://github.com/cloudflare/cloudflare-go/blob/main/pipelines/api.md Creates a new pipeline using the v1 API. Requires a context and pipeline parameters. ```go client.Pipelines.NewV1(ctx context.Context, params pipelines.PipelineNewV1Params) (*pipelines.PipelineNewV1Response, error) ``` -------------------------------- ### Get Insight Severity Source: https://github.com/cloudflare/cloudflare-go/blob/main/security_center/api.md Retrieves the severity of security insights for a given account or zone. This method corresponds to the HTTP GET request on the /accounts_or_zones/{account_or_zone_id}/security-center/insights/severity endpoint. ```APIDOC ## Get Insight Severity ### Description Retrieves the severity of security insights for a given account or zone. ### Method GET ### Endpoint `/{accounts_or_zones}/{account_or_zone_id}/security-center/insights/severity` ### Parameters #### Query Parameters - **params** (security_center.InsightSeverityGetParams) - Required - Parameters for fetching insight severity. ### Response #### Success Response (200) - **response** (*[]security_center.InsightSeverityGetResponse) - A list of security insight severities. #### Error Response - **error** (error) - An error object if the request fails. ``` -------------------------------- ### Create Site Source: https://github.com/cloudflare/cloudflare-go/blob/main/magic_transit/api.md Creates a new Magic Transit site. Requires site details and account ID. ```APIDOC ## POST /accounts/{account_id}/magic/sites ### Description Creates a new Magic Transit site. ### Method POST ### Endpoint `/accounts/{account_id}/magic/sites` ### Parameters #### Path Parameters - **account_id** (string) - Required - The ID of the account. #### Request Body - **params** (magic_transit.SiteNewParams) - Required - Parameters for creating a new site. ### Response #### Success Response (200) - **site** (magic_transit.Site) - The created site object. ``` -------------------------------- ### Bulk Get KV Namespace Entries Source: https://github.com/cloudflare/cloudflare-go/blob/main/kv/api.md Use BulkGet to retrieve multiple key-value pairs from a KV namespace. Requires a namespace ID and bulk get parameters. ```go client.KV.Namespaces.BulkGet(ctx context.Context, namespaceID string, params kv.NamespaceBulkGetParams) (*kv.NamespaceBulkGetResponse, error) ``` -------------------------------- ### Get AI Search Instance Chat Completions Source: https://github.com/cloudflare/cloudflare-go/blob/main/ai_search/api.md Use this method to get chat completions for an AI Search instance. Requires the instance ID and chat completion parameters. ```go client.AISearch.Instances.ChatCompletions(ctx context.Context, id string, params ai_search.InstanceChatCompletionsParams) (*ai_search.InstanceChatCompletionsResponse, error) ``` -------------------------------- ### Create a new Device DEXTest Source: https://github.com/cloudflare/cloudflare-go/blob/main/zero_trust/api.md Use this method to create a new Device DEXTest. Requires context and parameters for the test. ```go client.ZeroTrust.Devices.DEXTests.New(ctx, params) ``` -------------------------------- ### Get Zone Source: https://github.com/cloudflare/cloudflare-go/blob/main/zones/api.md Retrieves details for a specific zone. ```APIDOC ## GET /zones/{zone_id} ### Description Retrieves a zone. ### Method GET ### Endpoint /zones/{zone_id} ### Parameters #### Path Parameters - **zone_id** (string) - Required - The ID of the zone to retrieve. #### Query Parameters - **query** (zones.ZoneGetParams) - Required - Parameters for retrieving a zone. ### Response #### Success Response (200) - **Zone** (zones.Zone) - The zone object. ```