## Upload a schema to a zone `client.APIGateway.UserSchemas.New(ctx, params) (*UserSchemaNewResponse, error)` **post** `/zones/{zone_id}/api_gateway/user_schemas` Upload a schema to a zone ### Parameters - `params UserSchemaNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `File param.Field[Reader]` Body param: Schema file bytes - `Kind param.Field[UserSchemaNewParamsKind]` Body param: Kind of schema - `const UserSchemaNewParamsKindOpenAPIV3 UserSchemaNewParamsKind = "openapi_v3"` - `Name param.Field[string]` Body param: Name of the schema - `ValidationEnabled param.Field[UserSchemaNewParamsValidationEnabled]` Body param: Flag whether schema is enabled for validation. - `const UserSchemaNewParamsValidationEnabledTrue UserSchemaNewParamsValidationEnabled = "true"` - `const UserSchemaNewParamsValidationEnabledFalse UserSchemaNewParamsValidationEnabled = "false"` ### Returns - `type UserSchemaNewResponse struct{…}` - `Schema OldPublicSchema` - `CreatedAt Time` - `Kind OldPublicSchemaKind` Kind of schema - `const OldPublicSchemaKindOpenAPIV3 OldPublicSchemaKind = "openapi_v3"` - `Name string` Name of the schema - `SchemaID string` UUID. - `Source string` Source of the schema - `ValidationEnabled bool` Flag whether schema is enabled for validation. - `UploadDetails UserSchemaNewResponseUploadDetails` - `Warnings []UserSchemaNewResponseUploadDetailsWarning` Diagnostic warning events that occurred during processing. These events are non-critical errors found within the schema. - `Code int64` Code that identifies the event that occurred. - `Locations []string` JSONPath location(s) in the schema where these events were encountered. See for JSONPath specification. - `Message string` Diagnostic message that describes the event. ### Example ```go package main import ( "bytes" "context" "fmt" "io" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/api_gateway" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) userSchema, err := client.APIGateway.UserSchemas.New(context.TODO(), api_gateway.UserSchemaNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), File: cloudflare.F(io.Reader(bytes.NewBuffer([]byte("Example data")))), Kind: cloudflare.F(api_gateway.UserSchemaNewParamsKindOpenAPIV3), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", userSchema.Schema) } ``` #### Response ```json { "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": { "schema": { "created_at": "2014-01-01T05:20:00.12345Z", "kind": "openapi_v3", "name": "petstore schema", "schema_id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "source": "", "validation_enabled": true }, "upload_details": { "warnings": [ { "code": 28, "locations": [ ".paths[\"/user/{username}\"].put" ], "message": "unsupported media type: application/octet-stream" } ] } }, "success": true } ```