# Vulnerability Scanner # Credential Sets ## List Credential Sets `client.VulnerabilityScanner.CredentialSets.List(ctx, params) (*V4PagePaginationArray[CredentialSetListResponse], error)` **get** `/accounts/{account_id}/vuln_scanner/credential_sets` Returns all credential sets for the account. ### Parameters - `params CredentialSetListParams` - `AccountID param.Field[string]` Path param: Identifier. - `Page param.Field[int64]` Query param: Page number of paginated results. - `PerPage param.Field[int64]` Query param: Number of results per page. ### Returns - `type CredentialSetListResponse struct{…}` - `ID string` Credential set identifier. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.VulnerabilityScanner.CredentialSets.List(context.TODO(), vulnerability_scanner.CredentialSetListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production API credentials" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Create Credential Set `client.VulnerabilityScanner.CredentialSets.New(ctx, params) (*CredentialSetNewResponse, error)` **post** `/accounts/{account_id}/vuln_scanner/credential_sets` Creates a new credential set. ### Parameters - `params CredentialSetNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: Human-readable name. ### Returns - `type CredentialSetNewResponse struct{…}` - `ID string` Credential set identifier. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credentialSet, err := client.VulnerabilityScanner.CredentialSets.New(context.TODO(), vulnerability_scanner.CredentialSetNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Production API credentials"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credentialSet.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production API credentials" }, "result_info": {} } ``` ## Get Credential Set `client.VulnerabilityScanner.CredentialSets.Get(ctx, credentialSetID, query) (*CredentialSetGetResponse, error)` **get** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}` Returns a single credential set by ID. ### Parameters - `credentialSetID string` - `query CredentialSetGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type CredentialSetGetResponse struct{…}` - `ID string` Credential set identifier. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credentialSet, err := client.VulnerabilityScanner.CredentialSets.Get( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credentialSet.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production API credentials" }, "result_info": {} } ``` ## Update Credential Set `client.VulnerabilityScanner.CredentialSets.Update(ctx, credentialSetID, params) (*CredentialSetUpdateResponse, error)` **put** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}` Replaces a credential set. All fields must be provided. ### Parameters - `credentialSetID string` - `params CredentialSetUpdateParams` - `AccountID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: Human-readable name. ### Returns - `type CredentialSetUpdateResponse struct{…}` - `ID string` Credential set identifier. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credentialSet, err := client.VulnerabilityScanner.CredentialSets.Update( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Production API credentials"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credentialSet.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production API credentials" }, "result_info": {} } ``` ## Edit Credential Set `client.VulnerabilityScanner.CredentialSets.Edit(ctx, credentialSetID, params) (*CredentialSetEditResponse, error)` **patch** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}` Updates a credential set with only the provided fields; omitted fields remain unchanged. ### Parameters - `credentialSetID string` - `params CredentialSetEditParams` - `AccountID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: Human-readable name. ### Returns - `type CredentialSetEditResponse struct{…}` - `ID string` Credential set identifier. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.VulnerabilityScanner.CredentialSets.Edit( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production API credentials" }, "result_info": {} } ``` ## Delete Credential Set `client.VulnerabilityScanner.CredentialSets.Delete(ctx, credentialSetID, body) (*CredentialSetDeleteResponse, error)` **delete** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}` Deletes a credential set and all of its credentials. ### Parameters - `credentialSetID string` - `body CredentialSetDeleteParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type CredentialSetDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credentialSet, err := client.VulnerabilityScanner.CredentialSets.Delete( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credentialSet) } ``` #### 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" } } ], "success": true, "result": {}, "result_info": {} } ``` # Credentials ## List Credentials `client.VulnerabilityScanner.CredentialSets.Credentials.List(ctx, credentialSetID, params) (*V4PagePaginationArray[CredentialSetCredentialListResponse], error)` **get** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials` Returns all credentials within a credential set. ### Parameters - `credentialSetID string` - `params CredentialSetCredentialListParams` - `AccountID param.Field[string]` Path param: Identifier. - `Page param.Field[int64]` Query param: Page number of paginated results. - `PerPage param.Field[int64]` Query param: Number of results per page. ### Returns - `type CredentialSetCredentialListResponse struct{…}` A credential attached to API requests during scanning. The credential `value` is write-only and never returned in responses. - `ID string` Credential identifier. - `CredentialSetID string` Parent credential set identifier. - `Location CredentialSetCredentialListResponseLocation` Where the credential is attached in outgoing requests. - `const CredentialSetCredentialListResponseLocationHeader CredentialSetCredentialListResponseLocation = "header"` - `const CredentialSetCredentialListResponseLocationCookie CredentialSetCredentialListResponseLocation = "cookie"` - `LocationName string` Name of the header or cookie where the credential is attached. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.VulnerabilityScanner.CredentialSets.Credentials.List( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetCredentialListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "credential_set_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "location": "header", "location_name": "Authorization", "name": "Admin API key" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Create Credential `client.VulnerabilityScanner.CredentialSets.Credentials.New(ctx, credentialSetID, params) (*CredentialSetCredentialNewResponse, error)` **post** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials` Creates a new credential within a credential set. ### Parameters - `credentialSetID string` - `params CredentialSetCredentialNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `Location param.Field[CredentialSetCredentialNewParamsLocation]` Body param: Where the credential is attached in outgoing requests. - `const CredentialSetCredentialNewParamsLocationHeader CredentialSetCredentialNewParamsLocation = "header"` - `const CredentialSetCredentialNewParamsLocationCookie CredentialSetCredentialNewParamsLocation = "cookie"` - `LocationName param.Field[string]` Body param: Name of the header or cookie where the credential is attached. - `Name param.Field[string]` Body param: Human-readable name. - `Value param.Field[string]` Body param: The credential value (e.g. API key, session token). Write-only. Never returned in responses. ### Returns - `type CredentialSetCredentialNewResponse struct{…}` A credential attached to API requests during scanning. The credential `value` is write-only and never returned in responses. - `ID string` Credential identifier. - `CredentialSetID string` Parent credential set identifier. - `Location CredentialSetCredentialNewResponseLocation` Where the credential is attached in outgoing requests. - `const CredentialSetCredentialNewResponseLocationHeader CredentialSetCredentialNewResponseLocation = "header"` - `const CredentialSetCredentialNewResponseLocationCookie CredentialSetCredentialNewResponseLocation = "cookie"` - `LocationName string` Name of the header or cookie where the credential is attached. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credential, err := client.VulnerabilityScanner.CredentialSets.Credentials.New( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetCredentialNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Location: cloudflare.F(vulnerability_scanner.CredentialSetCredentialNewParamsLocationHeader), LocationName: cloudflare.F("Authorization"), Name: cloudflare.F("Admin API key"), Value: cloudflare.F("Bearer EXAMPLE_TOKEN"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credential.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "credential_set_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "location": "header", "location_name": "Authorization", "name": "Admin API key" }, "result_info": {} } ``` ## Get Credential `client.VulnerabilityScanner.CredentialSets.Credentials.Get(ctx, credentialSetID, credentialID, query) (*CredentialSetCredentialGetResponse, error)` **get** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}` Returns a single credential by ID. ### Parameters - `credentialSetID string` - `credentialID string` - `query CredentialSetCredentialGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type CredentialSetCredentialGetResponse struct{…}` A credential attached to API requests during scanning. The credential `value` is write-only and never returned in responses. - `ID string` Credential identifier. - `CredentialSetID string` Parent credential set identifier. - `Location CredentialSetCredentialGetResponseLocation` Where the credential is attached in outgoing requests. - `const CredentialSetCredentialGetResponseLocationHeader CredentialSetCredentialGetResponseLocation = "header"` - `const CredentialSetCredentialGetResponseLocationCookie CredentialSetCredentialGetResponseLocation = "cookie"` - `LocationName string` Name of the header or cookie where the credential is attached. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credential, err := client.VulnerabilityScanner.CredentialSets.Credentials.Get( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetCredentialGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credential.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "credential_set_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "location": "header", "location_name": "Authorization", "name": "Admin API key" }, "result_info": {} } ``` ## Update Credential `client.VulnerabilityScanner.CredentialSets.Credentials.Update(ctx, credentialSetID, credentialID, params) (*CredentialSetCredentialUpdateResponse, error)` **put** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}` Replaces a credential. All fields must be provided. ### Parameters - `credentialSetID string` - `credentialID string` - `params CredentialSetCredentialUpdateParams` - `AccountID param.Field[string]` Path param: Identifier. - `Location param.Field[CredentialSetCredentialUpdateParamsLocation]` Body param: Where the credential is attached in outgoing requests. - `const CredentialSetCredentialUpdateParamsLocationHeader CredentialSetCredentialUpdateParamsLocation = "header"` - `const CredentialSetCredentialUpdateParamsLocationCookie CredentialSetCredentialUpdateParamsLocation = "cookie"` - `LocationName param.Field[string]` Body param: Name of the header or cookie where the credential is attached. - `Name param.Field[string]` Body param: Human-readable name. - `Value param.Field[string]` Body param: The credential value. Write-only. Never returned in responses. ### Returns - `type CredentialSetCredentialUpdateResponse struct{…}` A credential attached to API requests during scanning. The credential `value` is write-only and never returned in responses. - `ID string` Credential identifier. - `CredentialSetID string` Parent credential set identifier. - `Location CredentialSetCredentialUpdateResponseLocation` Where the credential is attached in outgoing requests. - `const CredentialSetCredentialUpdateResponseLocationHeader CredentialSetCredentialUpdateResponseLocation = "header"` - `const CredentialSetCredentialUpdateResponseLocationCookie CredentialSetCredentialUpdateResponseLocation = "cookie"` - `LocationName string` Name of the header or cookie where the credential is attached. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credential, err := client.VulnerabilityScanner.CredentialSets.Credentials.Update( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetCredentialUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Location: cloudflare.F(vulnerability_scanner.CredentialSetCredentialUpdateParamsLocationHeader), LocationName: cloudflare.F("Authorization"), Name: cloudflare.F("Admin API key"), Value: cloudflare.F("Bearer EXAMPLE_TOKEN"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credential.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "credential_set_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "location": "header", "location_name": "Authorization", "name": "Admin API key" }, "result_info": {} } ``` ## Edit Credential `client.VulnerabilityScanner.CredentialSets.Credentials.Edit(ctx, credentialSetID, credentialID, params) (*CredentialSetCredentialEditResponse, error)` **patch** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}` Updates a credential with only the provided fields; omitted fields remain unchanged. ### Parameters - `credentialSetID string` - `credentialID string` - `params CredentialSetCredentialEditParams` - `AccountID param.Field[string]` Path param: Identifier. - `Location param.Field[CredentialSetCredentialEditParamsLocation]` Body param: Where the credential is attached in outgoing requests. - `const CredentialSetCredentialEditParamsLocationHeader CredentialSetCredentialEditParamsLocation = "header"` - `const CredentialSetCredentialEditParamsLocationCookie CredentialSetCredentialEditParamsLocation = "cookie"` - `LocationName param.Field[string]` Body param: Name of the header or cookie where the credential is attached. - `Name param.Field[string]` Body param: Human-readable name. - `Value param.Field[string]` Body param: The credential value. Write-only. Never returned in responses. ### Returns - `type CredentialSetCredentialEditResponse struct{…}` A credential attached to API requests during scanning. The credential `value` is write-only and never returned in responses. - `ID string` Credential identifier. - `CredentialSetID string` Parent credential set identifier. - `Location CredentialSetCredentialEditResponseLocation` Where the credential is attached in outgoing requests. - `const CredentialSetCredentialEditResponseLocationHeader CredentialSetCredentialEditResponseLocation = "header"` - `const CredentialSetCredentialEditResponseLocationCookie CredentialSetCredentialEditResponseLocation = "cookie"` - `LocationName string` Name of the header or cookie where the credential is attached. - `Name string` Human-readable name. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.VulnerabilityScanner.CredentialSets.Credentials.Edit( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetCredentialEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "credential_set_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "location": "header", "location_name": "Authorization", "name": "Admin API key" }, "result_info": {} } ``` ## Delete Credential `client.VulnerabilityScanner.CredentialSets.Credentials.Delete(ctx, credentialSetID, credentialID, body) (*CredentialSetCredentialDeleteResponse, error)` **delete** `/accounts/{account_id}/vuln_scanner/credential_sets/{credential_set_id}/credentials/{credential_id}` Deletes a credential. ### Parameters - `credentialSetID string` - `credentialID string` - `body CredentialSetCredentialDeleteParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type CredentialSetCredentialDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) credential, err := client.VulnerabilityScanner.CredentialSets.Credentials.Delete( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.CredentialSetCredentialDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", credential) } ``` #### 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" } } ], "success": true, "result": {}, "result_info": {} } ``` # Scans ## List Scans `client.VulnerabilityScanner.Scans.List(ctx, params) (*V4PagePaginationArray[ScanListResponse], error)` **get** `/accounts/{account_id}/vuln_scanner/scans` Returns all scans for the account. ### Parameters - `params ScanListParams` - `AccountID param.Field[string]` Path param: Identifier. - `Page param.Field[int64]` Query param: Page number of paginated results. - `PerPage param.Field[int64]` Query param: Number of results per page. ### Returns - `type ScanListResponse struct{…}` - `ID string` Scan identifier. - `ScanType ScanListResponseScanType` The type of vulnerability scan. - `const ScanListResponseScanTypeBOLA ScanListResponseScanType = "bola"` - `Status ScanListResponseStatus` Current lifecycle status of the scan. - `const ScanListResponseStatusCreated ScanListResponseStatus = "created"` - `const ScanListResponseStatusScheduled ScanListResponseStatus = "scheduled"` - `const ScanListResponseStatusPlanning ScanListResponseStatus = "planning"` - `const ScanListResponseStatusRunning ScanListResponseStatus = "running"` - `const ScanListResponseStatusFinished ScanListResponseStatus = "finished"` - `const ScanListResponseStatusFailed ScanListResponseStatus = "failed"` - `TargetEnvironmentID string` The target environment this scan runs against. - `Report ScanListResponseReport` Vulnerability report produced after the scan completes. The shape depends on the scan type. Present only for finished scans. - `Report ScanListResponseReportReport` Version 1 of the BOLA vulnerability scan report. - `Summary ScanListResponseReportReportSummary` Summary of all steps and findings. - `Verdict ScanListResponseReportReportSummaryVerdict` Overall verdict of the vulnerability scan. - `const ScanListResponseReportReportSummaryVerdictOk ScanListResponseReportReportSummaryVerdict = "ok"` - `const ScanListResponseReportReportSummaryVerdictWarning ScanListResponseReportReportSummaryVerdict = "warning"` - `const ScanListResponseReportReportSummaryVerdictInconclusive ScanListResponseReportReportSummaryVerdict = "inconclusive"` - `Tests []ScanListResponseReportReportTest` List of tests that were run. - `Steps []ScanListResponseReportReportTestsStep` Steps that were executed. - `Assertions []ScanListResponseReportReportTestsStepsAssertion` Assertions that were made against the received response. - `Description string` Human-readable description of the assertion, explaining what was checked. - `Kind ScanListResponseReportReportTestsStepsAssertionsKind` Kind of assertion. - `Parameters ScanListResponseReportReportTestsStepsAssertionsKindParameters` Range of HTTP status codes. - `Max int64` Maximum (inclusive) status code of the range. - `Min int64` Minimum (inclusive) status code of the range. - `Type ScanListResponseReportReportTestsStepsAssertionsKindType` - `const ScanListResponseReportReportTestsStepsAssertionsKindTypeHTTPStatusWithinRange ScanListResponseReportReportTestsStepsAssertionsKindType = "http_status_within_range"` - `Observed int64` Observed value on which the assertion was made. - `Outcome ScanListResponseReportReportTestsStepsAssertionsOutcome` Outcome of the assertion. - `const ScanListResponseReportReportTestsStepsAssertionsOutcomeOk ScanListResponseReportReportTestsStepsAssertionsOutcome = "ok"` - `const ScanListResponseReportReportTestsStepsAssertionsOutcomeFail ScanListResponseReportReportTestsStepsAssertionsOutcome = "fail"` - `const ScanListResponseReportReportTestsStepsAssertionsOutcomeInconclusive ScanListResponseReportReportTestsStepsAssertionsOutcome = "inconclusive"` - `Errors []ScanListResponseReportReportTestsStepsError` Errors the step encountered that may explain absent or incomplete fields. - `Description string` Human-readable error description. - `ErrorCode int64` Numeric error code identifying the class of error, if available. - `Request ScanListResponseReportReportTestsStepsRequest` HTTP request that was made, if any. - `CredentialSet ScanListResponseReportReportTestsStepsRequestCredentialSet` Credential set that was used. - `ID string` ID of the credential set. - `Role ScanListResponseReportReportTestsStepsRequestCredentialSetRole` Role of the credential set. - `const ScanListResponseReportReportTestsStepsRequestCredentialSetRoleOwner ScanListResponseReportReportTestsStepsRequestCredentialSetRole = "owner"` - `const ScanListResponseReportReportTestsStepsRequestCredentialSetRoleAttacker ScanListResponseReportReportTestsStepsRequestCredentialSetRole = "attacker"` - `HeaderNames []string` Names of headers that were sent. - `Method ScanListResponseReportReportTestsStepsRequestMethod` HTTP method. - `const ScanListResponseReportReportTestsStepsRequestMethodGet ScanListResponseReportReportTestsStepsRequestMethod = "GET"` - `const ScanListResponseReportReportTestsStepsRequestMethodDelete ScanListResponseReportReportTestsStepsRequestMethod = "DELETE"` - `const ScanListResponseReportReportTestsStepsRequestMethodPatch ScanListResponseReportReportTestsStepsRequestMethod = "PATCH"` - `const ScanListResponseReportReportTestsStepsRequestMethodPost ScanListResponseReportReportTestsStepsRequestMethod = "POST"` - `const ScanListResponseReportReportTestsStepsRequestMethodPut ScanListResponseReportReportTestsStepsRequestMethod = "PUT"` - `URL string` Exact and full URL (including host, query parameters) that was requested. - `VariableCaptures []ScanListResponseReportReportTestsStepsRequestVariableCapture` Variable captures requested for this step. - `JsonPath string` JSONPath expression used for capture, e.g. `"$.id"`. - `Name string` Variable name, e.g. `"resource_id"`. - `Body unknown` Request body, if any. - `Response ScanListResponseReportReportTestsStepsResponse` HTTP response that was received, if any. - `Body ScanListResponseReportReportTestsStepsResponseBody` HTTP response body. - `type ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFound struct{…}` No body was received. - `Kind ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKind` - `const ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKindNotFound ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKind = "not_found"` - `type ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytes struct{…}` Body received but unable to read as UTF-8. Raw bytes, base64-encoded. - `Contents string` - `Kind ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKind` - `const ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKindBytes ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKind = "bytes"` - `Truncated bool` - `type ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseText struct{…}` Body received as valid UTF-8 text but not valid JSON. - `Contents string` - `Kind ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKind` - `const ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKindText ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKind = "text"` - `Truncated bool` - `type ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJson struct{…}` Body received as valid JSON. - `Contents string` - `Kind ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKind` - `const ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKindJson ScanListResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKind = "json"` - `Truncated bool` - `HeaderNames []string` Names of headers that were received. - `Status int64` HTTP status code. - `StatusText string` HTTP status text, if available for the status code. - `Verdict ScanListResponseReportReportTestsVerdict` Verdict of this single test. - `const ScanListResponseReportReportTestsVerdictOk ScanListResponseReportReportTestsVerdict = "ok"` - `const ScanListResponseReportReportTestsVerdictWarning ScanListResponseReportReportTestsVerdict = "warning"` - `const ScanListResponseReportReportTestsVerdictInconclusive ScanListResponseReportReportTestsVerdict = "inconclusive"` - `PreflightErrors []ScanListResponseReportReportTestsPreflightError` Errors that prevented step execution. - `Description string` Human-readable error description. - `ErrorCode int64` Numeric error code identifying the class of error, if available. - `ReportSchemaVersion ScanListResponseReportReportSchemaVersion` Version of the report schema. - `const ScanListResponseReportReportSchemaVersionV1 ScanListResponseReportReportSchemaVersion = "v1"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.VulnerabilityScanner.Scans.List(context.TODO(), vulnerability_scanner.ScanListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "scan_type": "bola", "status": "created", "target_environment_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "report": { "report": { "summary": { "verdict": "ok" }, "tests": [ { "steps": [ { "assertions": [ { "description": "description", "kind": { "parameters": { "max": 0, "min": 0 }, "type": "http_status_within_range" }, "observed": 0, "outcome": "ok" } ], "errors": [ { "description": "description", "error_code": 0 } ], "request": { "credential_set": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "role": "owner" }, "header_names": [ "string" ], "method": "GET", "url": "https://example.com", "variable_captures": [ { "json_path": "json_path", "name": "name" } ], "body": {} }, "response": { "body": { "kind": "not_found" }, "header_names": [ "string" ], "status": 0, "status_text": "status_text" } } ], "verdict": "ok", "preflight_errors": [ { "description": "description", "error_code": 0 } ] } ] }, "report_schema_version": "v1" } } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Create Scan `client.VulnerabilityScanner.Scans.New(ctx, params) (*ScanNewResponse, error)` **post** `/accounts/{account_id}/vuln_scanner/scans` Creates and starts a new vulnerability scan. The response may include non-fatal warnings in the `messages` array. ### Parameters - `params ScanNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `CredentialSets param.Field[ScanNewParamsCredentialSets]` Body param: Credential set references for a BOLA scan. The scanner uses the `owner` credentials for legitimate requests and the `attacker` credentials to attempt unauthorized access. - `Attacker string` Credential set ID for the attacker. - `Owner string` Credential set ID for the resource owner. - `OpenAPI param.Field[string]` Body param: OpenAPI schema definition for the API under test. The scanner uses this to discover endpoints and construct requests. - `ScanType param.Field[ScanNewParamsScanType]` Body param - `const ScanNewParamsScanTypeBOLA ScanNewParamsScanType = "bola"` - `TargetEnvironmentID param.Field[string]` Body param: The target environment to scan. ### Returns - `type ScanNewResponse struct{…}` - `ID string` Scan identifier. - `ScanType ScanNewResponseScanType` The type of vulnerability scan. - `const ScanNewResponseScanTypeBOLA ScanNewResponseScanType = "bola"` - `Status ScanNewResponseStatus` Current lifecycle status of the scan. - `const ScanNewResponseStatusCreated ScanNewResponseStatus = "created"` - `const ScanNewResponseStatusScheduled ScanNewResponseStatus = "scheduled"` - `const ScanNewResponseStatusPlanning ScanNewResponseStatus = "planning"` - `const ScanNewResponseStatusRunning ScanNewResponseStatus = "running"` - `const ScanNewResponseStatusFinished ScanNewResponseStatus = "finished"` - `const ScanNewResponseStatusFailed ScanNewResponseStatus = "failed"` - `TargetEnvironmentID string` The target environment this scan runs against. - `Report ScanNewResponseReport` Vulnerability report produced after the scan completes. The shape depends on the scan type. Present only for finished scans. - `Report ScanNewResponseReportReport` Version 1 of the BOLA vulnerability scan report. - `Summary ScanNewResponseReportReportSummary` Summary of all steps and findings. - `Verdict ScanNewResponseReportReportSummaryVerdict` Overall verdict of the vulnerability scan. - `const ScanNewResponseReportReportSummaryVerdictOk ScanNewResponseReportReportSummaryVerdict = "ok"` - `const ScanNewResponseReportReportSummaryVerdictWarning ScanNewResponseReportReportSummaryVerdict = "warning"` - `const ScanNewResponseReportReportSummaryVerdictInconclusive ScanNewResponseReportReportSummaryVerdict = "inconclusive"` - `Tests []ScanNewResponseReportReportTest` List of tests that were run. - `Steps []ScanNewResponseReportReportTestsStep` Steps that were executed. - `Assertions []ScanNewResponseReportReportTestsStepsAssertion` Assertions that were made against the received response. - `Description string` Human-readable description of the assertion, explaining what was checked. - `Kind ScanNewResponseReportReportTestsStepsAssertionsKind` Kind of assertion. - `Parameters ScanNewResponseReportReportTestsStepsAssertionsKindParameters` Range of HTTP status codes. - `Max int64` Maximum (inclusive) status code of the range. - `Min int64` Minimum (inclusive) status code of the range. - `Type ScanNewResponseReportReportTestsStepsAssertionsKindType` - `const ScanNewResponseReportReportTestsStepsAssertionsKindTypeHTTPStatusWithinRange ScanNewResponseReportReportTestsStepsAssertionsKindType = "http_status_within_range"` - `Observed int64` Observed value on which the assertion was made. - `Outcome ScanNewResponseReportReportTestsStepsAssertionsOutcome` Outcome of the assertion. - `const ScanNewResponseReportReportTestsStepsAssertionsOutcomeOk ScanNewResponseReportReportTestsStepsAssertionsOutcome = "ok"` - `const ScanNewResponseReportReportTestsStepsAssertionsOutcomeFail ScanNewResponseReportReportTestsStepsAssertionsOutcome = "fail"` - `const ScanNewResponseReportReportTestsStepsAssertionsOutcomeInconclusive ScanNewResponseReportReportTestsStepsAssertionsOutcome = "inconclusive"` - `Errors []ScanNewResponseReportReportTestsStepsError` Errors the step encountered that may explain absent or incomplete fields. - `Description string` Human-readable error description. - `ErrorCode int64` Numeric error code identifying the class of error, if available. - `Request ScanNewResponseReportReportTestsStepsRequest` HTTP request that was made, if any. - `CredentialSet ScanNewResponseReportReportTestsStepsRequestCredentialSet` Credential set that was used. - `ID string` ID of the credential set. - `Role ScanNewResponseReportReportTestsStepsRequestCredentialSetRole` Role of the credential set. - `const ScanNewResponseReportReportTestsStepsRequestCredentialSetRoleOwner ScanNewResponseReportReportTestsStepsRequestCredentialSetRole = "owner"` - `const ScanNewResponseReportReportTestsStepsRequestCredentialSetRoleAttacker ScanNewResponseReportReportTestsStepsRequestCredentialSetRole = "attacker"` - `HeaderNames []string` Names of headers that were sent. - `Method ScanNewResponseReportReportTestsStepsRequestMethod` HTTP method. - `const ScanNewResponseReportReportTestsStepsRequestMethodGet ScanNewResponseReportReportTestsStepsRequestMethod = "GET"` - `const ScanNewResponseReportReportTestsStepsRequestMethodDelete ScanNewResponseReportReportTestsStepsRequestMethod = "DELETE"` - `const ScanNewResponseReportReportTestsStepsRequestMethodPatch ScanNewResponseReportReportTestsStepsRequestMethod = "PATCH"` - `const ScanNewResponseReportReportTestsStepsRequestMethodPost ScanNewResponseReportReportTestsStepsRequestMethod = "POST"` - `const ScanNewResponseReportReportTestsStepsRequestMethodPut ScanNewResponseReportReportTestsStepsRequestMethod = "PUT"` - `URL string` Exact and full URL (including host, query parameters) that was requested. - `VariableCaptures []ScanNewResponseReportReportTestsStepsRequestVariableCapture` Variable captures requested for this step. - `JsonPath string` JSONPath expression used for capture, e.g. `"$.id"`. - `Name string` Variable name, e.g. `"resource_id"`. - `Body unknown` Request body, if any. - `Response ScanNewResponseReportReportTestsStepsResponse` HTTP response that was received, if any. - `Body ScanNewResponseReportReportTestsStepsResponseBody` HTTP response body. - `type ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFound struct{…}` No body was received. - `Kind ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKind` - `const ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKindNotFound ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKind = "not_found"` - `type ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytes struct{…}` Body received but unable to read as UTF-8. Raw bytes, base64-encoded. - `Contents string` - `Kind ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKind` - `const ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKindBytes ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKind = "bytes"` - `Truncated bool` - `type ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseText struct{…}` Body received as valid UTF-8 text but not valid JSON. - `Contents string` - `Kind ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKind` - `const ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKindText ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKind = "text"` - `Truncated bool` - `type ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJson struct{…}` Body received as valid JSON. - `Contents string` - `Kind ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKind` - `const ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKindJson ScanNewResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKind = "json"` - `Truncated bool` - `HeaderNames []string` Names of headers that were received. - `Status int64` HTTP status code. - `StatusText string` HTTP status text, if available for the status code. - `Verdict ScanNewResponseReportReportTestsVerdict` Verdict of this single test. - `const ScanNewResponseReportReportTestsVerdictOk ScanNewResponseReportReportTestsVerdict = "ok"` - `const ScanNewResponseReportReportTestsVerdictWarning ScanNewResponseReportReportTestsVerdict = "warning"` - `const ScanNewResponseReportReportTestsVerdictInconclusive ScanNewResponseReportReportTestsVerdict = "inconclusive"` - `PreflightErrors []ScanNewResponseReportReportTestsPreflightError` Errors that prevented step execution. - `Description string` Human-readable error description. - `ErrorCode int64` Numeric error code identifying the class of error, if available. - `ReportSchemaVersion ScanNewResponseReportReportSchemaVersion` Version of the report schema. - `const ScanNewResponseReportReportSchemaVersionV1 ScanNewResponseReportReportSchemaVersion = "v1"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) scan, err := client.VulnerabilityScanner.Scans.New(context.TODO(), vulnerability_scanner.ScanNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), CredentialSets: cloudflare.F(vulnerability_scanner.ScanNewParamsCredentialSets{ Attacker: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), Owner: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), }), OpenAPI: cloudflare.F("open_api"), ScanType: cloudflare.F(vulnerability_scanner.ScanNewParamsScanTypeBOLA), TargetEnvironmentID: cloudflare.F("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", scan.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "scan_type": "bola", "status": "created", "target_environment_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "report": { "report": { "summary": { "verdict": "ok" }, "tests": [ { "steps": [ { "assertions": [ { "description": "description", "kind": { "parameters": { "max": 0, "min": 0 }, "type": "http_status_within_range" }, "observed": 0, "outcome": "ok" } ], "errors": [ { "description": "description", "error_code": 0 } ], "request": { "credential_set": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "role": "owner" }, "header_names": [ "string" ], "method": "GET", "url": "https://example.com", "variable_captures": [ { "json_path": "json_path", "name": "name" } ], "body": {} }, "response": { "body": { "kind": "not_found" }, "header_names": [ "string" ], "status": 0, "status_text": "status_text" } } ], "verdict": "ok", "preflight_errors": [ { "description": "description", "error_code": 0 } ] } ] }, "report_schema_version": "v1" } }, "result_info": {} } ``` ## Get Scan `client.VulnerabilityScanner.Scans.Get(ctx, scanID, query) (*ScanGetResponse, error)` **get** `/accounts/{account_id}/vuln_scanner/scans/{scan_id}` Returns a single scan by ID. ### Parameters - `scanID string` - `query ScanGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type ScanGetResponse struct{…}` - `ID string` Scan identifier. - `ScanType ScanGetResponseScanType` The type of vulnerability scan. - `const ScanGetResponseScanTypeBOLA ScanGetResponseScanType = "bola"` - `Status ScanGetResponseStatus` Current lifecycle status of the scan. - `const ScanGetResponseStatusCreated ScanGetResponseStatus = "created"` - `const ScanGetResponseStatusScheduled ScanGetResponseStatus = "scheduled"` - `const ScanGetResponseStatusPlanning ScanGetResponseStatus = "planning"` - `const ScanGetResponseStatusRunning ScanGetResponseStatus = "running"` - `const ScanGetResponseStatusFinished ScanGetResponseStatus = "finished"` - `const ScanGetResponseStatusFailed ScanGetResponseStatus = "failed"` - `TargetEnvironmentID string` The target environment this scan runs against. - `Report ScanGetResponseReport` Vulnerability report produced after the scan completes. The shape depends on the scan type. Present only for finished scans. - `Report ScanGetResponseReportReport` Version 1 of the BOLA vulnerability scan report. - `Summary ScanGetResponseReportReportSummary` Summary of all steps and findings. - `Verdict ScanGetResponseReportReportSummaryVerdict` Overall verdict of the vulnerability scan. - `const ScanGetResponseReportReportSummaryVerdictOk ScanGetResponseReportReportSummaryVerdict = "ok"` - `const ScanGetResponseReportReportSummaryVerdictWarning ScanGetResponseReportReportSummaryVerdict = "warning"` - `const ScanGetResponseReportReportSummaryVerdictInconclusive ScanGetResponseReportReportSummaryVerdict = "inconclusive"` - `Tests []ScanGetResponseReportReportTest` List of tests that were run. - `Steps []ScanGetResponseReportReportTestsStep` Steps that were executed. - `Assertions []ScanGetResponseReportReportTestsStepsAssertion` Assertions that were made against the received response. - `Description string` Human-readable description of the assertion, explaining what was checked. - `Kind ScanGetResponseReportReportTestsStepsAssertionsKind` Kind of assertion. - `Parameters ScanGetResponseReportReportTestsStepsAssertionsKindParameters` Range of HTTP status codes. - `Max int64` Maximum (inclusive) status code of the range. - `Min int64` Minimum (inclusive) status code of the range. - `Type ScanGetResponseReportReportTestsStepsAssertionsKindType` - `const ScanGetResponseReportReportTestsStepsAssertionsKindTypeHTTPStatusWithinRange ScanGetResponseReportReportTestsStepsAssertionsKindType = "http_status_within_range"` - `Observed int64` Observed value on which the assertion was made. - `Outcome ScanGetResponseReportReportTestsStepsAssertionsOutcome` Outcome of the assertion. - `const ScanGetResponseReportReportTestsStepsAssertionsOutcomeOk ScanGetResponseReportReportTestsStepsAssertionsOutcome = "ok"` - `const ScanGetResponseReportReportTestsStepsAssertionsOutcomeFail ScanGetResponseReportReportTestsStepsAssertionsOutcome = "fail"` - `const ScanGetResponseReportReportTestsStepsAssertionsOutcomeInconclusive ScanGetResponseReportReportTestsStepsAssertionsOutcome = "inconclusive"` - `Errors []ScanGetResponseReportReportTestsStepsError` Errors the step encountered that may explain absent or incomplete fields. - `Description string` Human-readable error description. - `ErrorCode int64` Numeric error code identifying the class of error, if available. - `Request ScanGetResponseReportReportTestsStepsRequest` HTTP request that was made, if any. - `CredentialSet ScanGetResponseReportReportTestsStepsRequestCredentialSet` Credential set that was used. - `ID string` ID of the credential set. - `Role ScanGetResponseReportReportTestsStepsRequestCredentialSetRole` Role of the credential set. - `const ScanGetResponseReportReportTestsStepsRequestCredentialSetRoleOwner ScanGetResponseReportReportTestsStepsRequestCredentialSetRole = "owner"` - `const ScanGetResponseReportReportTestsStepsRequestCredentialSetRoleAttacker ScanGetResponseReportReportTestsStepsRequestCredentialSetRole = "attacker"` - `HeaderNames []string` Names of headers that were sent. - `Method ScanGetResponseReportReportTestsStepsRequestMethod` HTTP method. - `const ScanGetResponseReportReportTestsStepsRequestMethodGet ScanGetResponseReportReportTestsStepsRequestMethod = "GET"` - `const ScanGetResponseReportReportTestsStepsRequestMethodDelete ScanGetResponseReportReportTestsStepsRequestMethod = "DELETE"` - `const ScanGetResponseReportReportTestsStepsRequestMethodPatch ScanGetResponseReportReportTestsStepsRequestMethod = "PATCH"` - `const ScanGetResponseReportReportTestsStepsRequestMethodPost ScanGetResponseReportReportTestsStepsRequestMethod = "POST"` - `const ScanGetResponseReportReportTestsStepsRequestMethodPut ScanGetResponseReportReportTestsStepsRequestMethod = "PUT"` - `URL string` Exact and full URL (including host, query parameters) that was requested. - `VariableCaptures []ScanGetResponseReportReportTestsStepsRequestVariableCapture` Variable captures requested for this step. - `JsonPath string` JSONPath expression used for capture, e.g. `"$.id"`. - `Name string` Variable name, e.g. `"resource_id"`. - `Body unknown` Request body, if any. - `Response ScanGetResponseReportReportTestsStepsResponse` HTTP response that was received, if any. - `Body ScanGetResponseReportReportTestsStepsResponseBody` HTTP response body. - `type ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFound struct{…}` No body was received. - `Kind ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKind` - `const ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKindNotFound ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseNotFoundKind = "not_found"` - `type ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytes struct{…}` Body received but unable to read as UTF-8. Raw bytes, base64-encoded. - `Contents string` - `Kind ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKind` - `const ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKindBytes ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseBytesKind = "bytes"` - `Truncated bool` - `type ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseText struct{…}` Body received as valid UTF-8 text but not valid JSON. - `Contents string` - `Kind ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKind` - `const ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKindText ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseTextKind = "text"` - `Truncated bool` - `type ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJson struct{…}` Body received as valid JSON. - `Contents string` - `Kind ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKind` - `const ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKindJson ScanGetResponseReportReportTestsStepsResponseBodyVulnScannerBOLABodyResponseJsonKind = "json"` - `Truncated bool` - `HeaderNames []string` Names of headers that were received. - `Status int64` HTTP status code. - `StatusText string` HTTP status text, if available for the status code. - `Verdict ScanGetResponseReportReportTestsVerdict` Verdict of this single test. - `const ScanGetResponseReportReportTestsVerdictOk ScanGetResponseReportReportTestsVerdict = "ok"` - `const ScanGetResponseReportReportTestsVerdictWarning ScanGetResponseReportReportTestsVerdict = "warning"` - `const ScanGetResponseReportReportTestsVerdictInconclusive ScanGetResponseReportReportTestsVerdict = "inconclusive"` - `PreflightErrors []ScanGetResponseReportReportTestsPreflightError` Errors that prevented step execution. - `Description string` Human-readable error description. - `ErrorCode int64` Numeric error code identifying the class of error, if available. - `ReportSchemaVersion ScanGetResponseReportReportSchemaVersion` Version of the report schema. - `const ScanGetResponseReportReportSchemaVersionV1 ScanGetResponseReportReportSchemaVersion = "v1"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) scan, err := client.VulnerabilityScanner.Scans.Get( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.ScanGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", scan.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "scan_type": "bola", "status": "created", "target_environment_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "report": { "report": { "summary": { "verdict": "ok" }, "tests": [ { "steps": [ { "assertions": [ { "description": "description", "kind": { "parameters": { "max": 0, "min": 0 }, "type": "http_status_within_range" }, "observed": 0, "outcome": "ok" } ], "errors": [ { "description": "description", "error_code": 0 } ], "request": { "credential_set": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "role": "owner" }, "header_names": [ "string" ], "method": "GET", "url": "https://example.com", "variable_captures": [ { "json_path": "json_path", "name": "name" } ], "body": {} }, "response": { "body": { "kind": "not_found" }, "header_names": [ "string" ], "status": 0, "status_text": "status_text" } } ], "verdict": "ok", "preflight_errors": [ { "description": "description", "error_code": 0 } ] } ] }, "report_schema_version": "v1" } }, "result_info": {} } ``` # Target Environments ## List Target Environments `client.VulnerabilityScanner.TargetEnvironments.List(ctx, params) (*V4PagePaginationArray[TargetEnvironmentListResponse], error)` **get** `/accounts/{account_id}/vuln_scanner/target_environments` Returns all target environments for the account. ### Parameters - `params TargetEnvironmentListParams` - `AccountID param.Field[string]` Path param: Identifier. - `Page param.Field[int64]` Query param: Page number of paginated results. - `PerPage param.Field[int64]` Query param: Number of results per page. ### Returns - `type TargetEnvironmentListResponse struct{…}` - `ID string` Target environment identifier. - `Name string` Human-readable name. - `Target TargetEnvironmentListResponseTarget` Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentListResponseTargetType` - `const TargetEnvironmentListResponseTargetTypeZone TargetEnvironmentListResponseTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. - `Description string` Optional description providing additional context. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.VulnerabilityScanner.TargetEnvironments.List(context.TODO(), vulnerability_scanner.TargetEnvironmentListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### 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" } } ], "success": true, "result": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production Zone", "target": { "type": "zone", "zone_tag": "d8e8fca2dc0f896fd7cb4cb0031ba249" }, "description": "Main production environment" } ], "result_info": { "count": 1, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Create Target Environment `client.VulnerabilityScanner.TargetEnvironments.New(ctx, params) (*TargetEnvironmentNewResponse, error)` **post** `/accounts/{account_id}/vuln_scanner/target_environments` Creates a new target environment for the account. ### Parameters - `params TargetEnvironmentNewParams` - `AccountID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: Human-readable name. - `Target param.Field[TargetEnvironmentNewParamsTarget]` Body param: Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentNewParamsTargetType` - `const TargetEnvironmentNewParamsTargetTypeZone TargetEnvironmentNewParamsTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. - `Description param.Field[string]` Body param: Optional description. ### Returns - `type TargetEnvironmentNewResponse struct{…}` - `ID string` Target environment identifier. - `Name string` Human-readable name. - `Target TargetEnvironmentNewResponseTarget` Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentNewResponseTargetType` - `const TargetEnvironmentNewResponseTargetTypeZone TargetEnvironmentNewResponseTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. - `Description string` Optional description providing additional context. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) targetEnvironment, err := client.VulnerabilityScanner.TargetEnvironments.New(context.TODO(), vulnerability_scanner.TargetEnvironmentNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Production Zone"), Target: cloudflare.F(vulnerability_scanner.TargetEnvironmentNewParamsTarget{ Type: cloudflare.F(vulnerability_scanner.TargetEnvironmentNewParamsTargetTypeZone), ZoneTag: cloudflare.F("d8e8fca2dc0f896fd7cb4cb0031ba249"), }), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", targetEnvironment.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production Zone", "target": { "type": "zone", "zone_tag": "d8e8fca2dc0f896fd7cb4cb0031ba249" }, "description": "Main production environment" }, "result_info": {} } ``` ## Get Target Environment `client.VulnerabilityScanner.TargetEnvironments.Get(ctx, targetEnvironmentID, query) (*TargetEnvironmentGetResponse, error)` **get** `/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}` Returns a single target environment by ID. ### Parameters - `targetEnvironmentID string` - `query TargetEnvironmentGetParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type TargetEnvironmentGetResponse struct{…}` - `ID string` Target environment identifier. - `Name string` Human-readable name. - `Target TargetEnvironmentGetResponseTarget` Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentGetResponseTargetType` - `const TargetEnvironmentGetResponseTargetTypeZone TargetEnvironmentGetResponseTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. - `Description string` Optional description providing additional context. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) targetEnvironment, err := client.VulnerabilityScanner.TargetEnvironments.Get( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.TargetEnvironmentGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", targetEnvironment.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production Zone", "target": { "type": "zone", "zone_tag": "d8e8fca2dc0f896fd7cb4cb0031ba249" }, "description": "Main production environment" }, "result_info": {} } ``` ## Update Target Environment `client.VulnerabilityScanner.TargetEnvironments.Update(ctx, targetEnvironmentID, params) (*TargetEnvironmentUpdateResponse, error)` **put** `/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}` Replaces a target environment. All fields must be provided. ### Parameters - `targetEnvironmentID string` - `params TargetEnvironmentUpdateParams` - `AccountID param.Field[string]` Path param: Identifier. - `Name param.Field[string]` Body param: Human-readable name. - `Target param.Field[TargetEnvironmentUpdateParamsTarget]` Body param: Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentUpdateParamsTargetType` - `const TargetEnvironmentUpdateParamsTargetTypeZone TargetEnvironmentUpdateParamsTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. - `Description param.Field[string]` Body param: Optional description. ### Returns - `type TargetEnvironmentUpdateResponse struct{…}` - `ID string` Target environment identifier. - `Name string` Human-readable name. - `Target TargetEnvironmentUpdateResponseTarget` Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentUpdateResponseTargetType` - `const TargetEnvironmentUpdateResponseTargetTypeZone TargetEnvironmentUpdateResponseTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. - `Description string` Optional description providing additional context. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) targetEnvironment, err := client.VulnerabilityScanner.TargetEnvironments.Update( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.TargetEnvironmentUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Production Zone"), Target: cloudflare.F(vulnerability_scanner.TargetEnvironmentUpdateParamsTarget{ Type: cloudflare.F(vulnerability_scanner.TargetEnvironmentUpdateParamsTargetTypeZone), ZoneTag: cloudflare.F("d8e8fca2dc0f896fd7cb4cb0031ba249"), }), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", targetEnvironment.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production Zone", "target": { "type": "zone", "zone_tag": "d8e8fca2dc0f896fd7cb4cb0031ba249" }, "description": "Main production environment" }, "result_info": {} } ``` ## Edit Target Environment `client.VulnerabilityScanner.TargetEnvironments.Edit(ctx, targetEnvironmentID, params) (*TargetEnvironmentEditResponse, error)` **patch** `/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}` Updates a target environment with only the provided fields; omitted fields remain unchanged. ### Parameters - `targetEnvironmentID string` - `params TargetEnvironmentEditParams` - `AccountID param.Field[string]` Path param: Identifier. - `Description param.Field[string]` Body param: Optional description. Omit to leave unchanged, set to `null` to clear, or provide a string to update. - `Name param.Field[string]` Body param: Human-readable name. - `Target param.Field[TargetEnvironmentEditParamsTarget]` Body param: Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentEditParamsTargetType` - `const TargetEnvironmentEditParamsTargetTypeZone TargetEnvironmentEditParamsTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. ### Returns - `type TargetEnvironmentEditResponse struct{…}` - `ID string` Target environment identifier. - `Name string` Human-readable name. - `Target TargetEnvironmentEditResponseTarget` Identifies the Cloudflare asset to scan. Uses a `type` discriminator. Currently the service supports only `zone` targets. - `Type TargetEnvironmentEditResponseTargetType` - `const TargetEnvironmentEditResponseTargetTypeZone TargetEnvironmentEditResponseTargetType = "zone"` - `ZoneTag string` Cloudflare zone tag. The zone must belong to the account. - `Description string` Optional description providing additional context. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.VulnerabilityScanner.TargetEnvironments.Edit( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.TargetEnvironmentEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.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" } } ], "success": true, "result": { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "name": "Production Zone", "target": { "type": "zone", "zone_tag": "d8e8fca2dc0f896fd7cb4cb0031ba249" }, "description": "Main production environment" }, "result_info": {} } ``` ## Delete Target Environment `client.VulnerabilityScanner.TargetEnvironments.Delete(ctx, targetEnvironmentID, body) (*TargetEnvironmentDeleteResponse, error)` **delete** `/accounts/{account_id}/vuln_scanner/target_environments/{target_environment_id}` Removes a target environment. ### Parameters - `targetEnvironmentID string` - `body TargetEnvironmentDeleteParams` - `AccountID param.Field[string]` Identifier. ### Returns - `type TargetEnvironmentDeleteResponse interface{…}` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/vulnerability_scanner" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) targetEnvironment, err := client.VulnerabilityScanner.TargetEnvironments.Delete( context.TODO(), "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", vulnerability_scanner.TargetEnvironmentDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", targetEnvironment) } ``` #### 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" } } ], "success": true, "result": {}, "result_info": {} } ```