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

# Update OSM Template

> This API updates an OSM template as per your requirements.

#### Rate Limit

The rate limit is 100 RPM.


## OpenAPI

````yaml /api/osm-templates/osm-templates.yaml put /custom-templates/osm
openapi: 3.0.3
info:
  title: MoEngage On-Site Messaging (OSM) Template API
  version: '1.0'
  description: >-
    API for creating, updating, and searching On-Site Messaging (OSM) templates
    within the MoEngage platform.
servers:
  - url: https://api-{dc}.moengage.com/v1.0
    description: MoEngage Custom Templates API Server
    variables:
      dc:
        default: '01'
        description: >-
          The ‘dc’ in the API Endpoint URL refers to the MoEngage Data Center
          (DC). MoEngage hosts each customer in a different DC. You can find
          your DC number and replace the value of ‘dc’ in the URL by referring
          to the DC and API endpoint mapping
          [here](/api/introduction#data-centers). Your MoEngage Data Center (DC)
          can be 01, 02, 03, 04, 05, 06, or 101.
security:
  - basicAuth: []
tags:
  - name: OSM Templates
    description: Operations to manage On-Site Messaging (OSM) templates.
paths:
  /custom-templates/osm:
    put:
      tags:
        - OSM Templates
      summary: Update OSM Template
      description: This API updates an OSM template as per your requirements.
      requestBody:
        required: true
        description: The updated details for the OSM template.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateOsmTemplateRequest'
            example:
              external_template_id: 81e1a740-3e57-4c70-8ec7-ffc84d576498
              update_campaigns: false
              basic_details:
                payload: <html><body><h1>Updated HTML Content</h1></body></html>
              meta_info:
                template_name: AD template updated API 1
                template_id: '133434477456'
                template_version: '2'
                updated_by: testuser@moengage.com
      responses:
        '200':
          description: Template updated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  external_template_id:
                    type: string
                    format: uuid
                    description: The unique ID of the updated template.
              example:
                external_template_id: 4a1afbc5-4c31-4f19-8c23-793e27af01aa
        '400':
          description: Bad Request. Validation failed or missing parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StandardErrorResponse'
              example:
                error:
                  code: 400 Bad Request
                  message: Validation failed because of invalid request data
                  details:
                    - code: MissingValue
                      target: external_template_id
                      message: >-
                        external_template_id value is required but value is
                        passed empty.
                  request_id: cTRlnJaG
        5XX:
          description: Internal Server Error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SimpleErrorResponse'
              example:
                title: Internal Server Error
                message: >-
                  An unexpected error was encountered while processing this
                  request. Please contact MoEngage Team
components:
  schemas:
    UpdateOsmTemplateRequest:
      type: object
      required:
        - external_template_id
        - basic_details
        - meta_info
      properties:
        external_template_id:
          type: string
          format: uuid
          description: >-
            The unique identifier generated by MoEngage during template
            creation.
        update_campaigns:
          type: boolean
          default: false
          description: >
            Flag to update all campaigns currently using this template to the
            newer version.

            * **`true`**: All campaigns running with this template will be
            updated.

            * **`false`**: A new version of the template is created; existing
            campaigns remain unchanged.
        basic_details:
          type: object
          description: Details about the template payload.
          required:
            - payload
          properties:
            payload:
              type: string
              description: |
                The updated HTML content.
                * Payload type must be HTML.
                * No limit restriction on field length.
        meta_info:
          type: object
          description: >-
            Updates template information such as name, version, and updater
            details.
          required:
            - template_name
            - template_id
            - updated_by
          properties:
            template_name:
              type: string
              description: The name of the template being updated.
            template_id:
              type: string
              description: A unique ID for the template provided by you.
            template_version:
              type: string
              description: >-
                Optional new version for the template. The version will be
                increased by 1 automatically after every update.
            updated_by:
              type: string
              format: email
              description: The email ID of the person updating the template.
    StandardErrorResponse:
      type: object
      description: Standard error structure used for 400 and 429 responses.
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: A brief explanation of the error.
              example: 4XX Bad Request
            message:
              type: string
              description: >-
                Describes why the request failed (e.g., Duplicate -
                template_id).
              example: Duplicate - template_id and template_version
            details:
              type: array
              description: >-
                A list of error detail objects containing code, target, and
                specific messages.
              items:
                type: object
                properties:
                  code:
                    type: string
                    description: Descriptive Error Code.
                    example: InvalidValue
                  target:
                    type: string
                    description: Denotes the field causing the issue.
                    example: Duplicate - template_id and template_version
                  message:
                    type: string
                    description: Descriptive Error Message.
                    example: >-
                      template_id:BasicTemplate1 template_version:1 is already
                      present.
            request_id:
              type: string
              description: Unique identifier for the request.
              example: cLCcgLQj
    SimpleErrorResponse:
      type: object
      description: Simplified error structure used for 401, 415, and 5xx responses.
      properties:
        title:
          type: string
          description: The title of the error.
          example: Authentication required
        description:
          type: string
          description: A description of the error (used in 401/415).
          example: MOE-APPKEY missing in Authentication Header
        message:
          type: string
          description: A message describing the error (used in 5xx).
          example: An unexpected error was encountered.
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: >
        Authentication is done via Basic Auth. This requires a base64-encoded
        string of your credentials in the format 'username:password'.


        - **Username**: Use your MoEngage workspace ID (also known as the App
        ID). You can find it in the MoEngage dashboard at **Settings** >
        **Account** > **APIs** > **Workspace ID (earlier app id)**.

        - **Password**: Use your API Key, which you can find within the
        **Campaign report/Business events/Custom templates/Catalog API/Inform
        Report** tile.


        For more information on authentication and getting your credentials,
        refer
        [here](https://www.moengage.com/docs/api/introduction#getting-your-credentials).

````