> ## 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 a journey-scoped notification template

> Publish the current draft of the journey-scoped notification template as a new version. Optionally roll back to a prior version by passing `{ "version": "vN" }`.



## OpenAPI

````yaml /openapi-specs/openapi.documented.yml post /journeys/{templateId}/templates/{notificationId}/publish
openapi: 3.0.1
info:
  title: Courier
  description: The Courier REST API for sending and managing notifications across channels.
  version: 0.0.1
servers:
  - url: https://api.courier.com
    description: Production
security: []
paths:
  /journeys/{templateId}/templates/{notificationId}/publish:
    post:
      tags:
        - Journeys
      summary: Publish a journey-scoped notification template
      description: >-
        Publish the current draft of the journey-scoped notification template as
        a new version. Optionally roll back to a prior version by passing `{
        "version": "vN" }`.
      operationId: journeys_publishTemplate
      parameters:
        - in: path
          name: templateId
          schema:
            type: string
            minLength: 1
          required: true
          description: Journey id
        - in: path
          name: notificationId
          schema:
            type: string
            minLength: 1
          required: true
          description: Notification template id
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/JourneyTemplatePublishRequest'
            examples:
              Example1:
                summary: Publish
                value: {}
      responses:
        '204':
          description: Published notification template
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
              examples:
                Example:
                  value:
                    message: Example message text
                    type: invalid_request_error
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
              examples:
                Example:
                  value:
                    message: Example message text
                    type: invalid_request_error
        '422':
          description: Unprocessable entity
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnprocessableEntity'
              examples:
                Example:
                  value:
                    message: Example message text
                    type: invalid_request_error
      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.journeys.templates.publish('x', { templateId: 'x' });
        - 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.journeys.templates.publish(
                notification_id="x",
                template_id="x",
            )
        - 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.Journeys.Templates.Publish(\n\t\tcontext.TODO(),\n\t\t\"x\",\n\t\tcourier.JourneyTemplatePublishParams{\n\t\t\tTemplateID: \"x\",\n\t\t},\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.journeys.templates.TemplatePublishParams;

            public final class Main {
                private Main() {}

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

                    TemplatePublishParams params = TemplatePublishParams.builder()
                        .templateId("x")
                        .notificationId("x")
                        .build();
                    client.journeys().templates().publish(params);
                }
            }
        - lang: Ruby
          source: |-
            require "courier"

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

            result = courier.journeys.templates.publish("x", template_id: "x")

            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->journeys->templates->publish(
                'x', templateID: 'x', version: 'v321669910225'
              );

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

            CourierClient client = new();

            TemplatePublishParams parameters = new()
            {
                TemplateID = "x",
                NotificationID = "x",
            };

            await client.Journeys.Templates.Publish(parameters);
        - lang: CLI
          source: |-
            courier journeys:templates publish \
              --api-key 'My API Key' \
              --template-id x \
              --notification-id x
components:
  schemas:
    JourneyTemplatePublishRequest:
      description: >-
        Request body for publishing a journey-scoped notification template. Pass
        `version` to roll back to a prior version; omit to publish the current
        draft.
      type: object
      properties:
        version:
          type: string
          pattern: ^v\d+$
    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'
    UnprocessableEntity:
      title: UnprocessableEntity
      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

````