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

# Edit a community template draft

> **Token scope:** `account` · `org` — read-only tokens refused (not a GET).



## OpenAPI

````yaml /openapi/org.json patch /orgs/{orgId}/templates/{code}
openapi: 3.1.0
info:
  title: InstaCloud API — Organization level
  version: 0.1.0
  description: >-
    Endpoints under `/orgs/{orgId}`: members, projects, billing, domains.
    Callable with an account-wide token or a token bound to that organization.


    Generated from the platform's own OpenAPI document
    (https://api.instacloud.com/openapi.json); see the [API
    overview](/reference/api/overview) for authentication and token scopes.
servers:
  - url: https://api.instacloud.com
    description: InstaCloud
security:
  - bearerAuth: []
tags:
  - name: Organization
    description: 'The organization itself: name, members, invitations.'
  - name: Projects
    description: Projects inside an organization.
  - name: Audit
    description: The project's event timeline, including agent-ingested events.
  - name: Domains
    description: >-
      Domains bought through InstaCloud, bring-your-own zones and their DNS
      records.
  - name: Billing
    description: Usage, cycles, invoices and credits.
  - name: Templates
    description: Deploy a template into a project.
paths:
  /orgs/{orgId}/templates/{code}:
    patch:
      tags:
        - Templates
      summary: Edit a community template draft
      description: >-
        **Token scope:** `account` · `org` — read-only tokens refused (not a
        GET).
      operationId: updateOrgTemplate
      parameters:
        - schema:
            format: uuid
            type: string
          in: path
          name: orgId
          required: true
        - schema:
            type: string
          in: path
          name: code
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                code:
                  description: Rename. Only before the first publish.
                  type: string
                name:
                  minLength: 1
                  maxLength: 80
                  type: string
                tagline:
                  maxLength: 160
                  type:
                    - string
                    - 'null'
                category:
                  type:
                    - string
                    - 'null'
                readme:
                  type:
                    - string
                    - 'null'
                logoUrl:
                  description: >-
                    An https:// image link. The link and its percent-encoded
                    form are each at most 2048 characters. null clears it.
                  type:
                    - string
                    - 'null'
                variables:
                  maxItems: 600
                  description: >-
                    Only the variables that changed, at most 600, the cap a
                    project apply has. A name deleted in this PATCH can be added
                    again only in a later PATCH. One invalid entry answers 400
                    and nothing is saved.
                  type: array
                  items:
                    type: object
                    properties:
                      service:
                        type: string
                      name:
                        description: >-
                          The generator's name for the variable: the view's
                          originalName when it is renamed, else its name. On an
                          add, the new variable's name.
                        type: string
                      choice:
                        description: >-
                          null clears the choice, back to what the generator
                          chose. Omitted leaves the choice as it is.
                        anyOf:
                          - $ref: '#/components/schemas/TemplateVariableChoice'
                          - type:
                              - object
                              - 'null'
                            enum:
                              - null
                              - null
                      newName:
                        description: >-
                          Renames the variable: ^[A-Z][A-Z0-9_]{0,63}$, and no
                          other variable of the service may have that name. null
                          clears the rename. Omitted leaves the name as it is.
                        type:
                          - string
                          - 'null'
                      add:
                        type: boolean
                        enum:
                          - true
                        description: >-
                          Adds a required variable called name to a web service
                          or worker: ^[A-Z][A-Z0-9_]{0,63}$, a name no variable
                          of the service has or shows, at most 200 variables per
                          service and 1000 per template. The entry carries
                          nothing else. A choice for it rides in its own entry,
                          and adds run before every other entry.
                      delete:
                        type: boolean
                        enum:
                          - true
                        description: >-
                          Deletes a variable the author added, with its choice
                          and rename. One from the project answers 400: remove
                          it with choice removed. The entry carries nothing
                          else, and deletes run after every other entry.
                    required:
                      - service
                      - name
                services:
                  maxItems: 100
                  description: >-
                    Only the services that changed, at most 100. An add or a
                    delete entry carries nothing else. Service adds run first
                    and deletes run after every other entry. A template holds at
                    most 50 services. A name deleted in this PATCH can be added
                    again only in a later PATCH. One invalid entry answers 400
                    and nothing is saved.
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        description: >-
                          The service. On an add, the new service name:
                          lower-kebab, at most 39 characters, a name no service
                          of the template has.
                        type: string
                      removed:
                        description: >-
                          true leaves the service out of the published template,
                          false restores it. Omitted leaves it as it is. A
                          service the author added is deleted instead, and true
                          on one answers 400.
                        type: boolean
                      settings:
                        description: >-
                          Only the fields that changed: each replaces that
                          field. null clears every setting of the service.
                          Postgres takes only pgVersion and storage only public.
                          Redis, MySQL and MongoDB answer 400, and so does a
                          field the service type does not take.
                        anyOf:
                          - $ref: '#/components/schemas/TemplateServiceSettings'
                          - type:
                              - object
                              - 'null'
                            enum:
                              - null
                              - null
                      add:
                        $ref: '#/components/schemas/TemplateAddedService'
                      delete:
                        type: boolean
                        enum:
                          - true
                        description: >-
                          Deletes a service the author added, with every
                          setting, choice, rename and added variable kept under
                          its name. One from the project answers 400: remove it
                          with removed true. The entry carries nothing else, and
                          deletes run after every other entry.
                    required:
                      - name
                expectedUpdatedAt:
                  format: date-time
                  description: >-
                    The draft's updatedAt as the client rendered it. A different
                    current value answers 409 template_draft_changed.
                  type: string
              required:
                - expectedUpdatedAt
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  template:
                    $ref: '#/components/schemas/CommunityTemplate'
                required:
                  - template
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Default Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: >-
            code template_draft_changed: the draft changed since the client read
            it (expectedUpdatedAt), review it and save again. Without a code:
            the new code is taken, or the template was already published and
            keeps its code.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CodedError'
        '429':
          description: This user saved too many times in the last minute. Retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    TemplateVariableChoice:
      description: >-
        The author's choice for one variable: required, optional with or without
        a default, a reference, a random 32-character secret, or left out.
      anyOf:
        - type: object
          properties:
            kind:
              type: string
              enum:
                - required
            description:
              description: At most 200 characters. Blank keeps the default sentence.
              type: string
          required:
            - kind
        - type: object
          properties:
            kind:
              type: string
              enum:
                - optional
            default:
              description: >-
                At most 4096 bytes. Published with the template, so never a
                secret.
              type: string
            description:
              type: string
          required:
            - kind
        - type: object
          properties:
            kind:
              type: string
              enum:
                - reference
            token:
              description: >-
                One of the view referenceOptions tokens, or a key of a service
                removed from the template: that variable stays required until
                the service is restored.
              type: string
          required:
            - kind
            - token
        - type: object
          properties:
            kind:
              type: string
              enum:
                - generated
          required:
            - kind
        - type: object
          properties:
            kind:
              type: string
              enum:
                - removed
          required:
            - kind
    TemplateServiceSettings:
      description: >-
        What the author changed on one service. CommunityTemplate.editableFields
        lists the keys each service type takes, and a PATCH answers 400 for any
        other. A field left out keeps the generator's value.
      type: object
      properties:
        public:
          description: >-
            Storage only: serve the bucket with anonymous public-read. false
            makes it private again.
          type: boolean
        image:
          description: An image reference, published as typed (not pinned to a digest).
          type: string
        port:
          description: >-
            1 to 65535. null: no port, so the service runs as a worker, with no
            health check and always on.
          type:
            - integer
            - 'null'
        alwaysOn:
          description: >-
            false: the service scales to zero when idle. A worker is always on
            whatever this says.
          type: boolean
        mountPath:
          description: >-
            Where a volume mounts, a path starting with /. null, or an empty or
            blank string: no volume.
          type:
            - string
            - 'null'
        pgVersion:
          description: >-
            Postgres only: the major a deploy creates the database on, one of
            16, 17, 18.
          type: integer
        healthcheck:
          description: 'A path starting with /. null, or an empty or blank string: none.'
          type:
            - string
            - 'null'
        command:
          description: >-
            Run through sh -c. null, or an empty or blank string: the image's
            own.
          type:
            - string
            - 'null'
    TemplateAddedService:
      description: >-
        A service the author adds to a template: a compute service from an
        image, web with a port and a worker without one, or a managed database
        or bucket by type.
      anyOf:
        - type: object
          properties:
            type:
              type: string
              enum:
                - compute
            image:
              description: >-
                A public image reference, published as typed. The Image setting
                checks it.
              type: string
            port:
              description: '1 to 65535. null: a worker, always on, with no health check.'
              type:
                - integer
                - 'null'
          required:
            - type
            - image
            - port
        - type: object
          properties:
            type:
              type: string
              enum:
                - postgres
                - redis
                - mysql
                - mongodb
                - storage
          required:
            - type
    CommunityTemplate:
      type: object
      properties:
        id:
          format: uuid
          description: >-
            The draft's stable id. A rename of its code keeps it, and a new
            draft gets a new one, even under a code a deleted draft had. Routes
            and editor links address a draft by its code.
          type: string
        code:
          type: string
        orgId:
          format: uuid
          type: string
        sourceProjectId:
          format: uuid
          type:
            - string
            - 'null'
        blank:
          description: >-
            Created with POST /orgs/{orgId}/templates, with no project behind
            it: every service is one the author added, and Regenerate From
            Project answers 400. A generated draft whose project was deleted is
            not blank.
          type: boolean
        status:
          type: string
          enum:
            - draft
            - published
            - unpublished
        publishedVersion:
          type:
            - string
            - 'null'
        hasUnpublishedChanges:
          type: boolean
        name:
          type: string
        tagline:
          type:
            - string
            - 'null'
        category:
          type:
            - string
            - 'null'
        readme:
          type:
            - string
            - 'null'
        defaultReadme:
          description: >-
            A README skeleton built from the draft as it is now: service names
            and required variable names only, never a value. The console offers
            it behind a button; it is not stored.
          type: string
        logoUrl:
          type:
            - string
            - 'null'
        services:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              type:
                description: >-
                  web with a port, worker without one, or the managed type
                  (postgres, redis, mysql, mongodb or storage). It and the
                  fields below are the values after the author's settings.
                type: string
              image:
                type:
                  - string
                  - 'null'
              port:
                type:
                  - integer
                  - 'null'
              healthcheck:
                type:
                  - string
                  - 'null'
              volume:
                type: boolean
              mountPath:
                description: >-
                  null with volume true: the volume mounts at the default /data.
                  null with volume false: no volume.
                type:
                  - string
                  - 'null'
              command:
                type:
                  - string
                  - 'null'
              alwaysOn:
                type:
                  - boolean
                  - 'null'
              public:
                description: >-
                  Storage only, always present on a bucket: anonymous
                  public-read, after the author's setting.
                type: boolean
              pgVersion:
                description: >-
                  Postgres only: the major a deploy creates the database on,
                  after the author's setting. Absent when the project's database
                  recorded none.
                type: integer
              added:
                description: >-
                  Present, and true, only on a service the author added: a PATCH
                  deletes it for good. One from the project is removed instead.
                type: boolean
              removed:
                description: >-
                  The author left this service out of the template. It stays
                  listed so it can be restored.
                type: boolean
              variables:
                description: >-
                  Sorted by the generator's name (originalName when renamed).
                  Empty for a managed database. A removed service lists what
                  restoring it brings back.
                type: array
                items:
                  $ref: '#/components/schemas/TemplateVariableView'
            required:
              - name
              - type
              - image
              - port
              - healthcheck
              - volume
              - mountPath
              - command
              - alwaysOn
              - removed
              - variables
        referenceOptions:
          description: >-
            What a variable may reference in the template as it is now. A
            removed service offers nothing.
          type: array
          items:
            $ref: '#/components/schemas/TemplateReferenceOption'
        editableFields:
          $ref: '#/components/schemas/TemplateEditableFields'
        referenceKeys:
          $ref: '#/components/schemas/TemplateReferenceKeys'
        publishRequirements:
          description: >-
            Always seven, in this order: has_service, no_blocked, no_conflicts,
            has_tagline, has_category, has_readme, required_descriptions.
          type: array
          items:
            $ref: '#/components/schemas/TemplatePublishRequirement'
        report:
          $ref: '#/components/schemas/TemplateGenerationReport'
        updatedAt:
          type: string
        takenDown:
          description: Staff took this template down. It cannot be republished.
          type: boolean
        deployCount:
          description: Succeeded deployments of this template.
          type: integer
        totalProjects:
          description: >-
            Distinct projects that deployed this template since its first
            publish, any outcome: the number the gallery card shows (the
            catalog's totalProjects).
          type: integer
      required:
        - id
        - code
        - orgId
        - sourceProjectId
        - blank
        - status
        - publishedVersion
        - hasUnpublishedChanges
        - name
        - tagline
        - category
        - readme
        - defaultReadme
        - logoUrl
        - services
        - referenceOptions
        - editableFields
        - referenceKeys
        - publishRequirements
        - report
        - updatedAt
        - takenDown
        - deployCount
        - totalProjects
    Error:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    CodedError:
      type: object
      properties:
        error:
          type: string
        code:
          description: >-
            stable machine-readable reason, e.g. private_lane_disabled,
            private_lane_unavailable_in_region, public_access_closed,
            credential_change_in_progress
          type: string
      required:
        - error
    TemplateVariableView:
      description: One variable of a template service as its author sees it.
      type: object
      properties:
        name:
          type: string
        kind:
          type: string
          enum:
            - required
            - optional
            - default
            - reference
            - generated
            - fixed
            - removed
        value:
          description: >-
            default: the default text. reference: the token. fixed: the literal
            or the address reference.
          type: string
        description:
          description: >-
            What whoever deploys reads. Omitted while it is the default
            sentence, which the console shows as an empty box.
          type: string
        brokenReference:
          description: >-
            The token this variable referenced before its service was removed
            from the template or left the project. The variable is then
            required.
          type: string
        originalName:
          description: >-
            Present only when the author renamed the variable: the generator's
            name, which a PATCH variables entry sends as name. name is then the
            new one.
          type: string
        added:
          description: >-
            Present, and true, only on a variable the author added: a PATCH
            deletes it for good. One from the project is removed with choice
            removed instead.
          type: boolean
      required:
        - name
        - kind
    TemplateReferenceOption:
      description: >-
        What a variable may reference: a database connection key, a bucket key,
        or a web service address including the service itself.
      type: object
      properties:
        token:
          description: Exactly what a reference choice sends and the manifest stores.
          type: string
        service:
          type: string
        key:
          description: >-
            A credential key of a managed database or a storage bucket, or url
            or host of a web service.
          type: string
      required:
        - token
        - service
        - key
    TemplateEditableFields:
      description: >-
        Per service type, the TemplateServiceSettings keys a template service of
        that type takes. A PATCH answers 400 for any other.
      type: object
      properties:
        web:
          type: array
          items:
            type: string
            enum:
              - image
              - port
              - healthcheck
              - command
              - mountPath
              - alwaysOn
        worker:
          type: array
          items:
            type: string
            enum:
              - image
              - port
              - healthcheck
              - command
              - mountPath
              - alwaysOn
        postgres:
          type: array
          items:
            type: string
            enum:
              - pgVersion
        redis:
          maxItems: 0
          type: array
          items:
            type: string
        mysql:
          maxItems: 0
          type: array
          items:
            type: string
        mongodb:
          maxItems: 0
          type: array
          items:
            type: string
        storage:
          type: array
          items:
            type: string
            enum:
              - public
      required:
        - web
        - worker
        - postgres
        - redis
        - mysql
        - mongodb
        - storage
    TemplateReferenceKeys:
      description: >-
        Per managed service type, the credential keys a variable may reference
        on a service of that type, one the author has not applied yet included
        (secretNames.ts CANONICAL_KEYS). A web service's url and host are not
        listed.
      type: object
      properties:
        postgres:
          type: array
          items:
            type: string
        redis:
          type: array
          items:
            type: string
        mysql:
          type: array
          items:
            type: string
        mongodb:
          type: array
          items:
            type: string
        storage:
          type: array
          items:
            type: string
      required:
        - postgres
        - redis
        - mysql
        - mongodb
        - storage
    TemplatePublishRequirement:
      description: >-
        One condition publish checks. Publish answers 400 template_not_ready
        while any is not ok.
      type: object
      properties:
        code:
          type: string
          enum:
            - has_service
            - no_blocked
            - no_conflicts
            - has_tagline
            - has_category
            - has_readme
            - required_descriptions
        ok:
          type: boolean
        items:
          description: >-
            no_blocked: each blocked reason. no_conflicts: one sentence with its
            fix for each name the author added that the project now has too,
            services first. required_descriptions: each <service>.<VAR> still
            without a description. Otherwise empty.
          type: array
          items:
            type: string
      required:
        - code
        - ok
        - items
    TemplateGenerationReport:
      description: >-
        What generation skipped, what blocks publishing (each with a fix), and
        notices.
      type: object
      properties:
        skipped:
          type: array
          items:
            type: object
            properties:
              service:
                type: string
              variable:
                type: string
              reason:
                type: string
              fix:
                type: string
            required:
              - reason
        blocked:
          type: array
          items:
            type: object
            properties:
              service:
                type: string
              variable:
                type: string
              reason:
                type: string
              fix:
                type: string
            required:
              - reason
        notices:
          type: array
          items:
            type: object
            properties:
              service:
                type: string
              variable:
                type: string
              reason:
                type: string
              fix:
                type: string
            required:
              - reason
      required:
        - skipped
        - blocked
        - notices
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Session access JWT or an API token (`insta_<prefix>_<secret>`).

````