Request data sharing with app specifications¶
This topic describes how to configure the specifications of a Snowflake Native App to request permission to share data with providers or third parties through listings. This enables use cases such as compliance reporting, telemetry sharing, and data preprocessing.
App specification workflow for sharing data¶
Configuring an app to share data by using listings follows this general workflow:
Providers configure automated granting of privileges for the app. This allows consumers to give permission to an app to create shares and listings.
Note
App specifications require
manifest_version = 2to be set in the manifest file.Providers add the CREATE SHARE and CREATE LISTING privileges to the manifest file.
Providers add SQL statements to the setup script to create the following objects as required:
The setup script creates the share and listing when the app is installed or upgraded. The app specification can be created during setup or at runtime through a stored procedure.
When configuring the app, consumers review and approve the target accounts and auto-fulfillment settings on the listing. Auto-fulfillment settings are only applicable for cross-region sharing. For more information on how consumers view and approve app specifications, see Approve connections to external resources using app specifications.
App specification definition for sharing data¶
For an app specification of type LISTING, the app specification definition contains the following entries:
TARGET_ACCOUNTS: A comma-separated list of target accounts to share data with, enclosed in single quotes. Each account must be specified in the formatOrgName.AccountName; for example:'ProviderOrg.ProviderAccount,PartnerOrg.PartnerAccount'.LISTING: The identifier of the listing object created by the app.AUTO_FULFILLMENT_REFRESH_SCHEDULE: Optional. The refresh schedule for cross-region data sharing. Can be specified as<num> MINUTEorUSING CRON <expression>.
Note
The listing name in the app specification must match an existing listing created by the app. After this is set, the listing name cannot be changed.
Set the version of the manifest file¶
To enable automated granting of privileges for an app, set the version at the beginning of the manifest file, as shown in the following example:
manifest_version: 2
Create an external listing¶
To create an external listing attached to the share, add the CREATE LISTING command to the setup script as shown in the following example:
CREATE EXTERNAL LISTING compliance_listing SHARE compliance_share AS $$ title: "Compliance Data Share" subtitle: "Regulatory compliance reporting data" description: "Share compliance and audit data with authorized accounts" listing_terms: type: "OFFLINE" $$ PUBLISH = FALSE REVIEW = FALSE;
Note
Apps can only attach shares, not application packages, to a listing.
Apps cannot directly add target accounts or auto-fulfillment configuration to the listing.
The listing manifest can only include the following properties: title, subtitle, description, and listing_terms.
All new listings must be created in an unpublished state, with both PUBLISH and REVIEW set to FALSE.
The listing title and description can be customized based on the consumer info, allowing providers to distinguish data sources.
Create an app specification for a listing¶
To create an app specification for a listing, follow this example:
ALTER APPLICATION SET SPECIFICATION shareback_spec TYPE = LISTING LABEL = 'Compliance Data Sharing' DESCRIPTION = 'Share compliance data with provider for regulatory reporting' TARGET_ACCOUNTS = 'ProviderOrg.ProviderAccount,AuditorOrg.AuditorAccount' LISTING = compliance_listing AUTO_FULFILLMENT_REFRESH_SCHEDULE = '720 MINUTE';This command creates an app specification named
shareback_specthat requests permission to share data with the specified target accounts.
For cross-region sharing, the
AUTO_FULFILLMENT_REFRESH_SCHEDULEparameter is required. You can set it to one of the following values:'<num> MINUTE': Number of minutes, with a minimum of 10 minutes,and a maximum of 8 days or 11520 minutes (eight days)
'USING CRON <expression> <time_zone>': Cron expression with time zone
Note
The app should only create the app specification after the listing and share objects exist.
Each listing can only have one associated app specification.
Updating the target accounts creates a new pending request for consumer approval.
Validating the listing configuration¶
Apps can validate that the listing has been properly configured after approval by running the following commands:
-- Check if the app specification is approved:
SHOW APPROVED SPECIFICATIONS IN APPLICATION;
-- Validate the listing configuration:
DESC LISTING compliance_listing;
Consumer approval workflow¶
Consumer approval of a LISTING app specification triggers this workflow:
Snowflake automatically adds the target accounts to the listing.
If specified, Snowflake configures the auto-fulfillment refresh schedule.
The listing becomes visible to the target accounts.
Data attached to the listing can be queried from the approved accounts.
Consumer rejection of a LISTING app specification triggers this workflow:
The listing becomes unpublished, and any existing target accounts are removed from the listing.
Auto-fulfillment is disabled.
The listing is no longer visible to any target accounts.
Best practices for LISTING app specifications¶
When implementing data sharing through app specification, consider the following best practices:
- Share integrity: Snowflake does not prevent consumers from modifying
 shares created by an application. As a result, the provider is responsible for implementing measures to protect the integrity of the underlying shared data.
Error handling: Implement proper error handling for cases where the app specification is declined or not yet approved.
Cross-region considerations: The app provider is responsible for setting refresh schedules that balance data freshness requirements with cost considerations. Although Listing Auto Fulfillment costs are billed to the app consumer, the provider’s choice of schedule should be cost-aware to minimize the unnecessary cost for the app consumer.
Compliance: Document clearly what data you are sharing, and why you are sharing it, in the app specification description.
Using callback functions with LISTING app specifications¶
Apps can use lifecycle callbacks to respond when consumers approve or decline listing specifications by adding the following code to the manifest file:
lifecycle_callbacks:
  specification_action: callbacks.on_spec_update
In the setup script, add the following callback stored procedure:
CREATE OR REPLACE PROCEDURE callbacks.on_spec_update (
  name STRING,
  status STRING,
  payload STRING)
RETURNS STRING
LANGUAGE SQL
AS
$$
BEGIN
  IF (name = 'shareback_spec' AND status = 'APPROVED') THEN
    -- Start populating shared tables
    CALL populate_compliance_data();
  ELSEIF (name = 'shareback_spec' AND status = 'DECLINED') THEN
    -- Clean up or notify provider
    CALL cleanup_share_data();
  END IF;
  RETURN 'Processed specification update';
END;
$$;
The procedure allows the app to react appropriately to consumer decisions about app’s data sharing request.
Limitations¶
This section describes limitations when using app specifications.
- Auditing
 Snowflake doesn’t offer built-in auditing for data that an app shares back to the provider. If a consumer has compliance or regulatory requirements that include an audit trail, they must coordinate directly with the provider to implement their own separate monitoring solutions.
- Sharing from within the application
 Snowflake does not recommend data sharing with the provider directly from within the application because Listing Auto Fulfillment is not currently supported for data shared in this manner.