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

# Create a public sharing link

> Creates or returns a public share link for a saved content entity owned by the authenticated user. Use `public_link` for view access and `public_link_contribute` for collaborative access.



## OpenAPI

````yaml /api-reference/openapi.json post /ensure-shared-library-entry-link
openapi: 3.1.0
info:
  title: Memex REST API
  description: Memex REST API endpoints.
  version: '2026-03-10'
servers:
  - url: https://memex.garden/api
    description: Public edge router
  - url: https://rubctkzqxcdgkbbcprnu.supabase.co/functions/v1
    description: Direct Supabase Edge Functions
security:
  - bearerAuth: []
paths:
  /ensure-shared-library-entry-link:
    post:
      summary: Create a public sharing link
      description: >-
        Creates or returns a public share link for a saved content entity owned
        by the authenticated user. Use `public_link` for view access and
        `public_link_contribute` for collaborative access.
      operationId: ensureSharedLibraryEntryLink
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EnsureSharedLibraryEntryLinkRequest'
            examples:
              viewLink:
                summary: Create a view-only link
                value:
                  contentId: content_entity_id
                  accessMode: public_link
              collaborateLink:
                summary: Create a collaborative link
                value:
                  contentId: content_entity_id
                  accessMode: public_link_contribute
      responses:
        '200':
          description: Public sharing link
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SharedLibraryEntryLink'
        '401':
          description: Authentication required or invalid bearer token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '500':
          description: Unexpected server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
components:
  schemas:
    EnsureSharedLibraryEntryLinkRequest:
      type: object
      required:
        - contentId
        - accessMode
      properties:
        contentId:
          type: string
          description: Saved content entity ID to share.
        accessMode:
          $ref: '#/components/schemas/SharedLibraryEntryAccessMode'
        unsavedContent:
          type: object
          description: >-
            Optional unsaved content payload. If the content ID is not already
            saved, Memex can save this entity before creating the share link.
          required:
            - clientReferenceId
            - entity
          properties:
            clientReferenceId:
              type: string
            entity:
              type: object
              required:
                - type
              properties:
                type:
                  $ref: '#/components/schemas/ContentEntityType'
              additionalProperties: true
          additionalProperties: false
      additionalProperties: false
    SharedLibraryEntryLink:
      type: object
      required:
        - sharedResourceId
        - accessMode
        - contentId
        - contentType
        - createdAt
        - publicToken
      properties:
        sharedResourceId:
          type: string
        accessMode:
          $ref: '#/components/schemas/SharedLibraryEntryAccessMode'
        title:
          type: string
        description:
          type: string
        contentId:
          type: string
        contentType:
          $ref: '#/components/schemas/ContentEntityType'
        createdAt:
          type: string
          format: date-time
        publicToken:
          type: string
      additionalProperties: false
    UnauthorizedError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Unauthorized
      additionalProperties: true
    InternalServerError:
      type: object
      required:
        - error
        - message
      properties:
        error:
          type: string
          example: Internal server error
        message:
          type: string
      additionalProperties: true
    SharedLibraryEntryAccessMode:
      type: string
      enum:
        - public_link
        - public_link_contribute
      description: >-
        `public_link` grants view access. `public_link_contribute` grants
        collaborative access.
    ContentEntityType:
      type: string
      enum:
        - web
        - pdf
        - youtube
        - twitter
        - instagram
        - tiktok
        - facebook
        - linkedin
        - pinterest
        - reddit
        - chatgpt
        - claude
        - annotation
        - image
        - transcribedMedia
        - audioRecording
        - selector
        - chatThread
        - twitterProfile
        - subreddit
        - youtubeChannel
      description: Exact persisted `content_entity.type` value.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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