Skip to main content
This topic describes the message notification types and data formats in DingTalk.

DingTalk message notification types

Work notification messages: Notification messages pushed to employees on behalf of a micro app in the work notification chat of an organization. Examples include birthday greetings and onboarding reminders.

Text message (text)

{
    "msgtype": "text",
    "text": {
        "content": "Monthly meeting notification"
    }
}

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYestextMessage type. Set to text for text messages.
contentStringYesMonthly meeting notificationMessage content. Up to 500 characters are recommended.

Message sample

Image message

{
    "msgtype": "image",
    "image": {
        "media_id": "@lADOADmaWMzazQKA"
    }
}

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYesimageMessage type. Set to image for image messages.
media_idStringYes@lADOADmaWMzazQKAThe media ID. Call the Upload media files API to obtain the mediaId parameter value. A size of 600 x 400 pixels with an aspect ratio of 3:2 is recommended.

Message sample

Voice message

{
    "msgtype": "voice",
    "voice": {
       "media_id": "@lADOADmaWMzazQKA",
       "duration": "10"
    }
}

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYesvoiceMessage type. Set to voice for voice messages.
media_idStringYes@lADOADmaWMzazQKAThe media file ID. Call the Upload media files API to obtain this value.
durationStringYes50A positive integer less than 60 that indicates the audio duration.

Message sample

File message

{
    "msgtype": "file",
    "file": {
       "media_id": "MEDIA_ID"
    }
}

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYesfileMessage type. Set to file for file messages.
media_idStringYes@lADOADmaWMzazQKAThe media file ID. The referenced media file must not exceed 10 MB. Call the Upload media files API to obtain this value.

Message sample

{
    "msgtype": "link",
    "link": {
        "messageUrl": "http://s.dingtalk.io/market/dingtalk/error_code.php",
        "picUrl":"@lALOACZwe2Rk",
        "title": "Test",
        "text": "Test"
    }
}

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYeslinkMessage type. Set to link for link messages.
link.messageUrlStringYeshttp://dingtalk.ioThe URL to open when the message is clicked. When the message is sent to a mini program, a mini program redirect URL is supported. See Message link description.
link.picUrlStringYes@lADOADmaWMzazQKACall the Upload media files API to obtain this value.
link.titleStringYesLink message testThe message title. Up to 100 characters are recommended.
link.textStringYesMessage content testThe message description. Up to 500 characters are recommended.

Message sample

OA message

{
     "msgtype": "oa",
     "oa": {
        "message_url": "http://dingtalk.io",
        "head": {
            "bgcolor": "FFBBBBBB",
            "text": "Header title"
        },
        "body": {
            "title": "Body title",
            "form": [
                {
                    "key": "Name:",
                    "value": "John"
                },
                {
                    "key": "Age:",
                    "value": "20"
                },
                {
                    "key": "Height:",
                    "value": "1.8 m"
                },
                {
                    "key": "Weight:",
                    "value": "65 kg"
                },
                {
                    "key": "Education:",
                    "value": "Bachelor's degree"
                },
                {
                    "key": "Hobbies:",
                    "value": "Ball games, listening to music"
                }
            ],
            "rich": {
                "num": "15.6",
                "unit": "USD"
            },
            "content": "Long text content long text content long text content long text content",
            "image": "@lADOADmaWMzazQKA",
            "file_count": "3",
            "author": "Jane "
        }
    }
}

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYesoaMessage type. Set to oa for OA messages.

OA message body parameters

NameTypeRequiredExampleDescription
oa.message_urlStringYeshttp://dingtalk.ioThe URL to open when the message is clicked. When the message is sent to a mini program, a mini program redirect URL is supported. See Message link description.
oa.pc_message_urlStringNohttp://dingtalk.ioThe URL to open when the message is clicked on the desktop client.
oa.headJSON ObjectYesThe message header.
oa.head.bgcolorStringYesFFBBBBBBThe font color of the message header title. The length is limited to 8 English characters. The first 2 characters indicate transparency, and the last 6 characters indicate the color value. Do not add 0x.
oa.head.textStringYesHeader titleThe message header title. For Send work notifications, this parameter is replaced with the current app name.
oa.status_barJSON ObjectNoThe message status bar. Only the userid list of recipients is supported. A maximum of 5 user IDs is allowed. Note Department ID lists are not supported, and to_all_user cannot be set to true.
oa.status_bar.status_valueStringNoIn progressThe status bar text.
oa.status_bar.status_bgStringNo0xFFF65E5EThe status bar background color. The default is black. The recommended format is 0xFF followed by a 6-digit color value.
oa.bodyJSON ObjectYesThe message body.
oa.body.titleStringNoBody titleThe message body title. Up to 50 characters are recommended.
oa.body.formArray[JSON Object]NoThe message body form. A maximum of 6 entries are displayed. Additional entries are hidden.
oa.body.form.keyStringNoNameThe keyword in the message body.
oa.body.form.valueStringNoJohnThe value corresponding to the keyword in the message body.
oa.body.richJSON ObjectNoThe single-line rich text information.
oa.body.rich.numStringNo15.6The number in the single-line rich text.
oa.body.rich.unitStringNoUSDThe unit in the single-line rich text.
oa.body.contentStringNoLong text contentThe message body content. A maximum of 3 lines is displayed.
oa.body.imageStringNo@lADOADmaWMzazQKAThe image in the message body. The @mediaId image resource is supported. Call the Upload media files API to obtain this value. A size of 600 x 400 pixels with an aspect ratio of 3:2 is recommended.
oa.body.file_countStringNo3The custom number of attachments. This number is for display only and is not verified by DingTalk.
oa.body.authorStringNoJaneThe custom author name.

