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

# Create Share Link

> Creates the chat's public share link. Anyone with the URL can read
the conversation without authentication. Each chat has at most one
active link.

When an active link already exists and `regenerate` isn't set, the
existing link is returned with `200` instead of an error. Pass
`?regenerate=true` to revoke the current link and mint a new URL.




## OpenAPI

````yaml /openapi.yaml post /v1/chats/{id}/share
openapi: 3.0.3
info:
  title: Chief Public API
  version: 1.0.0
  contact:
    name: Chief Support
    url: https://chief.bot
  description: |
    Chief's public REST API for programmatic access to chats and assets.

    All endpoints are authenticated with a Personal Access Token (PAT)
    sent in the `X-API-Key` header. PATs are minted out-of-band from the
    Chief settings UI.

    All endpoints that touch project-scoped resources require the
    `X-Project-Id` header. Missing or invalid project IDs respond with HTTP
    400 and the error code `publicapi.tenancy.project.missing`.

    ## Error envelope

    Every error response uses the same JSON envelope:

    ```json
    { "code": "publicapi.auth.invalid",
      "humane": "The provided API key is invalid or has been revoked.",
      "statusCode": 401 }
    ```

    `code` is a stable, dotted, lowercase identifier suitable for client-side
    i18n and analytics. `humane` is plain English safe to surface to end
    users. `statusCode` mirrors the HTTP status.

    ## Chat workflow — kickoff + poll

    Chats are asynchronous in v1. Callers need to poll the
    per-message endpoint until the content they need is present.

    1. `POST /v1/chats` with `{prompt}`. The server kicks off the
       workflow and returns `{chat_id, message_id, created_at}`
       immediately. `message_id` is the message you'll poll.
    2. `POST /v1/chats/{chat_id}/messages` with `{prompt}` to
       continue an existing chat — appends a new turn and returns
       `{message_id, created_at}`.
    3. `GET /v1/chats/{chat_id}/messages/{message_id}` to read the
       message. While the workflow is still writing, `prompt` and
       `response` are omitted; once written they're present. Treat the
       appearance of `response` as the signal that the assistant has
       produced output.
    4. `GET /v1/chats/{chat_id}` returns chat-level metadata only
       (`modified_at`). It does not carry messages.
    5. `GET /v1/chats/{chat_id}/messages` lists every message's id +
       `created_at` (no content); clients fetch one message at a time via
       `GET /v1/chats/{chat_id}/messages/{mid}` for the prompt + response
       body.

    ## Asset workflow — three-step upload

    Assets are uploaded directly to blob storage via a signed URL. The flow
    is:

    1. `POST /v1/assets` with `{filename, mime_type}`, optionally including
       the hex-encoded `md5` of the file. When `md5` matches content already
       in the project the server returns `200` with `already_exists: true` and
       no upload URL — skip to fetching the asset. Otherwise it returns `201`
       with `{asset_id, upload_url, upload_method:"PUT", upload_headers,
       expires_at}`.
    2. `PUT` the file bytes to `upload_url`, applying every header in
       `upload_headers` verbatim. The URL is valid until `expires_at`.
    3. `POST /v1/assets/{asset_id}/complete` with an empty body to
       hand the asset off to the ingest pipeline. The server reads the
       uploaded object's size and MD5 from blob storage at this step. The
       response carries the current `AssetResponse`; clients poll until
       `status` is `ready` or `failed`.
servers:
  - url: '{baseUrl}'
    description: Chief
    variables:
      baseUrl:
        default: https://api.storytell.ai
        description: Base URL of the deployment serving the API.
security:
  - apiKey: []
tags:
  - name: Chats
    description: Public chat lifecycle — kickoff, list, fetch.
  - name: Assets
    description: Public asset upload + ingest lifecycle.
  - name: Labels
    description: Public label CRUD and asset-label attachment.
  - name: Actions
    description: Public action CRUD plus enable/disable.
  - name: Sessions
    description: Public recording-session listing and CRUD.
  - name: Skills
    description: Public skill CRUD plus enable/disable.
  - name: Memories
    description: Public memory CRUD.
  - name: Projects
    description: Public project create/edit, membership, and invitations.
paths:
  /v1/chats/{id}/share:
    post:
      tags:
        - Chats
      summary: Create Share Link
      description: |
        Creates the chat's public share link. Anyone with the URL can read
        the conversation without authentication. Each chat has at most one
        active link.

        When an active link already exists and `regenerate` isn't set, the
        existing link is returned with `200` instead of an error. Pass
        `?regenerate=true` to revoke the current link and mint a new URL.
      operationId: createShareLink
      parameters:
        - $ref: '#/components/parameters/XProjectId'
        - in: path
          name: id
          required: true
          schema:
            type: string
            pattern: ^chat_[a-z0-9]{20}$
          example: chat_d8aad64dib2c7m3ae7j0
          description: Chat identifier.
        - in: query
          name: regenerate
          required: false
          schema:
            type: boolean
            default: false
          description: |
            When `true`, revokes any existing link and mints a new URL.
      responses:
        '200':
          description: An active share link already existed; returned unchanged.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShareLinkResponse'
        '201':
          description: Share link created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ShareLinkResponse'
              example:
                is_shared: true
                url: https://chief.bot/shared/chat/3f9c2e7a1b...
                created_at: '2026-05-23T10:15:30Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - apiKey: []
components:
  parameters:
    XProjectId:
      in: header
      name: X-Project-Id
      required: true
      schema:
        type: string
        pattern: ^project_[a-z0-9]{20}$
      example: project_d8a4td4dib27i4beefb0
      description: |
        Project identifier scoping the request. Required on every
        project-scoped public endpoint. Missing or malformed values respond
        with HTTP 400 and code `publicapi.tenancy.project.missing`.
  schemas:
    ShareLinkResponse:
      type: object
      required:
        - is_shared
      properties:
        is_shared:
          type: boolean
        url:
          type: string
          format: uri
          description: |
            Public URL of the shared conversation. Anyone with this URL can
            read the chat without authentication. Omitted when not shared.
        created_at:
          type: string
          format: date-time
          description: When the active link was created. Omitted when not shared.
    Error:
      type: object
      required:
        - code
        - statusCode
      properties:
        code:
          type: string
          pattern: ^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+$
          description: |
            Stable dotted, lowercase identifier, namespaced by domain and
            operation (`<domain>.<op>.<reason>`). Suitable for client-side
            i18n keys and analytics. Codes are additive; existing codes are
            never reworded.
          example: publicapi.auth.invalid
        humane:
          type: string
          description: Plain-English message safe to display to end users.
          example: The provided API key is invalid or has been revoked.
        statusCode:
          type: integer
          minimum: 400
          maximum: 599
          description: |
            Mirror of the HTTP status code. (Field name is camelCase here
            only — owned by `nutils.Error` across the platform.)
          example: 401
  responses:
    BadRequest:
      description: Malformed request, validation failure, or missing tenancy header.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            missingProject:
              summary: Missing X-Project-Id
              value:
                code: publicapi.tenancy.project.missing
                humane: X-Project-Id header is required.
                statusCode: 400
    Unauthorized:
      description: Missing, malformed, or revoked credentials.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: publicapi.auth.invalid
            humane: The provided API key is invalid or has been revoked.
            statusCode: 401
    NotFound:
      description: Resource does not exist or is outside the caller's reach.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: |
        Personal Access Token, sent verbatim as `pat_<32 chars>`. PATs are
        minted from the Chief settings UI.

````