> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tess.im/llms.txt
> Use this file to discover all available pages before exploring further.

# Share or Unshare Artifact

> Grants and revokes access in one all-or-nothing call. Granting needs the Artifacts User permission (`artifacts:create`) and stays within the sharing levels your admin allows for you. The first grant publishes the latest version when nothing is shared yet. `public` (anyone with the link) opens for any signed-in Tess user; visitors who are not signed in are sent to login first.

Authenticate with a Tess API token in the `Authorization: Bearer` header. See the [Artifacts API guide](https://docs.tess.im/en/artifacts-api.md) for the full flow, permissions and ownership rules.

### **Code Examples**

```http cURL theme={null}
curl --request POST \
  --url 'https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share' \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'x-workspace-id: YOUR_WORKSPACE_ID' \
  --header 'Content-Type: application/json' \
  --data '{
    "grant": [
      {
        "type": "workspace"
      },
      {
        "type": "user",
        "email": "cfo@company.com"
      }
    ]
  }'
```

```json Node.js theme={null}
const axios = require('axios');

const config = {
  method: 'post',
  url: 'https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'x-workspace-id': 'YOUR_WORKSPACE_ID',
    'Content-Type': 'application/json'
  },
  data: {
    "grant": [
      {
        "type": "workspace"
      },
      {
        "type": "user",
        "email": "cfo@company.com"
      }
    ]
  }
};

try {
  const response = await axios(config);
  console.log(response.data);
} catch (error) {
  console.error(error);
}
```

```python Python theme={null}
import requests

url = "https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "x-workspace-id": "YOUR_WORKSPACE_ID",
    "Content-Type": "application/json"
}
payload = {
  "grant": [
    {
      "type": "workspace"
    },
    {
      "type": "user",
      "email": "cfo@company.com"
    }
  ]
}

response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
```

```php PHP theme={null}
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode(["grant" => [["type" => "workspace"], ["type" => "user", "email" => "cfo@company.com"]]]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer YOUR_API_KEY",
    "x-workspace-id: YOUR_WORKSPACE_ID",
    "Content-Type: application/json"
  ]
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "Error: " . $err;
} else {
  echo $response;
}
```

```java Java theme={null}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share"))
    .header("Authorization", "Bearer YOUR_API_KEY")
    .header("x-workspace-id", "YOUR_WORKSPACE_ID")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\n  \"grant\": [\n    {\n      \"type\": \"workspace\"\n    },\n    {\n      \"type\": \"user\",\n      \"email\": \"cfo@company.com\"\n    }\n  ]\n}"))
    .build();

HttpResponse<String> response = client.send(request,
    HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

```go Go theme={null}
package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
    "strings"
)

func main() {
    client := &http.Client{}
    req, err := http.NewRequest("POST", "https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share", strings.NewReader(`{
  "grant": [
    {
      "type": "workspace"
    },
    {
      "type": "user",
      "email": "cfo@company.com"
    }
  ]
}`))
    if err != nil {
        fmt.Println(err)
        return
    }

    req.Header.Add("Authorization", "Bearer YOUR_API_KEY")
    req.Header.Add("x-workspace-id", "YOUR_WORKSPACE_ID")
    req.Header.Add("Content-Type", "application/json")

    resp, err := client.Do(req)
    if err != nil {
        fmt.Println(err)
        return
    }
    defer resp.Body.Close()

    body, err := ioutil.ReadAll(resp.Body)
    if err != nil {
        fmt.Println(err)
        return
    }

    fmt.Println(string(body))
}
```

```jsonnet .NET theme={null}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        using (var client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
            client.DefaultRequestHeaders.Add("x-workspace-id", "YOUR_WORKSPACE_ID");
            var content = new StringContent(@"{
  ""grant"": [
    {
      ""type"": ""workspace""
    },
    {
      ""type"": ""user"",
      ""email"": ""cfo@company.com""
    }
  ]
}", Encoding.UTF8, "application/json");

            var response = await client.PostAsync("https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share", content);
            string responseBody = await response.Content.ReadAsStringAsync();
            Console.WriteLine(responseBody);
        }
    }
}
```

```ruby Ruby theme={null}
require 'uri'
require 'net/http'
require 'json'

uri = URI('https://api.tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f/share')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer YOUR_API_KEY'
request['x-workspace-id'] = 'YOUR_WORKSPACE_ID'
request['Content-Type'] = 'application/json'
request.body = { 'grant' => [{ 'type' => 'workspace' }, { 'type' => 'user', 'email' => 'cfo@company.com' }] }.to_json

response = http.request(request)
puts response.read_body
```

### **Path Parameters**

**universal\_id** `string` *required*

The artifact ID (`universal_id`), for example `artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f`.

### **Headers**

**x-workspace-id** `integer` *required*

Workspace ID. **Required as of 2026-09-01.** Until then, if omitted, the user's selected workspace is used (deprecated). After the cutoff, a missing header returns **422**.

### **Request Body**

**grant** `object[]`

Targets to give access to (at most 50). Required when `revoke` is not sent. Each target has `type`: `user` (with `user_id` or `email`), `team` (with `team_id`; only a team you belong to), `workspace` or `public`.

**revoke** `object[]`

Targets to remove access from (at most 50), with the same shape as `grant`. Required when `grant` is not sent. Revoking ignores sharing restrictions.

### **Response**

**200**

```json theme={null}
{
  "universal_id": "artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f",
  "title": "Weekly pipeline (final)",
  "head_version": 2,
  "shared_version": 1,
  "changes": [
    {
      "action": "grant",
      "target_key": "workspace:1042",
      "result": "granted"
    },
    {
      "action": "grant",
      "target_key": "user:2087",
      "result": "granted"
    }
  ],
  "grants": [
    {
      "target_key": "workspace:1042",
      "type": "workspace",
      "id": 1042
    },
    {
      "target_key": "user:2087",
      "type": "user",
      "id": 2087
    }
  ],
  "viewer_url": "https://tess.im/artifacts/artifact_5d1f0c2e-8a3b-4c6d-9e7f-1a2b3c4d5e6f"
}
```

### **Response fields**

**changes** `array`

One entry per target: `action` (`grant` or `revoke`), `target_key` and `result`.

**grants** `array`

The grants that exist after the call.

**head\_version** `integer`

Latest version number.

**shared\_version** `integer | null`

Version people with access see.

**viewer\_url** `string`

Link that opens the artifact in Tess.

### **Errors**

| Status | Meaning |
| - | - |
| `401` | Missing or invalid API token. |
| `403` | `ARTIFACT_EDIT_FORBIDDEN` (you are not the owner), or `ARTIFACT_PLAN_NOT_ALLOWED` / `ARTIFACT_ROLE_NOT_ALLOWED` when granting. |
| `404` | `ARTIFACT_NOT_FOUND`: the artifact does not exist or is not yours. |
| `422` | Validation error, or a rejected target (the response lists `rejected_targets`): `ARTIFACT_SHARE_LEVEL_NOT_ALLOWED`, `ARTIFACT_TARGET_OUTSIDE_WORKSPACE` or `ARTIFACT_TARGET_NOT_FOUND`. Nothing is changed. |
| `429` | Too many requests. Retry after a short wait. |


## OpenAPI

````yaml api-reference/tess-public-api.openapi.json POST /artifacts/{universal_id}/share
openapi: 3.0.0
info:
  title: Tess API
  version: '0.1'
servers:
  - url: https://api.tess.im
security: []
paths:
  /artifacts/{universal_id}/share:
    post:
      tags:
        - Artifacts
      summary: Share or unshare an artifact
      description: >-
        Grants and revokes access in one all-or-nothing call. Granting needs the
        Artifacts User permission (`artifacts:create`) and stays within the
        sharer's sharing restrictions, set on the Members page: the member's own
        restriction, else the most permissive of their teams', else the defaults
        (organization, workspace and teams on; public off). Targets: `{type:
        user, user_id|email}` (a person of this workspace needs the workspace
        level; a person from another workspace of the same organization needs
        the organization level, which exists only when the workspace belongs to
        one), `{type: team, team_id}` (only a team the sharer belongs to),
        `{type: workspace}`, `{type: public}`. The first grant publishes the
        head when nothing is shared yet. `public` (anyone with the link) opens
        for any signed-in Tess user, from any organization; anonymous visitors
        are sent to login first.
      operationId: 79de954a780c15011636d448b406a7c5
      parameters:
        - name: universal_id
          in: path
          required: true
          schema:
            type: string
        - name: x-workspace-id
          in: header
          description: >-
            Workspace id. If not provided, the user's selected workspace is
            used.
          required: false
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              properties:
                grant:
                  type: array
                  items:
                    required:
                      - type
                    properties:
                      type:
                        type: string
                        enum:
                          - user
                          - team
                          - workspace
                          - public
                      user_id:
                        type: integer
                        nullable: true
                      email:
                        type: string
                        format: email
                        nullable: true
                      team_id:
                        type: integer
                        nullable: true
                    type: object
                  maxItems: 50
                revoke:
                  type: array
                  items:
                    required:
                      - type
                    properties:
                      type:
                        type: string
                        enum:
                          - user
                          - team
                          - workspace
                          - public
                      user_id:
                        type: integer
                        nullable: true
                      email:
                        type: string
                        format: email
                        nullable: true
                      team_id:
                        type: integer
                        nullable: true
                    type: object
                  maxItems: 50
              type: object
      responses:
        '200':
          description: Per-target results and the current grants
          content:
            application/json:
              schema:
                properties:
                  universal_id:
                    type: string
                  title:
                    type: string
                  head_version:
                    type: integer
                    nullable: true
                  shared_version:
                    type: integer
                    nullable: true
                  changes:
                    type: array
                    items:
                      type: object
                  grants:
                    type: array
                    items:
                      type: object
                  viewer_url:
                    type: string
                type: object
        '403':
          description: >-
            ARTIFACT_EDIT_FORBIDDEN (the caller can read the artifact but is not
            its owner), or ARTIFACT_PLAN_NOT_ALLOWED / ARTIFACT_ROLE_NOT_ALLOWED
            when granting without the Artifacts User permission
        '404':
          description: ARTIFACT_NOT_FOUND
        '422':
          description: >-
            Validation error, or a rejected target
            (ARTIFACT_SHARE_LEVEL_NOT_ALLOWED,
            ARTIFACT_TARGET_OUTSIDE_WORKSPACE, ARTIFACT_TARGET_NOT_FOUND) with
            `rejected_targets`; nothing is written
        '429':
          description: Too many requests
      security:
        - token: []
components:
  securitySchemes:
    token:
      type: http
      bearerFormat: Bearer
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.