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

# Publish a text item to the library

> Publishes an existing project text item to the component library, turning it into a reusable library component.

The text item's current text, variables, variants, and other fields are carried over to the new component, and the text item becomes its first linked instance. The new component keeps the text item's existing developer ID. The text item must not already be a library instance.



## OpenAPI

````yaml openapi.json post /components/publish
openapi: 3.0.0
info:
  version: 1.0.0
  title: Ditto API
  description: Programmatically read and write data in your Ditto workspace.
servers:
  - url: https://api.dittowords.com/v2
security: []
paths:
  /components/publish:
    post:
      tags:
        - Components
      summary: Publish a text item to the library
      description: >-
        Publishes an existing project text item to the component library,
        turning it into a reusable library component.


        The text item's current text, variables, variants, and other fields are
        carried over to the new component, and the text item becomes its first
        linked instance. The new component keeps the text item's existing
        developer ID. The text item must not already be a library instance.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                textItemId:
                  type: string
                  description: >-
                    Developer ID of the text item to publish. It must not
                    already be a library instance.
                name:
                  type: string
                  description: The name of the new library component.
                folderId:
                  type: string
                  description: >-
                    The developer ID of the folder to add the component to. If
                    omitted, the component will be added to the library root.
              required:
                - textItemId
                - name
              example:
                textItemId: text-item-id-1
                name: New Component
                folderId: my-folder-id
      responses:
        '200':
          description: Returns the developer ID of the newly created library component
          content:
            application/json:
              schema:
                type: object
                properties:
                  developerId:
                    type: string
                    description: >-
                      Developer ID of the newly created library component. This
                      is the same developer ID the text item had before
                      publishing.
                required:
                  - developerId
                example:
                  developerId: text-item-id-1
        '400':
          description: >-
            Returned when the text item developer ID does not match any existing
            text item, the text item is already a library instance, or the
            folder ID does not exist
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message describing the validation failure
                required:
                  - message
              example:
                message: Text item with developer ID text-item-id-1 not found
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````