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

# Publish a tool's draft

> Make your team's draft of a tool's code live, as the tool's newest version.

<Accordion title="Details">
  * Business accounts only, with tools:build. Pomerado doesn't check the draft's code, so only an Owner or Admin signed in to the Dashboard publishes it, never an API key or an agent.

  * Send the digest of the draft you saw. It publishes once a run of the draft passed on the live version, for free, and the draft is then gone.

  * The draft's files replace the live version's, a repair's included, with the inputs and outputs its run read. A public tool's code is read only, so publishing its draft is forbidden.

  * **Callers:** an API key, an MCP OAuth token or a Dashboard session.

  * **Permission:** `tools:build`.

  * **Effect:** Creates or changes something.

  * **Errors:** [`business_account_required`](/errors#business_account_required), [`not_found`](/errors#not_found), [`draft_changed`](/errors#draft_changed), [`draft_not_run`](/errors#draft_not_run), [`draft_not_publishable`](/errors#draft_not_publishable), and the [errors any request can get](/errors).
</Accordion>


## OpenAPI

````yaml /api-reference/openapi.json post /v1/code/{id}/draft/publish
openapi: 3.1.0
info:
  title: Pomerado API
  version: '1'
  description: >-
    Run and build website tools, follow their jobs, and manage logins, API keys
    and webhooks. Authenticate with a Pomerado API key (pom_…), an MCP OAuth
    token or a Dashboard session as a Bearer token.
servers:
  - url: https://api.pomerado.ai
security: []
tags:
  - name: account
    x-group: Account
  - name: api_keys
    x-group: API keys
  - name: connected_apps
    x-group: Connected apps
  - name: usage
    x-group: Usage
  - name: quota
    x-group: Quota
  - name: billing
    x-group: Billing
  - name: integrations
    x-group: Integrations
  - name: connect
    x-group: Connect
  - name: code
    x-group: Code
  - name: logins
    x-group: Saved logins
  - name: two_factor
    x-group: 2FA
  - name: login_access
    x-group: Login access
  - name: tools
    x-group: Tools
  - name: webhooks
    x-group: Webhooks
  - name: runs
    x-group: Runs
  - name: builds
    x-group: Builds
  - name: jobs
    x-group: Jobs
  - name: files
    x-group: Files
  - name: team
    x-group: Team
paths:
  /v1/code/{id}/draft/publish:
    post:
      tags:
        - code
      summary: Publish a tool's draft
      description: >-
        Make your team's draft of a tool's code live, as the tool's newest
        version.
      operationId: code.publish_draft
      parameters:
        - name: id
          in: path
          required: true
          description: 'a tool ID: tool_ and 32 lowercase hex digits'
          schema:
            type: string
            examples:
              - tool_0f8e2d1c4b3a49e8a7f6e5d4c3b2a190
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - digest
              properties:
                digest:
                  type: string
                  description: The draft's digest, as code.get answered it
                  pattern: ^[0-9a-f]{64}$
              additionalProperties: false
      responses:
        '200':
          description: The tool's code, with the draft live
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodeBundle'
        '400':
          description: invalid_request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: unauthorized, reauthentication_required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: business_account_required, forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: not_found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: draft_changed, draft_not_run, draft_not_publishable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '413':
          description: request_too_large
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: internal_error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '503':
          description: temporarily_unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - bearer: []
components:
  schemas:
    CodeBundle:
      type: object
      required:
        - integration
        - tool
        - versions
        - files
        - draft
      properties:
        integration:
          $ref: '#/components/schemas/CodeIntegration'
        tool:
          $ref: '#/components/schemas/CodeTool'
        versions:
          type: array
          items:
            $ref: '#/components/schemas/CodeVersion'
          description: The tool's versions, newest first, at most 100
        files:
          type: array
          items:
            $ref: '#/components/schemas/CodeFile'
          description: The live version's files, by path
        draft:
          anyOf:
            - $ref: '#/components/schemas/CodeDraft'
            - type: 'null'
          description: >-
            Your team's draft of the tool, shared by every member, or null when
            it has none
      additionalProperties: false
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - retryable
            - docs_url
          properties:
            code:
              type: string
            message:
              type: string
            retryable:
              type: boolean
            docs_url:
              type: string
            details:
              type: object
              required: []
              properties: {}
              additionalProperties:
                $id: /schemas/unknown
          additionalProperties: false
      additionalProperties: false
    CodeIntegration:
      type: object
      required:
        - id
        - name
        - site_url
        - visibility
        - tools
      properties:
        id:
          $ref: '#/components/schemas/integration_id'
        name:
          type: string
        site_url:
          anyOf:
            - type: string
            - type: 'null'
          description: The website's https origin, or null for an offline tool
        visibility:
          type: string
          enum:
            - public
            - private
          description: >-
            public: published on Pomerado for every account to find and use.
            private: only your team sees, uses and edits it
        tools:
          type: array
          items:
            $ref: '#/components/schemas/CodeTool'
          description: The tools your team created in it
      additionalProperties: false
    CodeTool:
      type: object
      required:
        - id
        - name
        - effect
        - live_version
        - draft_changed_files
        - login_required
        - http_version
      properties:
        id:
          $ref: '#/components/schemas/tool_id'
        name:
          type: string
        effect:
          type: string
          enum:
            - read
            - write
        live_version:
          type: object
          required:
            - number
            - published_at
            - change
            - requested_by
            - restored_from
            - restorable
          properties:
            number:
              type: integer
              description: >-
                The version's number: 1 for the tool's first code, one more for
                each later version
            published_at:
              $ref: '#/components/schemas/Date'
            change:
              type: string
              enum:
                - build
                - repair
                - change
                - update
                - edit
                - restore
              description: >-
                What made this version: build (Pomerado built the tool), repair
                (Pomerado repaired it after a run failed), change (someone asked
                for a change), update (Pomerado updated it), edit (a team member
                edited its code) or restore (a team member restored an earlier
                version as this one)
            requested_by:
              anyOf:
                - $ref: '#/components/schemas/CodeMember'
                - type: 'null'
              description: >-
                The team member who started the build, asked for the change, or
                published the edit or restore; null for a repair or an update,
                and for someone outside your team
            restored_from:
              anyOf:
                - $ref: '#/components/schemas/Int'
                - type: 'null'
              description: >-
                For a restore, the number of the version it restored; otherwise
                null
            restorable:
              type: boolean
              description: >-
                Whether code.restore can make this version live again: false for
                a version published before Pomerado kept a record of each
                version, and for one taken down
          additionalProperties: false
          description: The version callers run now
        draft_changed_files:
          type: integer
          description: >-
            How many files your team's draft of the tool changes; 0 when it has
            none
        login_required:
          type: boolean
          description: Whether the tool signs in to its website
        http_version:
          type: boolean
          description: >-
            Whether the live version has an HTTP version, which code.run runs
            with implementation http
      additionalProperties: false
    CodeVersion:
      type: object
      required:
        - number
        - published_at
        - change
        - requested_by
        - restored_from
        - restorable
      properties:
        number:
          type: integer
          description: >-
            The version's number: 1 for the tool's first code, one more for each
            later version
        published_at:
          $ref: '#/components/schemas/Date'
        change:
          type: string
          enum:
            - build
            - repair
            - change
            - update
            - edit
            - restore
          description: >-
            What made this version: build (Pomerado built the tool), repair
            (Pomerado repaired it after a run failed), change (someone asked for
            a change), update (Pomerado updated it), edit (a team member edited
            its code) or restore (a team member restored an earlier version as
            this one)
        requested_by:
          anyOf:
            - $ref: '#/components/schemas/CodeMember'
            - type: 'null'
          description: >-
            The team member who started the build, asked for the change, or
            published the edit or restore; null for a repair or an update, and
            for someone outside your team
        restored_from:
          anyOf:
            - $ref: '#/components/schemas/Int'
            - type: 'null'
          description: For a restore, the number of the version it restored; otherwise null
        restorable:
          type: boolean
          description: >-
            Whether code.restore can make this version live again: false for a
            version published before Pomerado kept a record of each version, and
            for one taken down
      additionalProperties: false
    CodeFile:
      type: object
      required:
        - path
        - source
        - bytes
        - content
      properties:
        path:
          type: string
          description: The file's path, such as src/tool.mjs
        source:
          type: string
          enum:
            - team
            - pomerado
          description: >-
            team: written for your tool by its build. pomerado: added by
            Pomerado to run it, such as operation.mjs and the sign-in recipe
            auth-fill.json
        bytes:
          type: integer
          description: The file's size in bytes
        content:
          type: string
          description: The file's text
      additionalProperties: false
    CodeDraft:
      type: object
      required:
        - base_version
        - digest
        - changed
        - updated_at
        - updated_by
        - passed_at
        - files
        - base_files
      properties:
        base_version:
          type: integer
          description: >-
            The version the draft started from: the live one when its first file
            was saved
        digest:
          type: string
          description: The SHA-256 of the whole file set the draft makes, in hex
        changed:
          type: array
          items:
            type: string
          description: >-
            The paths of the files the draft changes from its base version,
            sorted
        updated_at:
          $ref: '#/components/schemas/Date'
        updated_by:
          anyOf:
            - $ref: '#/components/schemas/CodeMember'
            - type: 'null'
          description: The member who saved last; null for someone no longer on your team
        passed_at:
          anyOf:
            - $ref: '#/components/schemas/Date'
            - type: 'null'
          description: When a run of the draft as it is now passed; null until one does
        files:
          type: array
          items:
            $ref: '#/components/schemas/CodeDraftFile'
          description: The changed files, by path
        base_files:
          anyOf:
            - type: array
              items:
                $ref: '#/components/schemas/CodeBaseFile'
            - type: 'null'
          description: >-
            Your team's files whose text in the base version isn't the live
            version's, by path: empty while the base version is live and for a
            public tool, whose code is read only, and null when, with the live
            files and the changed ones, they'd take more than 4 MiB of the
            answer's JSON
      additionalProperties: false
    integration_id:
      type: string
      description: 'an integration ID: int_ and 32 lowercase hex digits'
      examples:
        - int_0f8e2d1c4b3a49e8a7f6e5d4c3b2a190
    tool_id:
      type: string
      description: 'a tool ID: tool_ and 32 lowercase hex digits'
      examples:
        - tool_0f8e2d1c4b3a49e8a7f6e5d4c3b2a190
    Date:
      type: string
      description: a string to be decoded into a Date
    CodeMember:
      type: object
      required:
        - user_id
        - name
        - email
      properties:
        user_id:
          type: string
          description: The member's user ID
        name:
          anyOf:
            - type: string
            - type: 'null'
          description: The member's name, or null when they gave none
        email:
          type: string
          description: The member's sign-in email
      additionalProperties: false
    Int:
      type: integer
      description: an integer
    CodeDraftFile:
      type: object
      required:
        - path
        - content
      properties:
        path:
          type: string
          description: The file's path, such as src/tool.mjs
        content:
          anyOf:
            - type: string
            - type: 'null'
          description: The file's text in the draft, or null when the draft deletes it
      additionalProperties: false
    CodeBaseFile:
      type: object
      required:
        - path
        - content
      properties:
        path:
          type: string
          description: The file's path, such as src/tool.mjs
        content:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            The file's text in the base version, or null when the base version
            doesn't have it
      additionalProperties: false
  securitySchemes:
    bearer:
      type: http
      scheme: bearer

````

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