CREATE HTTP RULE
statementnot supportedOtherpreviewCreates an HTTP rule or replaces an existing HTTP rule. HTTP rules apply only in Cortex Code cloud sandboxes, which check the method and path of each request. Other features that use external access integrations ignore them; see Where HTTP rules apply.
Syntax
supportedpartialnot supportednot scored
CREATE [ OR REPLACE ] HTTP RULE [ IF NOT EXISTS ] <name>
SPECIFICATION = { '<yaml>' | $$<yaml>$$ }
Parameters
| Name | Required | Description |
|---|---|---|
name | required | Identifier for the HTTP rule; must be unique for the schema in which the HTTP rule is created. In addition, the identifier must start with an alphabetic character and cannot contain spaces or special characters unless the entire identifier string is enclosed in double quotes (for example, "My object"). Identifiers enclosed in double quotes are also case-sensitive. For more information, see Identifier requirements. |
SPECIFICATION = { 'yaml' | $$yaml$$ } | required | Specifies the destinations and requests that the HTTP rule allows, as a YAML document. For the format, see Specification format. Enclose the document in dollar signs ($$) so that you don’t need to escape the quotes and line breaks in it. |
Usage notes
- The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.
- CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.
- When Snowflake rejects a specification, the error names the field that caused it, such as matches[0].tls.http[1].path, and the reason. The error doesn’t include the field’s value.
- The specification must be a single YAML document. Anchors, aliases, tags, and merge keys aren’t supported. Enclose a value in quotes if YAML would otherwise read it as a number, a boolean, a null, or a date: for example, '1024' or 'yes'.
- Snowflake stores the specification in a normalized form. DESCRIBE HTTP RULE shows that form, which doesn’t keep your comments, layout, or key order and always includes each destination’s port.
- HTTP rules apply only in Cortex Code cloud sandboxes. For details, see Where HTTP rules apply.
- Regarding metadata: Attention Customers should ensure that no personal data (other than for a User object), sensitive data, export-controlled data, or other regulated data is entered as metadata when using the Snowflake service. For more information, see Metadata fields in Snowflake.
Access control requirements
A role used to execute this operation must have the following privileges at a minimum: Privilege | Object | Notes CREATE HTTP RULE | Schema | Only the schema owner has this privilege by default. It can be granted to additional roles as needed. OWNERSHIP | HTTP Rule | Required to replace an existing HTTP rule with CREATE OR REPLACE. Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema. For instructions on creating a custom role with a specified set of privileges, see Creating custom roles. For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.
Specification format
A specification lists destinations and, for each destination, the requests that the rule allows. For example: The specification has the following fields. Any other field causes an error. matches: Required. A list of one or more entries, each of which names a destination and the requests allowed to it. Each entry contains the following fields: Each entry must have tls, http, or both. A request over HTTPS is checked only against tls, and a request over plain HTTP only against http. destination: Required. A mapping with the following fields: type: Required. Must be HOST_PORT. value: 'host[:port]': Required. The host, and optionally the port, that the entry applies to. For the rules that apply, see Destinations. tls: A mapping with one field, http, which lists the requests allowed to the destination over HTTPS. http: A list of the requests allowed to the destination over plain HTTP. If an entry has http, its destination must name a port, such as 'deb.debian.org:80'. Each item in a tls.http or http list describes the requests it allows with up to two fields: method: A pattern that the request’s method must match, such as GET or 'GET|HEAD'. If you omit it, every method matches. path: A pattern that the request’s path must match, such as '/v1/items/[0-9]+'. The query string isn’t part of the path. If you omit it, every path matches. A request is allowed if it matches both patterns of any one item in the list. An empty item, {}, allows every request to the destination over that transport. - A host must be a domain name, not an IP address. A host that doesn’t contain a wildcard must be a name under a public suffix, such as .com or .co.uk. Write internationalized domain names in their xn-- form. - A host can contain one wildcard (*), which matches one or more letters, digits, or hyphens within a single label. At least two labels must follow the label with the wildcard. For example, '*.example.com' matches api.example.com, but not example.com or a.b.example.com. Enclose a host that contains a wildcard in quotes. - The port must be 80, 443, or a number from 1024 to 65535. If you omit the port, it’s 443. - When you create or alter the rule, Snowflake checks that each host that doesn’t contain a wildcard resolves to a public IPv4 address. Method and path patterns are regular expressions in the following subset: - A pattern matches the whole method or path. Don’t use the anchors ^ and $. - Matching is case-sensitive. For example, GET doesn’t match get. - A pattern can contain printable ASCII characters other than the space character. - You can use ., bracket expressions such as [0-9] or [^/], non-capturing groups (?:...), alternation with |, and the quantifiers *, +, and ?. Ranges in a bracket expression must lie within 0-9, a-z, or A-Z. - To match a special character literally, escape it with a backslash, such as \. or \?. - The following aren’t supported: capturing groups, flags such as (?i), counted repeats such as {2}, character class escapes such as \d, \w, or \s, lazy or possessive quantifiers, lookarounds, and backreferences. - A ] or } outside a bracket expression must be escaped. A path pattern matches the path as the request sends it. Snowflake doesn’t decode percent-escapes before matching, so write an escaped character as the request sends it, with uppercase hexadecimal digits: for example, /@scope%2Fname. A path that a server could interpret in more than one way, such as one that contains a . or .. segment, an empty segment, or a backslash, matches no path pattern. Item | Limit Length of a pattern | 256 bytes Patterns in a rule, counting each method and each path | 32 Entries in matches | 64 Size of a specification | 32,768 bytes HTTP rules in an external access integration | 32