Skip to content
Start here

Create prefix.

client.DDoSProtection.AdvancedTCPProtection.Prefixes.New(ctx, params) (*AdvancedTCPProtectionPrefixNewResponse, error)
POST/accounts/{account_id}/magic/advanced_tcp_protection/configs/prefixes

Create a prefix for an account.

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)
DDoS Protection Write
ParametersExpand Collapse
params AdvancedTCPProtectionPrefixNewParams
AccountID param.Field[string]

Path param: Identifier.

maxLength32
Comment param.Field[string]

Body param: A comment describing the prefix.

Excluded param.Field[bool]

Body param: Whether to exclude the prefix from protection.

Prefix param.Field[string]

Body param: The prefix to add in CIDR format.

ReturnsExpand Collapse
type AdvancedTCPProtectionPrefixNewResponse struct{…}
ID string

The unique ID of the prefix.

Comment string

A comment describing the prefix.

CreatedOn Time

The creation timestamp of the prefix.

formatdate-time
Excluded bool

Whether to exclude the prefix from protection.

ModifiedOn Time

The last modification timestamp of the prefix.

formatdate-time
Prefix string

The prefix in CIDR format.

Create prefix.

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/ddos_protection"
  "github.com/stainless-sdks/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  prefix, err := client.DDoSProtection.AdvancedTCPProtection.Prefixes.New(context.TODO(), ddos_protection.AdvancedTCPProtectionPrefixNewParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Comment: cloudflare.F("comment"),
    Excluded: cloudflare.F(true),
    Prefix: cloudflare.F("192.0.2.0/24"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", prefix.ID)
}
{
  "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": "id",
    "comment": "comment",
    "created_on": "2019-12-27T18:11:19.117Z",
    "excluded": true,
    "modified_on": "2019-12-27T18:11:19.117Z",
    "prefix": "192.0.2.0/24"
  }
}
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": {
    "id": "id",
    "comment": "comment",
    "created_on": "2019-12-27T18:11:19.117Z",
    "excluded": true,
    "modified_on": "2019-12-27T18:11:19.117Z",
    "prefix": "192.0.2.0/24"
  }
}