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

# Save Template Draft

> Requires `notification-template:edit`. Replaces the base half
(`base`, alias `metadata`) and the translations of a draft. Email
bodies are sanitised (removals listed in
`validation_detail.sanitized`). Each language is validated on its
own and the answer carries the field errors per scope (`base` or a
language) without blocking the save.

Structural errors are never stored: a base issue, or a translation
that sets a base field (`not-translatable`, such as a push
`action`), answers `422`. `409 version-not-draft` for a published or
archived version.




## OpenAPI

````yaml api-reference/notification/template-version/openapi.yaml PUT /notification/template/{document_id}/version/{version}
openapi: 3.0.1
info:
  title: Notification Template Version API
  description: |
    Versions of an event template (notification/notification-platform,
    ADR 0129): open a draft, save it, preview it, test-send it to yourself,
    publish it, compare versions and roll back, plus the channel contract
    the template editor builds its form from.

    **Halves.** A version has a `base` half shared by every language
    (layout, links, push `action`, ...) and a text half per language in
    `translations` (`es`, `en`, `pt`, `fr`, `it`). The fields of each half
    come from `GET /notification/channel/{channel}/contract`. A template has
    at most one draft; the published version keeps serving sends while the
    draft is edited. Publishing archives the previous version.

    **Errors.** Version writes answer `404 template-not-found` or `404
    version-not-found`, and `409 version-not-draft` when the version is not
    a draft. `422` carries one `{ code, field, language?, position?,
    message }` per problem in `error.errors`.
  version: '2026-11-03'
servers:
  - description: Production
    url: https://api.bbrands.io/api/v3
  - description: Certification
    url: https://certification.api.bbrands.io/api/v3
  - description: Development
    url: https://development.api.bbrands.io/api/v3
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Notification Template Version
    description: Drafts, publication, preview, test sends and diffs of a template.
  - name: Notification Channel Contract
    description: JSON Schema of the template halves of a channel.
paths:
  /notification/template/{document_id}/version/{version}:
    put:
      tags:
        - Notification Template Version
      summary: Save a draft
      description: |
        Requires `notification-template:edit`. Replaces the base half
        (`base`, alias `metadata`) and the translations of a draft. Email
        bodies are sanitised (removals listed in
        `validation_detail.sanitized`). Each language is validated on its
        own and the answer carries the field errors per scope (`base` or a
        language) without blocking the save.

        Structural errors are never stored: a base issue, or a translation
        that sets a base field (`not-translatable`, such as a push
        `action`), answers `422`. `409 version-not-draft` for a published or
        archived version.
      operationId: notificationTemplateVersionSave
      parameters:
        - $ref: '#/components/parameters/TemplateId'
        - $ref: '#/components/parameters/Version'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                base:
                  type: object
                  additionalProperties: true
                  description: Base half, shared by every language.
                metadata:
                  type: object
                  additionalProperties: true
                  description: Alias of `base`.
                translations:
                  $ref: '#/components/schemas/Translations'
            example:
              base:
                action: open_url
                url: https://app.maihuego.com/onboarding
              translations:
                es:
                  title: Te damos la bienvenida
                  body: Hola {{recipient.first_name}}, completa tu registro.
      responses:
        '200':
          description: Draft saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      version:
                        $ref: '#/components/schemas/TemplateVersion'
                      validation:
                        type: object
                        description: >-
                          Per scope (`base` or a language), field → first
                          message.
                        additionalProperties:
                          type: object
                          additionalProperties:
                            type: string
                        example:
                          en:
                            title: Must have at most 65 characters
                      validation_detail:
                        type: object
                        properties:
                          valid:
                            type: boolean
                          base:
                            type: array
                            items:
                              $ref: '#/components/schemas/ContractIssue'
                          translations:
                            type: object
                            additionalProperties:
                              type: array
                              items:
                                $ref: '#/components/schemas/ContractIssue'
                          sanitized:
                            type: object
                            description: Per language, what the HTML sanitiser removed.
                            additionalProperties:
                              type: array
                              items:
                                type: string
                  message:
                    type: string
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
components:
  parameters:
    TemplateId:
      name: document_id
      in: path
      required: true
      description: Template identifier.
      schema:
        type: string
        format: uuid
    Version:
      name: version
      in: path
      required: true
      description: Version number.
      schema:
        type: integer
        minimum: 1
        maximum: 100000
  schemas:
    Translations:
      type: object
      description: Text half per language.
      properties:
        es:
          type: object
          additionalProperties: true
        en:
          type: object
          additionalProperties: true
        pt:
          type: object
          additionalProperties: true
        fr:
          type: object
          additionalProperties: true
        it:
          type: object
          additionalProperties: true
    TemplateVersion:
      type: object
      properties:
        document_id:
          type: string
          format: uuid
        version:
          type: integer
        status:
          type: string
          enum:
            - archived
            - draft
            - published
        base:
          type: object
          additionalProperties: true
          description: Base half, shared by every language.
        metadata:
          type: object
          additionalProperties: true
          description: Same as `base`.
        translations:
          $ref: '#/components/schemas/Translations'
        languages:
          type: array
          items:
            $ref: '#/components/schemas/Locale'
        change_note:
          type: string
          nullable: true
        copied_from:
          type: string
          format: uuid
          nullable: true
          description: Version the draft was copied from.
        created_by:
          type: string
          format: uuid
          nullable: true
        published_by:
          type: string
          format: uuid
          nullable: true
        published_at:
          type: string
          format: date-time
          nullable: true
        archived_at:
          type: string
          format: date-time
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
          nullable: true
    ContractIssue:
      type: object
      properties:
        code:
          type: string
          example: too-long
        path:
          type: string
          example: title
        message:
          type: string
    Meta:
      type: object
      properties:
        correlation:
          type: string
          description: Request correlation id; quote it when reporting an issue.
        status:
          type: integer
        timestamp:
          type: string
          format: date-time
        version:
          type: string
          nullable: true
    Locale:
      type: string
      enum:
        - es
        - en
        - pt
        - fr
        - it
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            errors:
              type: array
              items: {}
            message:
              type: string
        meta:
          $ref: '#/components/schemas/Meta'
  responses:
    BadRequest:
      description: Malformed path, unknown body field or a body that is not JSON
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing, invalid, revoked or expired credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: The caller lacks the required permission
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Template or version not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: >-
        The version state does not allow it (`draft-exists`,
        `version-not-draft`)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnprocessableEntity:
      description: The content breaks a business rule; `error.errors` lists every problem
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            error:
              code: UNPROCESSABLE_ENTITY
              errors:
                - code: unknown-variable
                  field: title
                  language: en
                  message: Unknown variable onboarding.link
                  position: 12
              message: Unprocessable Entity
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: A `secret` API key, `hzk_<env>_<prefix>_<secret>`.

````

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