# Upload permanent material
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 Name | type | Required to fill in | Example | Introductions |
---|---|---|---|---|
access_token | string | yes | ACCESS_TOKEN | Interface invocation credentials, using access_token , authorizer_access_token |
type | string | yes | video | Media types, image, voice, video (video) and thumbnail |
# Request BodyRequest Payload
Parameter Name | type | Required to fill in | Introductions |
---|---|---|---|
media | formdata | yes | Media Document Identification |
description | object | no | Material description information that is required when uploading video material |
# Body.descriptionObject Payload
Material description information that is required when uploading video material
Parameter Name | type | Required to fill in | Example | Introductions |
---|---|---|---|---|
title | string | no | Video title | Video Material Description Title |
introduction | string | no | Video Summary | Video Footage Description Description |
# 3. Return Parameters
# Response Payload
Parameter Name | type | Introductions |
---|---|---|
media_id | string | Added permanent material media_id |
url | string | URL (Image only) |
# 4. Note
- 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).
- 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.
- 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
- 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.
- 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.
- 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 code | Error Description | Solutions |
---|---|---|
40007 | invalid media_id | Invalid Media ID |
# 7. Scope of application
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;