# Upload permanent material

Debugging Tools

Interface should be called on the server side, not in the front end (Weixin Mini Program, web pages, APP, etc.) directly called, specific reference interface call guide

Interface name: addMaterial

This interface is used to add permanent materials such as pictures / voice / video.

# 1. How to call

# HTTPS calls

POST https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE

# Cloud Calls

  • Call method: officialAccount.material.addMaterial

  • The input and exit parameters are the same as the HTTPS call, which can be called in the cloud call documentation

# Third party invocation

  • This interface supports Third Party Platform generation business call.

  • The permission set to which this interface belongs is: 11,100

  • When a service provider is authorized by one of the permissions set, it can call on behalf of the merchant by using authorizer_access_token , which can be viewed in the third-party call documentation.

# 2. Request parameters

# Query parametersQuery String parameters

Parameter NametypeRequired to fill inExampleIntroductions
access_tokenstringyesACCESS_TOKENInterface invocation credentials, using access_token , authorizer_access_token
typestringyesvideoMedia types, image, voice, video (video) and thumbnail

# Request BodyRequest Payload

Parameter NametypeRequired to fill inIntroductions
mediaformdatayesMedia Document Identification
descriptionobjectnoMaterial description information that is required when uploading video material

# Body.descriptionObject Payload

Material description information that is required when uploading video material

Parameter NametypeRequired to fill inExampleIntroductions
titlestringnoVideo titleVideo Material Description Title
introductionstringnoVideo SummaryVideo Footage Description Description

# 3. Return Parameters

# Response Payload

Parameter NametypeIntroductions
media_idstringAdded permanent material media_id
urlstringURL (Image only)

# 4. Note

  1. When the permanent picture material is added, it will be returned to the developer with URL, and the developer can use it within the Tencent domain name (Tencent domain name outside the use, the picture will be blocked).
  2. Official Account has an upper limit on the total amount of material stored in Official Account: 100000 for graphic and photo material, and 1,000 for other types.
  3. The format size and other requirements of the material are consistent with the official website of the public platform:
  • Image: 10M, support bmp / png / jpeg / jpg / gif format
  • Voice: 2M, playback length not more than 60s, mp3 / wma / wav / amr format
  • Video (video): 10MB, MP4 format supported
  • Thumbnail (thumb): 64KB, supports JPG format
  1. In the specific content of the image message, the WeChat background filters external image links, and the image URL needs to be obtained through the upload of the image of the image from the interface.
  2. interface upload picture upload, do not take up Official Account in the material library of the number of 100000 pictures limit, pictures only support jpg / png format, the size must be less than 1MB.
  3. Text messages support the ability to insert links to your own account and other Official Account / Service Account group posts in the body.

# 5. Code examples

# 5.1 New video examples

Example Requests

curl "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE" -F media=@media.file -F description='{"title":VIDEO_TITLE, "introduction":INTRODUCTION}'

Return an example

{
  "media_id": "MEDIA_ID_123456",
  "url": ""
}

# 5.2 Examples of new pictures

Example Requests

curl "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=ACCESS_TOKEN&type=TYPE" -F media=@media.file

Return an example

{
  "media_id": "MEDIA_ID_654321",
  "url": "https://example.com/image.jpg"
}

# 6. Error code

The following is a list of error codes for this interface, other error codes can refer to General error codes

Error codeError DescriptionSolutions
40007invalid media_idInvalid Media ID

# 7. Scope of application

How this interface can be invoked under different account types:
Official Account Service Account
  • ✔: The account can call this interface
  • Other account types that are not expressly stated may not be called on this interface without special instructions;