api.parse function. Then use the api.extract user-defined function (UDF) to extract key-value pairs from the Markdown returned by the api.parse function.
The Markdown you specify will be sent to the -hosted service, and the results will display directly in Snowsight.
Using the api.extract function is the same as calling the endpoint. For full details about this endpoint and its response, go to .
Extract Inputs
Theapi.extract function requires two inputs:
- the Markdown content from
api.parse - a JSON Schema that defines which fields to extract and their expected format
Methods for Passing the JSON Schema
Theapi.extract function accepts the JSON schema in two formats:
Pass a URL to an Externally Hosted JSON Schema
Use this method when you:- Reuse the same schema across multiple queries
- Work with complex schemas that would clutter your SQL script
- Share schemas across teams or projects
api.extract:
Include the JSON Schema Inline with PARSE_JSON
Use this method when you:- Have a simple schema specific to one query
- Want to keep all logic contained in a single script
- Prototype or test schema definitions
PARSE_JSON function:
Sample Scenarios
This section provides examples of how to run theapi.extract function in different scenarios.
- Parse and Extract Data from Files at Publicly Accessible URLs
- Parse and Extract Data from a Staged File
Parse and Extract Data from Files at Publicly Accessible URLs
Run the command below to parse multiple files at publicly accessible URLs, and then extract data from the parsed output. We’ve provided the sample files to help you get started. Replace this placeholder with your information:APP_NAME.
Parse and Extract Data from a Staged File
Run the command below to parse a single file in a Snowflake stage, and then extract data from the parsed output. Replace these placeholders with your information:APP_NAME, your_db, your_schema, your_stage, path/to/file.pdf, and the JSON schema in the PARSE_JSON function.
Sample Script: Parse and Extract a Staged File
Let’s say you have the following setup:- APP_NAME: AGENTIC_DOCUMENT_EXTRACTION__APP
- Database: DEMO_DB
- Schema: DEMO_SCHEMA
- Stage: DEMO_STAGE
- PDF: statement-jane-harper.pdf
- Employee Name
- Employee Social Security Number
statement-jane-harper.pdf:
employee_name and employee_ssn fields.


