Share¶
POST /api/v1/snapshots/{snapshot_uuid}/share
Overview¶
Create an access share and a long-lived first-hop code for an existing snapshot.
Before Calling and Usage Steps¶
The current key must have share.shareManage, and only snapshots that have not been deleted in the current workspace are supported. Free Plan/free edition workspaces do not support snapshot sharing; the site version determines this. Each call creates a new share configuration, and there is no public idempotency key. Repeated requests may produce multiple valid shares. On timeout/500, first check the share management list in the current console and verify the resourceUUID before deciding whether to retry.
content.token and authCode are the same long-lived first-hop code, used for the /share/{code} page under the current workspace's branded/custom console domain. They are not a second-stage share token that can be used directly for data queries, and are certainly not the share_ configuration UUID. shortUrl may be empty when the site disables short links; use the actual console entry point concatenated with /share/ and authCode. Do not hard-code the branded domain. To cancel a share, obtain the corresponding share_ UUID from Share Management in the console. The current creation response does not return this UUID, and this OpenAPI group does not provide a public ShareConfig list, so the UUID cannot be derived from the code returned by this call alone. If the UI does not display it, ask the workspace administrator to help obtain it. Do not use a cross-workspace authorization configuration grant_ UUID, and do not pass token or snap_.
This call saves a copy of the snapshot page configuration for display, while actual queries still restore the server-side scope saved with the snapshot. The client-side maskCfg only performs additional masking and cannot expand authorization. Share regular expressions process only string values; numbers/objects/arrays are not masked by this rule. fields=* must be used alone; a mixed list such as *,message does not guarantee coverage of all fields. Save-time regex validation uses regex, while execution uses Python standard re.sub. Use syntax supported by both and test with actual samples; a successful save does not guarantee that queries can be executed. Queries with missing/unsupported scopes in old snapshots may return 403 on access and require the original sharer to regenerate them. Successful share creation does not guarantee that every query is available.
For IP control, currently only custom can actually pass the public declaration; followWorkspace returns 406 due to a length validation conflict. isOpen=true, type=custom, and a non-empty list of real IPs are required; custom[] does not actually restrict access. Use extraction codes/expiration and masking to control access as needed; hiddenTopBar/showWatermark are display-only. Short link and first-hop code cache synchronization may occur before or after the main body is committed; a 500 does not guarantee that no valid share exists. Verify first, then retry.
Route Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| snapshot_uuid | string | Y | Not the share configuration share_ UUID, the token/authCode first-hop code, or the dashboard UUID. Example: snap_exampleHow to obtain or enter: Get content.data[].uuid from the Snapshot List, and operate only on snap_ UUIDs that the current key confirms it has permission to manage. |
Request Headers¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| DF-API-KEY | string | Y | OpenAPI authentication credential for the workspace. Example: <DF-API-KEY>How to obtain or enter: Obtain an OpenAPI key with this operation permission from API Key Management in the target workspace. |
Request Body Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| maskCfg | object | Optional object; correct fields/reExprs must be constructed together. This is additional share masking and does not replace the data/sensitive rules captured when the snapshot was generated; full coverage of real data is not automatically verified. Example: {"fields": "message", "reExprs": [{"name": "email", "reExpr": "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+", "enable": 1}]}How to obtain or enter: Construct it according to the actual fields to display and the masking pattern, and verify it first on controlled data. |
|
| maskCfg.fields | string | Optional string. If omitted/empty, no share masking fields are specified; leading and trailing whitespace is stripped per field. Only matching string values have enabled regular expressions applied; numbers/objects/arrays are not converted or masked by this share regex; it is not an access allowlist. Allowed null: False Allowed empty string: True Example: message,hostHow to obtain or enter: Select fields from the actual column names returned by the snapshot query, separated by commas; for all fields, pass * alone, and do not write a mixed list such as *,message. |
|
| maskCfg.reExprs | array | Optional array of objects; omit for []. At creation, syntax is checked for all reExpr values, including items with enable=0. Item declarations are not fully validated; non-object items may cause a 500. Allowed null: False Example: [{"name": "email", "reExpr": "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+", "enable": 1}]How to obtain or enter: The caller provides an array of validated regular expressions. |
|
| maskCfg.reExprs[*] | json | The object must contain a correct reExpr and enable, and is applied in array order. Example: {"name": "email", "reExpr": "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+", "enable": 1}How to obtain or enter: One masking rule. |
|
| maskCfg.reExprs[*].name | string | Optional display name; it is not used to select fields. Example: emailHow to obtain or enter: The caller assigns a display name to the regex. |
|
| maskCfg.reExprs[*].reExpr | string | Save-time validation uses regex.finditer, while execution uses standard re.sub; both must be compatible. Syntax unique to regex may save successfully but then fail during a share query. Save validation failure returns 400 ErrorRegularExpression; verify with actual string samples and performance. Example: [A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+How to obtain or enter: Enter an expression compatible with Python standard re.sub and verify it against real samples. |
|
| maskCfg.reExprs[*].enable | integer | At runtime, truthiness determines whether it executes; 0/1 integers are recommended. No complete enum is declared, so do not rely on arbitrary types for stable behavior. Example: 1How to obtain or enter: 0 disables, 1 enables. |
|
| ipWhitelistSet | object | Optional IP control object. If omitted/disabled, no share IP restriction is added. Creation does not fully validate IP strings; verify in the actual access path. Example: {"isOpen": true, "type": "custom", "ipWhitelist": ["192.0.2.0/24"]}How to obtain or enter: The network administrator provides the real egress IP/CIDR allowed to access the share; example addresses must be replaced. |
|
| ipWhitelistSet.isOpen | boolean | Optional boolean; if omitted, false. Even when true, a valid type must be selected and a non-empty list provided to restrict as expected. Allowed null: False Example: trueHow to obtain or enter: Set explicitly to true when the networks receiving the share need to be restricted. |
|
| ipWhitelistSet.type | string | The declared enum is custom/followWorkspace, but followWorkspace is 15 characters long and conflicts with the current maxLength 12, causing an upfront 406; it cannot be set through this public entry point. If omitted/empty with isOpen=true, runtime may only warn without restricting access; do not treat it as following the workspace by default. Allowed null: False Allowed empty string: True Maximum length: 12 Allowed values: ['followWorkspace', 'custom'] Example: customHow to obtain or enter: For current public writes, use custom. |
|
| ipWhitelistSet.ipWhitelist | array | Optional array; when custom, it should be explicitly non-empty. [] currently does not restrict access in practice; it does not deny all. There is no per-item creation validation; invalid addresses may cause exceptions during access, so be sure to verify. Allowed null: False Example: ["192.0.2.0/24"]How to obtain or enter: A single IP or CIDR range provided by the network administrator; confirm the real client egress address recognized by the server. |
|
| ipWhitelistSet.ipWhitelist[*] | string | A single IP/CIDR string, not a domain or URL. Example: 192.0.2.0/24How to obtain or enter: The real allowed egress IP/CIDR; the example CIDR only illustrates the format. |
|
| changeTime | boolean | Optional boolean; the UI defaults to false. It only saves display control and does not expand the server-side authorization scope/original data retention period. Allowed null: False Example: falseHow to obtain or enter: Decide based on whether share visitors are allowed to adjust the query time in the UI. |
|
| expirationAt | integer | Optional integer; if omitted, the site's snapshotShareCfg.effectiveTime applies (default 172800 seconds = 2 days); -1 means permanent. Although an explicit empty string is declared as allowed, it is normalized to -1; only integers are recommended. A past time can be saved but expires immediately on access; this is not Unix milliseconds. Allowed null: False Allowed empty string: True Example: -1How to obtain or enter: The caller selects the validity period in Unix seconds; -1 means permanent, or use the current time plus the desired number of valid seconds. |
|
| extractionCode | string | Optional string; omitted/empty means no extraction code is added. It is not DF-API-KEY or the share first-hop authCode. The server stores the extraction code; do not record it in public logs. Allowed null: False Allowed empty string: True Maximum length: 12 Example: read123How to obtain or enter: The caller generates a 1–12 character extraction code and communicates it to recipients through a controlled channel. |
|
| hiddenTopBar | boolean | Optional boolean, default false; the Body overrides compatible Query values. It only controls the page top bar and is not authentication. Allowed null: False Example: falseHow to obtain or enter: Choose according to the share page display requirements. |
|
| showWatermark | boolean | Optional boolean; the UI defaults to false. A watermark does not replace data access restrictions. Allowed null: False Example: falseHow to obtain or enter: Choose according to share display needs. |
Additional Parameter Notes¶
The snapshot saves the page configuration and server-side query scope; internet sharing requires creating a separate share configuration. snap_, share_, first-hop code, and second-stage token are different identifiers.
Request Example¶
curl --request POST 'https://openapi.guance.com/api/v1/snapshots/snap_example/share' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json' \
--data-raw '{"expirationAt":-1,"extractionCode":"read123","changeTime":false,"hiddenTopBar":false,"showWatermark":true,"ipWhitelistSet":{"isOpen":true,"type":"custom","ipWhitelist":["192.0.2.0/24"]}}'
Response¶
HTTP 200, application/json. The example below shows the main fields that can be read directly.
| Field | Type | Description |
|---|---|---|
| content | object | Share creation result; does not include the share_ configuration UUID or the full snapshot. |
| content.token | string | Long-lived first-hop code compatibility field; same as authCode, and not a second-stage query token. |
| content.authCode | string | The same long-lived first-hop code; access the console at /share/{code}; the validity period follows the share configuration. |
| content.shortUrl | string | Full URL of the generated short link; empty when disabled/not returned, in which case use the original share address from the console. |
| content.isHidden | boolean | Always false for this public creation; isHidden input is not accepted. |
| content.declaration | object or null | Workspace public declaration for a non-empty business object; may be null or an empty object when not configured; empty business objects are not attached. |
{
"code": 200,
"content": {
"token": "SHARE-LINK-CODE",
"authCode": "SHARE-LINK-CODE",
"shortUrl": "",
"isHidden": false,
"declaration": {}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-EXAMPLE"
}
Error Responses¶
For authentication, rate limiting, and common request errors, see Common Error Definitions.
| HTTP Status | errorCode | Trigger Condition | Message or Response Description | Handling |
|---|---|---|---|---|
| 406 | ft.ParameterValidationFailed | A request field is missing, or a field value violates the declared validation conditions | Parameter parsing failed | Check the parameter location, field name, type, and value. |
| 400 | ft.RequestJsonFormatError | Invalid request JSON syntax | Request JSON format error | Correct the JSON according to content.reason, line, and column. |
| 400 | ft.JsonFormatError | The top level of the request JSON is not an object | Partial JSON file format error | Submit a share parameter object. |
| 404 | ft.ObjectNotExists | The target snapshot in the current workspace does not exist/has been deleted | The specified object does not exist | Obtain the snap_ UUID again from the snapshot list in this workspace. |
| 401 | ft.WKSPNotExistOrReleased | Creating the share failed to validate the current active workspace/the workspace has been released | Workspace does not exist/or has been released | First verify the active status of the workspace for the current key; unlike NotFoundWorkspace, which only constructs a branded address, do not rely on an existing page link to prove that the workspace is still valid. |
| 403 | ft.ForbiddenFreeWKSPSnapshotShare | The current workspace is a Free Plan/free edition version that does not support snapshot sharing | Snapshot sharing is prohibited in Free Plan workspaces | Have the administrator verify the product version; do not bypass this using undocumented parameters such as isHidden. |
| 403 | ft.ShareTokenInvalid | After the pre-check found the snapshot, the resource became invalid when share creation read it again | The share resource is no longer valid | Refresh the snapshot status and confirm whether it has been deleted. |
| 406 | ft.NotFoundWorkspace | The workspace does not exist when constructing the console address from the branded/custom domain | The specified workspace was not found | Have the administrator verify the key workspace and access domain configuration. |
| 400 | ft.ErrorRegularExpression | Any regular expression in maskCfg.reExprs cannot be compiled, including disabled items | Regular expression error | Validate all regular expressions first, remove invalid items, and then create again. |
| 500 | ft.InternalServerError | An unhandled exception occurs in historical snapshot content/meta structures, share/first-hop credential writes, short link generation, or credential cache synchronization after commit | Internal error | First check in Share Management in the console whether it has been created, then decide whether to retry to avoid generating multiple valid shares; retain traceId for troubleshooting. |