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

# ブランドメッセージのテンプレートを作成する

> カカオブランドメッセージのテンプレートを作成します。

> [!NOTE]
>
> 画像が必要なテンプレートでは、先に画像アップロードAPIで画像をアップロードします。レスポンスの`data.images[].url`をテンプレート本文に指定します。

> [!WARNING]
>
> `failoverTextMessage`を指定する場合は、`unsubscribeNumber`も必須です。広告SMSの代替配信には、登録済みの080受信拒否番号が必要です。


## OpenAPI

````yaml /ja/api-reference/openapi.yaml post /v1/projects/{projectId}/messages/kakao-brand-message/templates
openapi: 3.0.3
info:
  title: Notifly API
  version: 1.0.0
  contact:
    email: contact@notifly.tech
servers:
  - url: https://api.notifly.tech
    description: Notifly APIサーバー
security: []
tags:
  - name: catalog
    x-group: カタログ
paths:
  /v1/projects/{projectId}/messages/kakao-brand-message/templates:
    post:
      summary: create-kakao-brand-message-template
      operationId: createKakaoBrandMessageTemplate
      parameters:
        - name: projectId
          in: path
          required: true
          schema:
            type: string
          description: プロジェクトIDです。
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KakaoBrandMessageTemplateCreateRequest'
            example:
              senderKey: example_sender_key
              templateName: 신규 회원 쿠폰 안내
              template:
                type: image
                content:
                  text: '#{name}님, 신규 쿠폰이 도착했습니다.'
                  image:
                    url: https://mud-kage.kakao.com/example/img_l.jpg
                    link: https://example.com/coupon
                  buttons:
                    - buttonType: WL
                      buttonName: 쿠폰 확인
                      linkMo: https://example.com/coupon
      responses:
        '200':
          description: テンプレートを作成しました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KakaoBrandMessageTemplateCreateResponse'
        '400':
          description: リクエスト本文の形式が不正であるか、テンプレートがカカオの検証に合格しませんでした。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotiflyV1ErrorResponse'
        '401':
          description: トークンが無効か期限切れのため、認証に失敗しました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotiflyV1ErrorResponse'
        '403':
          description: プロジェクトへのアクセス権限がありません。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotiflyV1ErrorResponse'
        '500':
          description: サーバー内部エラーです。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotiflyV1ErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    KakaoBrandMessageTemplateCreateRequest:
      type: object
      required:
        - senderKey
        - templateName
        - template
      properties:
        senderKey:
          type: string
          minLength: 1
          description: カカオブランドメッセージの送信プロフィールの`senderKey`です。
        templateName:
          type: string
          minLength: 1
          description: テンプレート名です。
        template:
          $ref: '#/components/schemas/KakaoBrandMessageTemplateInput'
        failoverTextMessage:
          $ref: '#/components/schemas/KakaoBrandMessageFailoverTextMessageInput'
        unsubscribeNumber:
          type: string
          minLength: 1
          description: 代替配信に使うテキストメッセージを設定する際に必要な080受信拒否番号です。
    KakaoBrandMessageTemplateCreateResponse:
      type: object
      properties:
        data:
          type: object
          required:
            - templateId
          properties:
            templateId:
              type: string
              description: Notiflyに保存されたカカオブランドメッセージテンプレートIDです。
        error:
          type: string
          nullable: true
          description: 成功時はnullです。
    NotiflyV1ErrorResponse:
      type: object
      properties:
        data:
          type: object
          nullable: true
          description: 失敗時はnullです。
        error:
          oneOf:
            - type: string
            - $ref: '#/components/schemas/NotiflyV1ErrorObject'
          description: >-
            v1
            APIのエラーレスポンスです。認証や権限のエラーはcodeとmessageを持つオブジェクト、リクエストの検証エラーは文字列で返される場合があります。
      example:
        data: null
        error:
          code: UNAUTHORIZED
          message: Invalid Authorization Token
    KakaoBrandMessageTemplateInput:
      oneOf:
        - type: object
          title: テキスト型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - text
            content:
              type: object
              required:
                - text
              description: テキスト型の本文です。
              properties:
                text:
                  type: string
                  minLength: 1
                  description: メッセージ本文です。変数は`#{変数名}`の形式で入力します。
                buttons:
                  $ref: '#/components/schemas/KakaoBrandMessageButtons'
                coupon:
                  $ref: '#/components/schemas/KakaoBrandMessageCoupon'
        - type: object
          title: 画像型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - image
            content:
              type: object
              required:
                - text
                - image
              description: 標準画像と本文を表示します。
              properties:
                text:
                  type: string
                  minLength: 1
                  description: 画像の下に表示するメッセージ本文です。
                image:
                  $ref: '#/components/schemas/KakaoBrandMessageImage'
                buttons:
                  $ref: '#/components/schemas/KakaoBrandMessageButtons'
                coupon:
                  $ref: '#/components/schemas/KakaoBrandMessageCoupon'
        - type: object
          title: ワイド画像型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - wide-image
            content:
              type: object
              required:
                - text
                - image
              description: ワイド画像と本文を表示します。
              properties:
                text:
                  type: string
                  minLength: 1
                  description: 画像の下に表示するメッセージ本文です。
                image:
                  $ref: '#/components/schemas/KakaoBrandMessageImage'
                buttons:
                  $ref: '#/components/schemas/KakaoBrandMessageButtons'
                coupon:
                  $ref: '#/components/schemas/KakaoBrandMessageCoupon'
        - type: object
          title: ワイドアイテムリスト型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - wide-itemlist
            content:
              type: object
              required:
                - header
                - itemlist
              description: 最初のアイテムをメインアイテムとして、残りをサブアイテムとして表示します。
              properties:
                header:
                  type: string
                  minLength: 1
                  description: アイテムリストの上部に表示するタイトルです。
                itemlist:
                  type: array
                  minItems: 1
                  description: メインアイテムとサブアイテムのリストです。
                  items:
                    $ref: '#/components/schemas/KakaoBrandMessageWideItem'
                buttons:
                  $ref: '#/components/schemas/KakaoBrandMessageButtons'
                coupon:
                  $ref: '#/components/schemas/KakaoBrandMessageCoupon'
        - type: object
          title: カルーセル型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - carousel
            content:
              type: object
              required:
                - carousel
              description: 複数のフィードカードを左右にスワイプして閲覧できる形式で表示します。
              properties:
                carousel:
                  type: object
                  required:
                    - list
                  properties:
                    list:
                      type: array
                      minItems: 1
                      description: カルーセルに表示するフィードカードのリストです。
                      items:
                        $ref: '#/components/schemas/KakaoBrandMessageCarouselItem'
                    tail:
                      $ref: '#/components/schemas/KakaoBrandMessageLink'
        - type: object
          title: プレミアム動画型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - premium-video
            content:
              type: object
              required:
                - header
                - content
              description: 動画、サムネイル、説明文を表示します。
              properties:
                header:
                  type: string
                  minLength: 1
                  description: 動画の上に表示するタイトルです。
                content:
                  type: string
                  minLength: 1
                  description: 動画の説明文です。
                videoUrl:
                  type: string
                  format: uri
                  description: 外部からアクセスできる動画URLです。
                thumbnail:
                  $ref: '#/components/schemas/KakaoBrandMessageImage'
                buttons:
                  $ref: '#/components/schemas/KakaoBrandMessageButtons'
                coupon:
                  $ref: '#/components/schemas/KakaoBrandMessageCoupon'
        - type: object
          title: コマース型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - commerce
            content:
              type: object
              required:
                - item
              description: 単一商品の画像と価格情報を表示します。
              properties:
                additionalContent:
                  type: string
                  description: 商品情報の上に表示する追加テキストです。
                item:
                  $ref: '#/components/schemas/KakaoBrandMessageCommerceItem'
                coupon:
                  $ref: '#/components/schemas/KakaoBrandMessageCoupon'
        - type: object
          title: カルーセルコマース型
          required:
            - type
            - content
          properties:
            type:
              type: string
              enum:
                - carousel-commerce
            content:
              type: object
              required:
                - items
              description: 複数の商品カードをカルーセル形式で表示します。
              properties:
                intro:
                  $ref: '#/components/schemas/KakaoBrandMessageCarouselIntro'
                items:
                  type: array
                  minItems: 1
                  description: カルーセルに表示する商品カードのリストです。
                  items:
                    $ref: '#/components/schemas/KakaoBrandMessageCommerceItem'
                tail:
                  $ref: '#/components/schemas/KakaoBrandMessageLink'
      description: '`content`の構造は`type`によって異なります。必須フィールドとネスト構造は、各タイプのスキーマを確認してください。'
    KakaoBrandMessageFailoverTextMessageInput:
      oneOf:
        - $ref: '#/components/schemas/KakaoBrandMessageFailoverSmsInput'
        - $ref: '#/components/schemas/KakaoBrandMessageFailoverLmsInput'
      discriminator:
        propertyName: type
      description: カカオブランドメッセージの配信に失敗したときに送るテキストメッセージです。LMSでは`title`が必須です。
    NotiflyV1ErrorObject:
      type: object
      properties:
        code:
          type: string
          description: エラーコードです。
        message:
          type: string
          description: エラーメッセージです。
    KakaoBrandMessageButtons:
      type: array
      description: メッセージに表示するボタンのリストです。
      items:
        type: object
        required:
          - buttonType
        properties:
          buttonType:
            type: string
            enum:
              - WL
              - AL
              - BK
              - MD
              - AC
            description: ボタンのタイプです。
          buttonName:
            type: string
            description: ボタン名です。`AC`タイプでは省略できます。
          linkMo:
            type: string
            description: モバイルWebリンクです。
          linkPc:
            type: string
            description: PC用のWebリンクです。
          linkAnd:
            type: string
            description: Androidアプリのリンクです。
          linkIos:
            type: string
            description: iOSアプリのリンクです。
    KakaoBrandMessageCoupon:
      type: object
      additionalProperties: true
      description: >-
        クーポンのタイトル、説明、モバイルWeb、PC用Web、アプリのリンクを設定します。`title`を直接入力するか、`titleType`と`titleValue`でクーポンのタイトルを構成できます。
    KakaoBrandMessageImage:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
          description: 画像アップロードAPIが返す`data.images[].url`の値です。
        link:
          type: string
          description: 画像をクリックしたときの遷移先URLです。
    KakaoBrandMessageWideItem:
      type: object
      required:
        - image
        - link
      properties:
        title:
          type: string
          description: アイテムのタイトルです。
        image:
          $ref: '#/components/schemas/KakaoBrandMessageImage'
        link:
          $ref: '#/components/schemas/KakaoBrandMessageLink'
    KakaoBrandMessageCarouselItem:
      type: object
      required:
        - image
      properties:
        header:
          type: string
          description: カードのタイトルです。
        message:
          type: string
          description: カードの本文です。
        additionalContent:
          type: string
          description: カードに表示する追加テキストです。
        image:
          $ref: '#/components/schemas/KakaoBrandMessageImage'
        regularPrice:
          type: integer
          minimum: 0
          maximum: 99999999
          description: 商品の通常価格です。
        discountPrice:
          type: integer
          minimum: 0
          description: 商品の割引価格です。
        discountType:
          type: string
          enum:
            - amount
            - rate
          description: 割引の表示形式です。
        buttons:
          $ref: '#/components/schemas/KakaoBrandMessageButtons'
        coupon:
          $ref: '#/components/schemas/KakaoBrandMessageCoupon'
    KakaoBrandMessageLink:
      type: object
      properties:
        linkMo:
          type: string
          description: モバイルWebリンクです。
        linkPc:
          type: string
          description: PC用のWebリンクです。
        linkAnd:
          type: string
          description: Androidアプリのリンクです。
        linkIos:
          type: string
          description: iOSアプリのリンクです。
    KakaoBrandMessageCommerceItem:
      type: object
      required:
        - title
        - regularPrice
      properties:
        title:
          type: string
          minLength: 1
          description: 商品名です。
        regularPrice:
          type: integer
          minimum: 0
          maximum: 99999999
          description: 商品の通常価格です。
        discountPrice:
          type: integer
          minimum: 0
          description: 商品の割引価格です。
        discountType:
          type: string
          enum:
            - amount
            - rate
          description: 割引の表示形式です。
        additionalContent:
          type: string
          description: 商品カードに表示する追加テキストです。
        image:
          $ref: '#/components/schemas/KakaoBrandMessageImage'
        buttons:
          $ref: '#/components/schemas/KakaoBrandMessageButtons'
        coupon:
          $ref: '#/components/schemas/KakaoBrandMessageCoupon'
    KakaoBrandMessageCarouselIntro:
      type: object
      properties:
        header:
          type: string
          description: 導入カードのタイトルです。
        content:
          type: string
          description: 導入カードの本文です。
        image:
          $ref: '#/components/schemas/KakaoBrandMessageImage'
        link:
          $ref: '#/components/schemas/KakaoBrandMessageLink'
    KakaoBrandMessageFailoverSmsInput:
      type: object
      required:
        - type
        - body
        - senderPhoneNumber
      properties:
        type:
          type: string
          enum:
            - sms
          description: SMSによる代替配信です。
        body:
          type: string
          minLength: 1
          description: 代替配信に使うテキストメッセージの本文です。
        senderPhoneNumber:
          type: string
          minLength: 1
          description: テキストメッセージ用に登録された送信元番号です。
    KakaoBrandMessageFailoverLmsInput:
      type: object
      required:
        - type
        - title
        - body
        - senderPhoneNumber
      properties:
        type:
          type: string
          enum:
            - lms
          description: LMSによる代替配信です。
        title:
          type: string
          minLength: 1
          description: LMSのタイトルです。
        body:
          type: string
          minLength: 1
          description: 代替配信に使うテキストメッセージの本文です。
        senderPhoneNumber:
          type: string
          minLength: 1
          description: テキストメッセージ用に登録された送信元番号です。
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '`POST /authenticate`で発行したトークンをBearer形式で送信します。'

````

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