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

# Publish Notification Template

> Publish a notification template. Publishes the current draft by default. Pass a version in the request body to publish a specific historical version.



## OpenAPI

````yaml /openapi-specs/openapi.documented.yml post /notifications/{id}/publish
openapi: 3.0.1
info:
  title: Courier
  description: The Courier REST API.
  version: 0.0.1
servers:
  - url: https://api.courier.com
    description: Production
security: []
paths:
  /notifications/{id}/publish:
    post:
      tags:
        - Notification Templates
      summary: Publish Notification Template
      description: >-
        Publish a notification template. Publishes the current draft by default.
        Pass a version in the request body to publish a specific historical
        version.
      operationId: notifications_publish
      parameters:
        - name: id
          in: path
          description: Template ID (nt_ prefix).
          required: true
          schema:
            type: string
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotificationTemplatePublishRequest'
            examples:
              PublishDraft:
                summary: Publish the current draft (default)
                value: {}
              PublishSpecificVersion:
                summary: Publish a specific historical version (rollback)
                value:
                  version: v001
      responses:
        '204':
          description: >-
            Successfully published, or already published with no changes
            (idempotent).
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
              examples:
                InvalidVersion:
                  value:
                    type: invalid_request_error
                    message: 'version: Expected format: v001, v002, etc.'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
              examples:
                TemplateNotFound:
                  value:
                    type: invalid_request_error
                    message: Notification template nt_nonexistent not found
                VersionNotFound:
                  value:
                    type: invalid_request_error
                    message: Version not found for template nt_123
      security:
        - BearerAuth: []
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Courier from '@trycourier/courier';

            const client = new Courier({
              apiKey: process.env['COURIER_API_KEY'], // This is the default and can be omitted
            });

            await client.notifications.publish('id');
        - lang: Python
          source: |-
            import os
            from courier import Courier

            client = Courier(
                api_key=os.environ.get("COURIER_API_KEY"),  # This is the default and can be omitted
            )
            client.notifications.publish(
                id="id",
            )
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\n\t\"github.com/trycourier/courier-go\"\n\t\"github.com/trycourier/courier-go/option\"\n)\n\nfunc main() {\n\tclient := courier.NewClient(\n\t\toption.WithAPIKey(\"My API Key\"),\n\t)\n\terr := client.Notifications.Publish(\n\t\tcontext.TODO(),\n\t\t\"id\",\n\t\tcourier.NotificationPublishParams{},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n}\n"
        - lang: Java
          source: |-
            package com.courier.example;

            import com.courier.client.CourierClient;
            import com.courier.client.okhttp.CourierOkHttpClient;
            import com.courier.models.notifications.NotificationPublishParams;

            public final class Main {
                private Main() {}

                public static void main(String[] args) {
                    CourierClient client = CourierOkHttpClient.fromEnv();

                    client.notifications().publish("id");
                }
            }
        - lang: Ruby
          source: |-
            require "courier"

            courier = Courier::Client.new(api_key: "My API Key")

            result = courier.notifications.publish("id")

            puts(result)
        - lang: PHP
          source: >-
            <?php


            require_once dirname(__DIR__) . '/vendor/autoload.php';


            use Courier\Client;

            use Courier\Core\Exceptions\APIException;


            $client = new Client(apiKey: getenv('COURIER_API_KEY') ?: 'My API
            Key');


            try {
              $result = $client->notifications->publish('id', version: 'v321669910225');

              var_dump($result);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: |-
            using Courier;
            using Courier.Models.Notifications;

            CourierClient client = new();

            NotificationPublishParams parameters = new() { ID = "id" };

            await client.Notifications.Publish(parameters);
        - lang: CLI
          source: |-
            courier notifications publish \
              --api-key 'My API Key' \
              --id id
components:
  schemas:
    NotificationTemplatePublishRequest:
      title: NotificationTemplatePublishRequest
      type: object
      description: >-
        Optional request body for publishing a notification template. Omit or
        send an empty object to publish the current draft.
      properties:
        version:
          type: string
          pattern: ^v\d+$
          description: >-
            Historical version to publish (e.g. "v001"). Omit to publish the
            current draft.
    BadRequest:
      title: BadRequest
      type: object
      properties:
        type:
          type: string
          enum:
            - invalid_request_error
      required:
        - type
      allOf:
        - $ref: '#/components/schemas/BaseError'
    NotFound:
      title: NotFound
      type: object
      properties:
        type:
          type: string
          enum:
            - invalid_request_error
      required:
        - type
      allOf:
        - $ref: '#/components/schemas/BaseError'
    BaseError:
      title: BaseError
      type: object
      properties:
        message:
          type: string
          description: A message describing the error that occurred.
      required:
        - message
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````