Skip to content
Start here

Update all list items

client.Rules.Lists.Items.Update(ctx, listID, params) (*ListItemUpdateResponse, error)
PUT/accounts/{account_id}/rules/lists/{list_id}/items

Removes all existing items from the list and adds the provided items to the list.

This operation is asynchronous. To get current the operation status, invoke the Get bulk operation status endpoint with the returned operation_id.

There is a limit of 1 pending bulk operation per account. If an outstanding bulk operation is in progress, the request will be rejected.

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
Accepted Permissions (at least one required)
Account Filter Lists Edit
ParametersExpand Collapse
listID string

The unique ID of the list.

maxLength32
minLength32
params ListItemUpdateParams
AccountID param.Field[string]

Path param: The Account ID for this resource.

maxLength32
minLength32
Body param.Field[[]ListItemUpdateParamsBody]

Body param

type ListItemUpdateParamsBodyListsListItemIPComment struct{…}
IP string

An IPv4 address, an IPv4 CIDR, an IPv6 address, or an IPv6 CIDR.

Comment stringoptional

Defines an informative summary of the list item.

type ListItemUpdateParamsBodyListsListItemRedirectComment struct{…}
Redirect Redirect

The definition of the redirect.

SourceURL string
TargetURL string
IncludeSubdomains booloptional
PreservePathSuffix booloptional
PreserveQueryString booloptional
StatusCode RedirectStatusCodeoptional
One of the following:
const RedirectStatusCode301 RedirectStatusCode = 301
const RedirectStatusCode302 RedirectStatusCode = 302
const RedirectStatusCode307 RedirectStatusCode = 307
const RedirectStatusCode308 RedirectStatusCode = 308
SubpathMatching booloptional
Comment stringoptional

Defines an informative summary of the list item.

type ListItemUpdateParamsBodyListsListItemHostnameComment struct{…}
Hostname Hostname

Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, wildcards (*), and the hyphen (-).

URLHostname string
ExcludeExactHostname booloptional

Only applies to wildcard hostnames (e.g., *.example.com). When true (default), only subdomains are blocked. When false, both the root domain and subdomains are blocked.

Comment stringoptional

Defines an informative summary of the list item.

type ListItemUpdateParamsBodyListsListItemASNComment struct{…}
ASN int64

Defines a non-negative 32 bit integer.

Comment stringoptional

Defines an informative summary of the list item.

ReturnsExpand Collapse
type ListItemUpdateResponse struct{…}
OperationID string

The unique operation ID of the asynchronous action.

Update all list items

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  item, err := client.Rules.Lists.Items.Update(
    context.TODO(),
    "2c0fc9fa937b11eaa1b71c4d701ab86e",
    rules.ListItemUpdateParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      Body: []rules.ListItemUpdateParamsBodyUnion{rules.ListItemUpdateParamsBodyListsListItemIPComment{
        IP: cloudflare.F("10.0.0.1"),
      }},
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", item.OperationID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": {
    "operation_id": "4da8780eeb215e6cb7f48dd981c4ea02"
  },
  "success": 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"
      }
    }
  ],
  "result": {
    "operation_id": "4da8780eeb215e6cb7f48dd981c4ea02"
  },
  "success": true
}