Create share
Code Mode: praxis.share.permissions.create
HTTP: POST /share/v1/permissions
Make one object readable by anyone holding a link, before sending the link to a person or embedding it. Name the object as resource {type, id} — a file id from the File API, a canvas id, a media asset’s library_id/asset_id, or an agent id (agent_…) of a service agent whose owner turned share links on. The response is 201 and is the only time link.web_url is returned; store it, because later reads omit it and a lost address means creating another share (the old one keeps working until you delete it). Opening a file or media link signs a short-lived read address; opening a canvas link shows a snapshot rendered at that moment; opening an agent link starts a Hosted conversation with that agent as the visitor, so each browser keeps its own history. The link is anonymous, and for every type so far read-only. A type that cannot be shared answers 400 RESOURCE_TYPE_UNSUPPORTED; an agent whose share links are switched off answers 400 RESOURCE_NOT_SHAREABLE and its owner turns them on in the agent’s embed settings (share_links), which also requires the agent to have a short number; an object that is missing or outside your organization answers 404 RESOURCE_NOT_FOUND.
签名
praxis.share.permissions.create(args:{body:{resource:{/** What kind of object is shared; file, canvas, media_asset and agent create today. e.g. "file" */ type:"file"|"artifact"|"canvas"|"media_asset"|"agent";/** Id of the object within its type. */ id:string};/** ISO 8601 instant after which the link answers 410; omit or null for a link that never expires, and it must be in the future. e.g. "2026-12-31T00:00:00Z" */ expire_time?:string|null;/** Ask viewers to open the content without a download prompt; a limit, not a guarantee, because anyone who can read it can save it. */ prevents_download?:boolean}}):Promise<{/** Share id, shr_ followed by 32 lowercase letters or digits; use it to retrieve or delete the share. */ id:string;/** Object type tag; always share.permission. */ object:"share.permission";/** The organization that owns the share, taken from the credential that created it. */ organization_id:string;resource:{/** What kind of object is shared; file, canvas, media_asset and agent create today. e.g. "file" */ type:"file"|"artifact"|"canvas"|"media_asset"|"agent";/** Id of the object within its type. */ id:string};/** What the link grants; read only. */ roles:Array<"read">;link:{/** What the link allows; view, which is read-only, is the only type. */ type:"view";/** Who can open the link; anonymous, meaning anyone holding it, is the only scope. */ scope:"anonymous";/** Whether the link asks viewers not to download; a limit, not a guarantee. */ prevents_download:boolean;/** The link address to give to people; present only in the creation response, since the service stores a hash of it and cannot show it again. */ web_url?:string};/** ISO 8601 instant after which the link answers 410, or null when it never expires. */ expire_time:string|null;/** Current state of the link; expired is derived from expire_time and revoked comes from delete. */ status:"active"|"expired"|"revoked";/** Who created the share, in the form user:{id}; the user behind the API key or session that made the call. */ created_by:string;/** When the share was created, ISO 8601. */ create_time:string;/** When the share was deleted, ISO 8601, or null while it has not been. */ revoke_time:string|null;/** How many times the link was opened. */ open_count:number;/** When the link was last opened, ISO 8601, or null if it never was. */ last_open_time:string|null}>;请求体
| 必填 | 内容类型 | 说明 |
|---|---|---|
| 是 | application/json | The object to share and the limits of the link. |
响应
| 状态码 | 内容类型 | 说明 |
|---|---|---|
| 201 | application/json | The new share, including link.web_url, which is returned only in this response. |
| 400 | application/json | INVALID_PARAMS means a body field or identifier violates the documented format; RESOURCE_TYPE_UNSUPPORTED means the resource type cannot be shared yet; RESOURCE_NOT_SHAREABLE means the object exists but its owner keeps share links off — for an agent, turn share links on in its embed settings (share_links) first, which requires the agent to have a short number. Correct the indicated field; the message names it. |
| 401 | application/json | The bearer API key is missing or invalid; provide a valid Praxis API key before retrying. |
| 403 | application/json | PERMISSION_DENIED means the credential cannot perform this operation, or is bound to specific files and listed without naming one; use a key with share access, or pass resource_type and resource_id of a bound file. |
| 404 | application/json | RESOURCE_NOT_FOUND means the object to share does not exist in this organization, or the credential is not bound to it; read the file id from the File API and retry. |
| 500 | application/json | INTERNAL means the service could not complete the request; for a create, list shares for the file before retrying so the same object is not exposed twice. |