Skip to content
Start here

Update Field Extractor

client.FieldExtractors.Update(ctx, extractor, params) (*FieldExtractorUpdateResponse, error)
PUT/accounts/{account_id}/field_extractors/{extractor}

Replaces all custom extraction rules for an extractor type. Omitted rules are deleted.

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
ParametersExpand Collapse
extractor string

Extractor type.

minLength1
params FieldExtractorUpdateParams
AccountID param.Field[string]

Path param: Cloudflare account ID.

minLength1
Rules param.Field[[]FieldExtractorUpdateParamsRule]

Body param

Fields []FieldExtractorUpdateParamsRulesField
Expression string
maxLength4096
minLength1
Name string
minLength1
Ref string
maxLength64
minLength1
Description stringOptional
maxLength4096
ReturnsExpand Collapse
type FieldExtractorUpdateResponse struct{…}
Extractor string

Extractor type.

Rules []FieldExtractorUpdateResponseRule
Fields []FieldExtractorUpdateResponseRulesField
Expression string

Wirefilter value expression.

Name string

Field name.

Ref string

Stable rule identifier.

Description stringOptional

Human-readable rule description.

Update Field Extractor

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  fieldExtractor, err := client.FieldExtractors.Update(
    context.TODO(),
    "llm_prompts",
    field_extractors.FieldExtractorUpdateParams{
      AccountID: cloudflare.F("123456"),
      Rules: cloudflare.F([]field_extractors.FieldExtractorUpdateParamsRule{field_extractors.FieldExtractorUpdateParamsRule{
        Fields: cloudflare.F([]field_extractors.FieldExtractorUpdateParamsRulesField{field_extractors.FieldExtractorUpdateParamsRulesField{
          Expression: cloudflare.F("x"),
          Name: cloudflare.F("x"),
        }}),
        Ref: cloudflare.F("x"),
      }}),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", fieldExtractor.Extractor)
}
{
  "errors": [
    {
      "code": 0,
      "message": "message",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "extractor": "llm_prompts",
    "rules": [
      {
        "fields": [
          {
            "expression": "filter(http.request.body.json.strings.values, http.request.body.json.strings.pointers[*] matches \"^/messages/\\\\d+/content$\")",
            "name": "prompt"
          }
        ],
        "ref": "openai-chat",
        "description": "description"
      }
    ]
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 0,
      "message": "message",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "result": {
    "extractor": "llm_prompts",
    "rules": [
      {
        "fields": [
          {
            "expression": "filter(http.request.body.json.strings.values, http.request.body.json.strings.pointers[*] matches \"^/messages/\\\\d+/content$\")",
            "name": "prompt"
          }
        ],
        "ref": "openai-chat",
        "description": "description"
      }
    ]
  },
  "success": true
}