> ## 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.

# Put Notification Element

> Update a single element within a notification template. Only supported for V2 (elemental) templates.



## OpenAPI

````yaml /openapi-specs/openapi.documented.yml put /notifications/{id}/elements/{elementId}
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:
  /notifications/{id}/elements/{elementId}:
    put:
      tags:
        - Notification Templates
      summary: Put Notification Element
      description: >-
        Update a single element within a notification template. Only supported
        for V2 (elemental) templates.
      operationId: notifications_putElement
      parameters:
        - name: id
          in: path
          description: Notification template ID (`nt_` prefix).
          required: true
          schema:
            type: string
        - name: elementId
          in: path
          description: Element ID within the template.
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NotificationElementPutRequest'
            examples:
              UpdateTextElement:
                summary: Update a text element
                value:
                  type: text
                  data:
                    content: Updated text content
                  state: DRAFT
      responses:
        '200':
          description: Element updated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotificationContentMutationResponse'
              examples:
                ElementUpdated:
                  summary: Element updated successfully
                  value:
                    id: nt_01abc123
                    version: '2022-01-01'
                    elements:
                      - id: elem_1
                        checksum: abc123
                      - id: elem_2
                        checksum: def456
                    state: DRAFT
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequest'
              examples:
                ValidationError:
                  value:
                    type: invalid_request_error
                    message: 'type: Required'
        '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
                ElementNotFound:
                  value:
                    type: invalid_request_error
                    message: Element elem_nonexistent not found in template nt_01abc123
      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
            });


            const notificationContentMutationResponse = await
            client.notifications.putElement('elementId', {
              id: 'id',
              type: 'text',
              data: { content: 'Updated text content' },
              state: 'DRAFT',
            });


            console.log(notificationContentMutationResponse.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
            )

            notification_content_mutation_response =
            client.notifications.put_element(
                element_id="elementId",
                id="id",
                type="text",
                data={
                    "content": "Updated text content"
                },
                state="DRAFT",
            )

            print(notification_content_mutation_response.id)
        - lang: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\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\tnotificationContentMutationResponse, err := client.Notifications.PutElement(\n\t\tcontext.TODO(),\n\t\t\"elementId\",\n\t\tcourier.NotificationPutElementParams{\n\t\t\tID: \"id\",\n\t\t\tNotificationElementPutRequest: courier.NotificationElementPutRequestParam{\n\t\t\t\tType: \"text\",\n\t\t\t},\n\t\t},\n\t)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\tfmt.Printf(\"%+v\\n\", notificationContentMutationResponse.ID)\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.NotificationContentMutationResponse;

            import
            com.courier.models.notifications.NotificationElementPutRequest;

            import
            com.courier.models.notifications.NotificationPutElementParams;


            public final class Main {
                private Main() {}

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

                    NotificationPutElementParams params = NotificationPutElementParams.builder()
                        .id("id")
                        .elementId("elementId")
                        .notificationElementPutRequest(NotificationElementPutRequest.builder()
                            .type("text")
                            .build())
                        .build();
                    NotificationContentMutationResponse notificationContentMutationResponse = client.notifications().putElement(params);
                }
            }
        - lang: Ruby
          source: >-
            require "courier"


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


            notification_content_mutation_response =
            courier.notifications.put_element("elementId", id: "id", type:
            "text")


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


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


            use Courier\Client;

            use Courier\Core\Exceptions\APIException;

            use Courier\Notifications\NotificationTemplateState;


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


            try {
              $notificationContentMutationResponse = $client->notifications->putElement(
                'elementId',
                id: 'id',
                type: 'text',
                channels: ['string'],
                data: ['content' => 'bar'],
                if: 'if',
                loop: 'loop',
                ref: 'ref',
                state: NotificationTemplateState::DRAFT,
              );

              var_dump($notificationContentMutationResponse);
            } catch (APIException $e) {
              echo $e->getMessage();
            }
        - lang: C#
          source: >-
            using System;

            using TryCourier;

            using TryCourier.Models.Notifications;


            CourierClient client = new();


            NotificationPutElementParams parameters = new()

            {
                ID = "id",
                ElementID = "elementId",
                Type = "text",
            };


            var notificationContentMutationResponse = await
            client.Notifications.PutElement(parameters);


            Console.WriteLine(notificationContentMutationResponse);
        - lang: CLI
          source: |-
            courier notifications put-element \
              --api-key 'My API Key' \
              --id id \
              --element-id elementId \
              --type text
components:
  schemas:
    NotificationElementPutRequest:
      title: NotificationElementPutRequest
      type: object
      description: >-
        Request body for updating a single element. Additional type-specific
        fields are allowed.
      properties:
        type:
          type: string
          description: Element type (text, meta, action, image, etc.).
        channels:
          type: array
          items:
            type: string
        data:
          type: object
          additionalProperties: true
        if:
          type: string
        loop:
          type: string
        ref:
          type: string
        state:
          $ref: '#/components/schemas/NotificationTemplateState'
      required:
        - type
      additionalProperties: true
    NotificationContentMutationResponse:
      title: NotificationContentMutationResponse
      type: object
      description: >-
        Shared mutation response for `PUT` content, `PUT` element, and `PUT`
        locale operations. Contains the template ID, content version,
        per-element checksums, and resulting state.
      properties:
        id:
          type: string
          description: Template ID.
        version:
          type: string
          description: Content version identifier.
        elements:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              checksum:
                type: string
            required:
              - id
              - checksum
        state:
          $ref: '#/components/schemas/NotificationTemplateState'
      required:
        - id
        - version
        - elements
        - state
    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'
    NotificationTemplateState:
      title: NotificationTemplateState
      type: string
      description: Template state. Defaults to `DRAFT`.
      enum:
        - DRAFT
        - PUBLISHED
      default: DRAFT
    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

````