Skip to content
Start here

Updates security.txt

client.SecurityTXT.Update(ctx, params) (*SecurityTXTUpdateResponse, error)
PUT/zones/{zone_id}/security-center/securitytxt

Updates the security.txt file configuration for a zone, which provides security researchers with vulnerability reporting information.

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)
Zone Settings Write
ParametersExpand Collapse
params SecurityTXTUpdateParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Contact param.Field[[]string]

Body param: Methods that researchers should use for reporting vulnerabilities. Can be a URI for an email address, phone number, or URL.

Expires param.Field[Time]

Body param: RFC3339-formatted date and time string indicating the time that, after which, the contents of the security.txt file should be considered stale. It is recommended that this value is less than a year into the future.

formatdate-time
Acknowledgments param.Field[[]string]Optional

Body param: Link(s) to a page where security researchers are recognised for their reports.

Canonical param.Field[[]string]Optional

Body param: Canonical URI where the security.txt file is located.

Enabled param.Field[bool]Optional

Body param: Whether or not to serve the security.txt file in this zone. If false, security.txt requests will pass through to the origin server.

Encryption param.Field[[]string]Optional

Body param: URI(s) pointing to a location where an encryption key that researchers should use for encrypted communications can be retrieved. The key itself must not appear in this field.

Hiring param.Field[[]string]Optional

Body param: Link(s) to any security-related job positions.

Policy param.Field[[]string]Optional

Body param: Link(s) to where a vulnerability disclosure policy is located.

PreferredLanguages param.Field[string]Optional

Body param: Comma-separated list of natural languages that are preferred when submitting security reports. Language codes should be as defined in RFC5646.

ReturnsExpand Collapse
type SecurityTXTUpdateResponse struct{…}
Errors []SecurityTXTUpdateResponseError
Code int64
minimum1000
Message string
DocumentationURL stringOptional
Source SecurityTXTUpdateResponseErrorsSourceOptional
Pointer stringOptional
Messages []SecurityTXTUpdateResponseMessage
Code int64
minimum1000
Message string
DocumentationURL stringOptional
Source SecurityTXTUpdateResponseMessagesSourceOptional
Pointer stringOptional
Success SecurityTXTUpdateResponseSuccess

Whether the API call was successful.

Updates security.txt

package main

import (
  "context"
  "fmt"
  "time"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  securityTXT, err := client.SecurityTXT.Update(context.TODO(), security_txt.SecurityTXTUpdateParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Contact: cloudflare.F([]string{"mailto:security@example.com", "tel:+1-201-555-0123", "https://example.com/security-contact.html"}),
    Expires: cloudflare.F(time.Now()),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", securityTXT.Errors)
}
{
  "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
}
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
}