Message sample

Markdown message

{
    "msgtype": "markdown",
    "markdown": {
        "title": "Content displayed on the first screen of the chat",
        "text": "# This is text that supports markdown   \n   ## Heading 2    \n   * List item 1   \n  "
    }
}

Markdown syntax

Title
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
 
Quote
> A man who stands for nothing will fall for anything.
 
Bold, Italic
**bold**
*italic*
 
Link
[this is a link](http://name.com)
 
Image

 
Bulleted List
- item1
- item2
 
Numbered List
1. item1
2. item2

Line break
  \n  (It is recommended to add 2 spaces before and after \n)

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYesmarkdownMessage type. Call the Upload media files API to obtain this value. Set to markdown for Markdown messages.
titleStringYesTest titleThe content displayed on the first screen of the chat.
textStringYesTest contentThe Markdown-formatted message. The maximum length is 5,000 characters.

Message sample

Card message

Card messages support the overall-redirect ActionCard style and the independent-redirect ActionCard style:
  • The overall-redirect ActionCard style supports a single click action. The single_title and single_url parameters are required.
    {
        "msgtype": "action_card",
        "action_card": {
            "title": "Text displayed in the chat list and notifications",
            "markdown": "Body content in Markdown format",
            "single_title": "View details",
            "single_url": "https://open.dingtalk.com"
        }
    }
    
  • The independent-redirect ActionCard style supports multiple click actions. The btn_orientation and btn_json_list parameters are required.
    {
        "msgtype": "action_card",
        "action_card": {
            "title": "Text displayed in the chat list and notifications",
            "markdown": "Body content in Markdown format",
            "btn_orientation": "1",
            "btn_json_list": [
                {
                    "title": "Button one",
                    "action_url": "https://www.taobao.com"
                },
                {
                    "title": "Button two",
                    "action_url": "https://www.tmall.com"
                }
            ]
        }
    }
    

Parameters

NameTypeRequiredExampleDescription
msgtypeStringYesaction_cardMessage type. Set to action_card for card messages.
action_card.markdownStringYesBody content in Markdown formatThe message content. Markdown is supported. Follow the standard Markdown syntax. Up to 1,000 characters are recommended.
action_card.titleStringNoTest titleThe text displayed in the chat list and notifications.
action_card.single_titleStringNoView detailsThe title used with the overall-redirect ActionCard style. Must be set together with single_url. The maximum length is 20 characters. Note For the overall-redirect ActionCard style, single_title and single_url are required.
action_card.single_urlStringNohttps://open.dingtalk.comThe URL to open when the message is clicked. Call the Upload media files API to obtain this value. When the message is sent to a mini program, a mini program redirect URL is supported. The maximum length is 500 characters.
action_card.btn_orientationStringNo0The button layout used with the independent-redirect ActionCard style: - 0: vertical - 1: horizontal Must be set together with btn_json_list.
action_card.btn_json_listJSONArrayNoThe button list used with the independent-redirect ActionCard style. Must be set together with btn_orientation. The total length must not exceed 1,000 characters. Note For the independent-redirect ActionCard style, btn_json_list and btn_orientation are required.
action_card.btn_json_list.titleStringNoTwo buttonsThe button title used with the independent-redirect ActionCard style. The maximum length is 20 characters.
action_card.btn_json_list.action_urlStringNohttps://www.tmall.comThe redirect URL used with the independent-redirect ActionCard style. The maximum length is 700 characters.

Message sample

  • A message sent with the overall-redirect ActionCard message type appears as follows:
  • A message sent with the independent-redirect ActionCard message type appears as follows: