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

# Share Artifact

Generate a signed share URL for an existing artifact. The URL allows anyone to view the artifact without authentication.

## Request

<ParamField path="id" type="string" required>
  The artifact ID to share
</ParamField>

<ParamField body="expiresIn" type="string">
  Share link expiration. Examples: `1h`, `24h`, `7d`, `30d`. Default: `7d`
</ParamField>

<ParamField body="allowDownload" type="boolean">
  Allow viewers to download the artifact (PDF only). Default: `false`
</ParamField>

<ParamField body="password" type="string">
  Optional password protection for the share link
</ParamField>

## Response

<ResponseField name="url" type="string">
  The shareable URL
</ResponseField>

<ResponseField name="token" type="string">
  The share token (for reference)
</ResponseField>

<ResponseField name="expiresAt" type="string">
  ISO 8601 expiration timestamp
</ResponseField>

<ResponseExample>
  ```json 200 theme={null}
  {
    "url": "https://genui.sh/a/art_abc123?token=eyJhbGc...",
    "token": "eyJhbGc...",
    "expiresAt": "2024-01-22T12:00:00Z"
  }
  ```

  ```json 404 theme={null}
  {
    "error": {
      "code": "not_found",
      "message": "Artifact not found"
    }
  }
  ```
</ResponseExample>

## Code Examples

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://genui.sh/api/artifacts/art_abc123/share \
    -H "Authorization: Bearer $GENUI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"expiresIn": "7d"}'
  ```

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

  artifact_id = "art_abc123"
  response = requests.post(
      f"https://genui.sh/api/artifacts/{artifact_id}/share",
      headers={"Authorization": f"Bearer {os.environ['GENUI_API_KEY']}"},
      json={"expiresIn": "7d"}
  )
  share = response.json()
  print(f"Share URL: {share['url']}")
  print(f"Expires: {share['expiresAt']}")
  ```

  ```javascript JavaScript theme={null}
  const artifactId = 'art_abc123';
  const response = await fetch(`https://genui.sh/api/artifacts/${artifactId}/share`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.GENUI_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ expiresIn: '7d' })
  });
  const { url, expiresAt } = await response.json();
  console.log(`Share URL: ${url}`);
  console.log(`Expires: ${expiresAt}`);
  ```

  ```go Go theme={null}
  artifactID := "art_abc123"
  payload := map[string]string{"expiresIn": "7d"}
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("POST", "https://genui.sh/api/artifacts/"+artifactID+"/share", bytes.NewBuffer(body))
  req.Header.Set("Authorization", "Bearer "+os.Getenv("GENUI_API_KEY"))
  req.Header.Set("Content-Type", "application/json")

  client := &http.Client{}
  resp, _ := client.Do(req)
  defer resp.Body.Close()

  var share map[string]string
  json.NewDecoder(resp.Body).Decode(&share)
  fmt.Printf("Share URL: %s\n", share["url"])
  ```

  ```ruby Ruby theme={null}
  artifact_id = 'art_abc123'
  uri = URI("https://genui.sh/api/artifacts/#{artifact_id}/share")

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = "Bearer #{ENV['GENUI_API_KEY']}"
  request['Content-Type'] = 'application/json'
  request.body = { expiresIn: '7d' }.to_json

  response = http.request(request)
  share = JSON.parse(response.body)
  puts "Share URL: #{share['url']}"
  ```

  ```rust Rust theme={null}
  let artifact_id = "art_abc123";
  let response = client
      .post(format!("https://genui.sh/api/artifacts/{}/share", artifact_id))
      .header("Authorization", format!("Bearer {}", api_key))
      .json(&json!({"expiresIn": "7d"}))
      .send()
      .await?;

  let share: serde_json::Value = response.json().await?;
  println!("Share URL: {}", share["url"]);
  ```

  ```csharp .NET theme={null}
  var artifactId = "art_abc123";
  var response = await client.PostAsJsonAsync($"https://genui.sh/api/artifacts/{artifactId}/share", new {
      expiresIn = "7d"
  });
  var share = await response.Content.ReadFromJsonAsync<JsonElement>();
  Console.WriteLine($"Share URL: {share.GetProperty("url")}");
  ```
</CodeGroup>

## Password-Protected Sharing

To create a password-protected share link:

```json theme={null}
{
  "expiresIn": "7d",
  "password": "secret123"
}
```

Viewers will be prompted to enter the password before accessing the artifact.
