actions.json
As described in the URL Scheme section, an actions.json
file may be used at the root URL of a website to create a mapping between the site's pages and their associated actions. When provided with a website URL, Clients that render Blinks may check for the presence of this file at the site's root URL.
For example, my-site.com would store its actions.json
file at https://my-site.com/actions.json, and this single file would be responsible for the mapping rules for all my-site.com
pages.
CORS Headers
The actions.json
file response must include valid CORS headers for the GET
& OPTIONS
requests, and must have an Access-Control-Allow-Origin
header value of *
. See the dedicated CORS header section linked above for more details.
Rules
The rules
field allows the application to set up a mapping between a set of a website's relative route paths to a set of different paths.
Type: Array
of ActionRuleObject
.
We'll discuss these in more detail in the next two sections.
Rules - pathPattern
pathPattern
is a string
pattern that matches each incoming pathname. It can be an absolute or relative path and supports the following formats:
Exact Match: Matches the exact URL path.
Example:
/exact-path
Example:
https://website.com/exact-path
Wildcard Match: Uses wildcards to match any sequence of characters in the URL path. This can match single (using
*
) or multiple segments (using**
). (see Path Matching below).Example:
/trade/*
will match/trade/123
and/trade/abc
, but it only captures the first segment after/trade/
.Example:
/category/*/item/**
will match/category/123/item/456
and/category/abc/item/def
.Example:
/api/actions/trade/*/confirm
will match/api/actions/trade/123/confirm
.
Rules - apiPath
apiPath
is a string
indicating the destination path for the action request. It can be defined as an absolute pathname or an external URL.
Example:
/api/exact-path
Example:
https://api.example.com/v1/donate/*
Example:
/api/category/*/item/*
Example:
/api/swap/**
Rules - Query Parameters
Query parameters from the original URL are always preserved and appended to the mapped URL.
Rules - Path Matching
The following table outlines the syntax for path-matching patterns:
Rules Examples
The following example demonstrates an exact match rule to map requests to /buy
from your site's root to the exact path /api/buy
relative to your site's root:
This example uses wildcard path matching to map requests to any path (excluding subdirectories) under /actions/
, from your site's root to a corresponding path under /api/actions/
relative to your site's root:
The following example uses wildcard path matching to map requests to any path (excluding subdirectories) under /donate/
, from your site's root to the corresponding https://api.dialect.com/api/v1/donate/
absolute path at an external site:
This example uses wildcard path matching for an idempotent rule to map requests to any path (including subdirectories) under /api/actions/
, from your site's root to itself:
Idempotent rules allow blink clients to more easily determine if a given path supports Action API requests without having to be prefixed with the
solana-action:
URI or performing additional response testing.
Open Graph Meta Tags
For a blink to render when the URL of your action website is pasted, a couple of Open Graph meta tags or X (Twitter) meta tags need to be included in the <head>
of your webpage.
For example:
Last updated