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

# Update Artifact

Update an existing artifact's title, description, content, or metadata.

## Request

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

<ParamField body="title" type="string">
  New display title
</ParamField>

<ParamField body="description" type="string">
  New description
</ParamField>

<ParamField body="content" type="object">
  Updated template-specific content object
</ParamField>

<ParamField body="metadata" type="object">
  Updated metadata (merged with existing)
</ParamField>

<ParamField body="expiresIn" type="string">
  New expiration duration from now
</ParamField>

<Note>
  You cannot change the template type of an existing artifact.
</Note>

## Response

Returns the updated artifact object.

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "art_abc123",
    "template": "markdown",
    "title": "Updated Title",
    "status": "active",
    "createdAt": "2024-01-15T12:00:00Z",
    "updatedAt": "2024-01-16T14:30:00Z"
  }
  ```

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

## Code Examples

<CodeGroup>
  ```bash curl theme={null}
  curl -X PUT https://genui.sh/api/artifacts/art_abc123 \
    -H "Authorization: Bearer $GENUI_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "title": "Updated Title",
      "content": {"text": "# Updated Content\n\nThis has been modified."}
    }'
  ```

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

  artifact_id = "art_abc123"
  response = requests.put(
      f"https://genui.sh/api/artifacts/{artifact_id}",
      headers={"Authorization": f"Bearer {os.environ['GENUI_API_KEY']}"},
      json={
          "title": "Updated Title",
          "content": {"text": "# Updated Content\n\nThis has been modified."}
      }
  )
  artifact = response.json()
  print(f"Updated at: {artifact['updatedAt']}")
  ```

  ```javascript JavaScript theme={null}
  const artifactId = 'art_abc123';
  const response = await fetch(`https://genui.sh/api/artifacts/${artifactId}`, {
    method: 'PUT',
    headers: {
      'Authorization': `Bearer ${process.env.GENUI_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      title: 'Updated Title',
      content: { text: '# Updated Content\n\nThis has been modified.' }
    })
  });
  const artifact = await response.json();
  console.log(`Updated at: ${artifact.updatedAt}`);
  ```

  ```go Go theme={null}
  artifactID := "art_abc123"
  payload := map[string]interface{}{
      "title":   "Updated Title",
      "content": map[string]string{"text": "# Updated Content\n\nThis has been modified."},
  }
  body, _ := json.Marshal(payload)

  req, _ := http.NewRequest("PUT", "https://genui.sh/api/artifacts/"+artifactID, 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()
  ```

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

  request = Net::HTTP::Put.new(uri)
  request['Authorization'] = "Bearer #{ENV['GENUI_API_KEY']}"
  request['Content-Type'] = 'application/json'
  request.body = {
    title: 'Updated Title',
    content: { text: '# Updated Content\n\nThis has been modified.' }
  }.to_json

  response = http.request(request)
  ```

  ```rust Rust theme={null}
  let artifact_id = "art_abc123";
  let response = client
      .put(format!("https://genui.sh/api/artifacts/{}", artifact_id))
      .header("Authorization", format!("Bearer {}", api_key))
      .json(&json!({
          "title": "Updated Title",
          "content": {"text": "# Updated Content\n\nThis has been modified."}
      }))
      .send()
      .await?;
  ```

  ```csharp .NET theme={null}
  var artifactId = "art_abc123";
  var response = await client.PutAsJsonAsync($"https://genui.sh/api/artifacts/{artifactId}", new {
      title = "Updated Title",
      content = new { text = "# Updated Content\n\nThis has been modified." }
  });
  ```
</CodeGroup>
