Skip to content
Start here

Updates security.txt

client.securityTXT.update(SecurityTXTUpdateParams { zone_id, contact, expires, 7 more } params, RequestOptionsoptions?): SecurityTXTUpdateResponse { errors, messages, success }
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 { zone_id, contact, expires, 7 more }
zone_id: string

Path param: Identifier.

maxLength32
contact: Array<string>

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

expires: string

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?: Array<string>

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

canonical?: Array<string>

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

enabled?: boolean

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?: Array<string>

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?: Array<string>

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

policy?: Array<string>

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

preferred_languages?: string

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
SecurityTXTUpdateResponse { errors, messages, success }
errors: Array<Error>
code: number
minimum1000
message: string
documentation_url?: string
source?: Source { pointer }
pointer?: string
messages: Array<Message>
code: number
minimum1000
message: string
documentation_url?: string
source?: Source { pointer }
pointer?: string
success: true

Whether the API call was successful.

Updates security.txt

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const securityTXT = await client.securityTXT.update({
  zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
  contact: [
    'mailto:security@example.com',
    'tel:+1-201-555-0123',
    'https://example.com/security-contact.html',
  ],
  expires: '2027-12-31T23:59:59Z',
});

console.log(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
}