> ## 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.

# Create and Share

Create an artifact and immediately generate a share URL in a single request. This is the most efficient way to create shareable content.

## Request

<ParamField body="template" type="string" required>
  Template type: `markdown`, `chart`, `table`, `pdf`
</ParamField>

<ParamField body="title" type="string">
  Display title for the artifact
</ParamField>

<ParamField body="content" type="object" required>
  Template-specific content object
</ParamField>

<ParamField body="expiresIn" type="string">
  Expiration for both artifact and share link. Default: `7d`
</ParamField>

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

<ParamField body="metadata" type="object">
  Custom metadata key-value pairs
</ParamField>

## Response

<ResponseField name="id" type="string">
  The artifact ID
</ResponseField>

<ResponseField name="url" type="string">
  The shareable URL (ready to use immediately)
</ResponseField>

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

<ResponseExample>
  ```json 201 theme={null}
  {
    "id": "art_abc123",
    "template": "markdown",
    "title": "Quick Note",
    "status": "active",
    "url": "https://genui.sh/a/art_abc123?token=eyJhbGc...",
    "expiresAt": "2024-01-22T12:00:00Z",
    "createdAt": "2024-01-15T12:00:00Z"
  }
  ```
</ResponseExample>

## Code Examples

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://genui.sh/api/artifacts/share \
    -H "Authorization: Bearer $GENUI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "template": "markdown",
      "title": "Quick Note",
      "content": {"text": "# Important Update\n\nHere is the information you requested."},
      "expiresIn": "24h"
    }'
  ```

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

  response = requests.post(
      "https://genui.sh/api/artifacts/share",
      headers={"Authorization": f"Bearer {os.environ['GENUI_API_KEY']}"},
      json={
          "template": "markdown",
          "title": "Quick Note",
          "content": {"text": "# Important Update\n\nHere is the information you requested."},
          "expiresIn": "24h"
      }
  )
  result = response.json()
  print(f"Share this URL: {result['url']}")
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://genui.sh/api/artifacts/share', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.GENUI_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      template: 'markdown',
      title: 'Quick Note',
      content: { text: '# Important Update\n\nHere is the information you requested.' },
      expiresIn: '24h'
    })
  });
  const { url } = await response.json();
  console.log(`Share this URL: ${url}`);
  ```

  ```go Go theme={null}
  payload := map[string]interface{}{
      "template":  "markdown",
      "title":     "Quick Note",
      "content":   map[string]string{"text": "# Important Update\n\nHere is the information you requested."},
      "expiresIn": "24h",
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("POST", "https://genui.sh/api/artifacts/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 result map[string]interface{}
  json.NewDecoder(resp.Body).Decode(&result)
  fmt.Printf("Share this URL: %s\n", result["url"])
  ```

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

  request = Net::HTTP::Post.new(uri)
  request['Authorization'] = "Bearer #{ENV['GENUI_API_KEY']}"
  request['Content-Type'] = 'application/json'
  request.body = {
    template: 'markdown',
    title: 'Quick Note',
    content: { text: '# Important Update\n\nHere is the information you requested.' },
    expiresIn: '24h'
  }.to_json

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

  ```rust Rust theme={null}
  let response = client
      .post("https://genui.sh/api/artifacts/share")
      .header("Authorization", format!("Bearer {}", api_key))
      .json(&json!({
          "template": "markdown",
          "title": "Quick Note",
          "content": {"text": "# Important Update\n\nHere is the information you requested."},
          "expiresIn": "24h"
      }))
      .send()
      .await?;

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

  ```csharp .NET theme={null}
  var response = await client.PostAsJsonAsync("https://genui.sh/api/artifacts/share", new {
      template = "markdown",
      title = "Quick Note",
      content = new { text = "# Important Update\n\nHere is the information you requested." },
      expiresIn = "24h"
  });
  var result = await response.Content.ReadFromJsonAsync<JsonElement>();
  Console.WriteLine($"Share this URL: {result.GetProperty("url")}");
  ```
</CodeGroup>

## Use Cases

This endpoint is ideal for:

* **AI agents** that need to share results immediately
* **Automation workflows** that generate and distribute content
* **One-off sharing** without needing to manage artifact IDs
* **Ephemeral content** that should auto-expire

## Comparison with Separate Calls

| Approach         | API Calls | Use Case                            |
| ---------------- | --------- | ----------------------------------- |
| Create + Share   | 2         | Need artifact ID for future updates |
| Create and Share | 1         | One-shot content sharing            |
