Skip to content

API configuration

Last updated View as MarkdownAgent setup

Use the API to upload, activate, list, and delete OpenAPI schemas. An uploaded schema supplies a Schema Profile for its operations.

Configure an uploaded schema

  1. Upload a schema.
  2. Add the schema operations to the Web Assets inventory.
  3. Activate the schema to make uploaded profile evaluation available.
  4. Send representative traffic through the configured operations.
  5. Analyze cf.schema_validation.uploaded.violated in Profile Analysis.
  6. Configure mitigation with WAF Custom Rules.

Settings changes may take a few minutes to implement.

Configuration

Upload and activate a schema

Upload a schema with POST. This example uses example_schema.yaml from the current directory.

Required API token permissions

At least one of the following token permissions is required:
  • Account API Gateway
  • Domain API Gateway
Upload a schemabash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/schema_validation/schemas" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"kind": "openapi_v3",
		"name": "example_schema",
		"source": "<SOURCE>",
		"validation_enabled": true
	}'
{
	"result": {
		"schema": {
			"schema_id": "af632e95-c986-4738-a67d-2ac09995017a",
			"name": "example_schema",
			"kind": "openapi_v3",
			"source": "<SOURCE>",
			"created_at": "2023-04-03T15:10:08.902309Z"
		}
	},
	"success": true,
	"errors": [],
	"messages": []
}

By default, uploaded schema evaluation is inactive. Set validation_enabled=true to make evaluation available during upload.

Use PATCH to activate evaluation after inspecting the schema.

Required API token permissions

At least one of the following