Skip to content
Start here

Create a new Token Validation configuration

client.TokenValidation.Configuration.New(ctx, params) (*TokenConfig, error)
POST/zones/{zone_id}/token_validation/config

Create a new Token Validation configuration

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 API GatewayDomain API Gateway
ParametersExpand Collapse
params ConfigurationNewParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Credentials param.Field[ConfigurationNewParamsCredentials]

Body param

Keys []ConfigurationNewParamsCredentialsKey
One of the following:
type ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSA struct{…}

JSON representation of an RSA key.

Alg ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg

Algorithm

One of the following:
const ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgRs256 ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "RS256"
const ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgRs384 ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "RS384"
const ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgRs512 ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "RS512"
const ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgPs256 ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "PS256"
const ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgPs384 ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "PS384"
const ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgPs512 ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "PS512"
E string

RSA exponent

Kid string

Key ID

Kty ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyRSAKty

Key Type

N string

RSA modulus

type ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256 struct{…}

JSON representation of an ES256 key

Alg ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256Alg

Algorithm

Crv ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256Crv

Curve

Kid string

Key ID

Kty ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256Kty

Key Type

X string

X EC coordinate

Y string

Y EC coordinate

type ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384 struct{…}

JSON representation of an ES384 key

Alg ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384Alg

Algorithm

Crv ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384Crv

Curve

Kid string

Key ID

Kty ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384Kty

Key Type

X string

X EC coordinate

Y string

Y EC coordinate

Description param.Field[string]

Body param

maxLength500
Title param.Field[string]

Body param

maxLength50
TokenSources param.Field[[]string]

Body param

TokenType param.Field[ConfigurationNewParamsTokenType]

Body param

const ConfigurationNewParamsTokenTypeJWT ConfigurationNewParamsTokenType = "JWT"
ReturnsExpand Collapse
type TokenConfig struct{…}
ID string

UUID.

maxLength36
minLength36
CreatedAt Time
formatdate-time
Credentials TokenConfigCredentials
Keys []TokenConfigCredentialsKey
One of the following:
type TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSA struct{…}

JSON representation of an RSA key.

Alg TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg

Algorithm

One of the following:
const TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgRs256 TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "RS256"
const TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgRs384 TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "RS384"
const TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgRs512 TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "RS512"
const TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgPs256 TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "PS256"
const TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgPs384 TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "PS384"
const TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlgPs512 TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAAlg = "PS512"
E string

RSA exponent

Kid string

Key ID

Kty TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyRSAKty

Key Type

N string

RSA modulus

type TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256 struct{…}

JSON representation of an ES256 key

Alg TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256Alg

Algorithm

Crv TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256Crv

Curve

Kid string

Key ID

Kty TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256Kty

Key Type

X string

X EC coordinate

Y string

Y EC coordinate

type TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384 struct{…}

JSON representation of an ES384 key

Alg TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384Alg

Algorithm

Crv TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384Crv

Curve

Kid string

Key ID

Kty TokenConfigCredentialsKeysAPIShieldCredentialsJWTKeyEcEs384Kty

Key Type

X string

X EC coordinate

Y string

Y EC coordinate

Description string
maxLength500
LastUpdated Time
formatdate-time
Title string
maxLength50
TokenSources []string
TokenType TokenConfigTokenType

Create a new Token Validation configuration

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  tokenConfig, err := client.TokenValidation.Configuration.New(context.TODO(), token_validation.ConfigurationNewParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Credentials: cloudflare.F(token_validation.ConfigurationNewParamsCredentials{
      Keys: cloudflare.F([]token_validation.ConfigurationNewParamsCredentialsKeyUnion{token_validation.ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256{
        Alg: cloudflare.F(token_validation.ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256AlgEs256),
        Crv: cloudflare.F(token_validation.ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256CrvP256),
        Kid: cloudflare.F("38013f13-c266-4eec-a72a-92ec92779f21"),
        Kty: cloudflare.F(token_validation.ConfigurationNewParamsCredentialsKeysAPIShieldCredentialsJWTKeyEcEs256KtyEc),
        X: cloudflare.F("KN53JRwN3wCjm2o39bvZUX2VdrsHzS8pxOAGjm8m7EQ"),
        Y: cloudflare.F("lnkkzIxaveggz-HFhcMWW15nxvOj0Z_uQsXbpK0GFcY"),
      }}),
    }),
    Description: cloudflare.F("Long description for Token Validation Configuration"),
    Title: cloudflare.F("Example Token Validation Configuration"),
    TokenSources: cloudflare.F([]string{`http.request.headers["x-auth"][0]`, `http.request.cookies["Authorization"][0]`}),
    TokenType: cloudflare.F(token_validation.ConfigurationNewParamsTokenTypeJWT),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", tokenConfig.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"
      }
    }
  ],
  "result": {
    "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
    "created_at": "2014-01-01T05:20:00.12345Z",
    "credentials": {
      "keys": [
        {
          "alg": "ES256",
          "crv": "P-256",
          "kid": "38013f13-c266-4eec-a72a-92ec92779f21",
          "kty": "EC",
          "x": "KN53JRwN3wCjm2o39bvZUX2VdrsHzS8pxOAGjm8m7EQ",
          "y": "lnkkzIxaveggz-HFhcMWW15nxvOj0Z_uQsXbpK0GFcY"
        }
      ]
    },
    "description": "Long description for Token Validation Configuration",
    "last_updated": "2014-01-01T05:20:00.12345Z",
    "title": "Example Token Validation Configuration",
    "token_sources": [
      "http.request.headers[\"x-auth\"][0]",
      "http.request.cookies[\"Authorization\"][0]"
    ],
    "token_type": "JWT"
  },
  "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": {
    "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
    "created_at": "2014-01-01T05:20:00.12345Z",
    "credentials": {
      "keys": [
        {
          "alg": "ES256",
          "crv": "P-256",
          "kid": "38013f13-c266-4eec-a72a-92ec92779f21",
          "kty": "EC",
          "x": "KN53JRwN3wCjm2o39bvZUX2VdrsHzS8pxOAGjm8m7EQ",
          "y": "lnkkzIxaveggz-HFhcMWW15nxvOj0Z_uQsXbpK0GFcY"
        }
      ]
    },
    "description": "Long description for Token Validation Configuration",
    "last_updated": "2014-01-01T05:20:00.12345Z",
    "title": "Example Token Validation Configuration",
    "token_sources": [
      "http.request.headers[\"x-auth\"][0]",
      "http.request.cookies[\"Authorization\"][0]"
    ],
    "token_type": "JWT"
  },
  "success": true
}