Skip to content
Start here

Updates Account State

client.SecurityCenter.State.Update(ctx, params) (*StateUpdateResponse, error)
PUT/accounts/{account_id}/security-center/state

Updates account-level Security Center state. Currently supports enabling or disabling scans for the account. Returns the account’s state after the update.

Security
API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

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

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

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

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
ParametersExpand Collapse
params StateUpdateParams
AccountID param.Field[string]

Path param: Identifier.

maxLength32
ScansEnabled param.Field[bool]

Body param: Enable or disable scans for the account.

ReturnsExpand Collapse
type StateUpdateResponse struct{…}
RecentDormantReactivation bool

Whether the account was recently reactivated from a dormant state (used to show the reactivation banner).

ScansEnabled bool

Whether on-demand and scheduled scans are enabled for the account.

Updates Account State

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  state, err := client.SecurityCenter.State.Update(context.TODO(), security_center.StateUpdateParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    ScansEnabled: cloudflare.F(true),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", state.RecentDormantReactivation)
}
{
  "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": {
    "recent_dormant_reactivation": false,
    "scans_enabled": true
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "recent_dormant_reactivation": false,
    "scans_enabled": true
  }
}