Upload Media File

View Markdown

Last edited on 2026-03-30

This API should be called on the server side and cannot be called directly on the client side (Mini Program, web page, APP, etc.). For details, please refer to API Call Guide.

API English Name: upload_vp_file

This API is used to upload media files (such as images and vouchers).

1. Call Method

HTTPS Call

POST https://api.weixin.qq.com/xpay/upload_vp_file?access_token=ACCESS_TOKEN&pay_sig=PAY_SIG

Cloud Call

  • This API does not support cloud call.

Third-party Call

  • This API supports third-party platforms on behalf of Merchant call.

  • The permission set ID of this API is: 157

  • After the service provider obtains one of the permission set authorizations, it can use authorizer_access_token to call on behalf of Merchant, for details please refer to Third-party Call documentation.

2. Request Parameters

Query Parameters Query String Parameters

ParameterTypeRequiredExampleDescription
access_tokenstringYesACCESS_TOKENAPI call credential, you can use access_token, authorizer_access_token
pay_sigstringYes-Payment signature.

Request Body Request Payload

ParameterTypeRequiredDescription
envnumberYes0 - Production environment, 1 - Sandbox environment (only used for signature verification; query results always reflect the production environment).
base64_imgstringYesBase64-encoded image content. If using this field, the image size cannot exceed 1 MB. For images larger than 1 MB, use the `img_url` field.
img_urlstringYesImage URL. It must be directly downloadable and must not return status codes such as 302. The maximum allowed image size is 2 MB (prefer using `img_url`).
file_namestringYesImage name.

3. Response Parameters

Response Body Response Payload

ParameterTypeDescription
errcodenumberError code.
errmsgstringError message.
file_idstringReturned file ID.

4. Notes

Payment Signature

Payment Signature

The signature parameter is pay_sig, appended after the query parameters.

For example, if the API endpoint is: https://api.weixin.qq.com/xpay/query_user_balance?access_token=xxxx

After adding the signature, it becomes: https://api.weixin.qq.com/xpay/query_user_balance?access_token=xxxx&pay_sig=xxx

5. Code Example

No code example for this API

6. Error Codes

The following is the error code list of this API, other error codes can refer to Common Error Codes; When encountering errors in calling the API, you can use the official API Diagnostic Tool to assist in locating and analyzing problems.

Error CodeError Description
-1System error.
268490001OpenID error.
268490002Request parameter field error. For details, check `errmsg`.
268490003Signature error.
268490004Duplicate operation (Returned by interfaces related to gifting, token payment, and ad fund recharge, indicating that the previous operation was successful).
268490005The order has already been refunded via the `cancel_currency_pay` API and does not support further refunds.
268490006Insufficient token balance for refund/payment operation.
268490007The image or text contains sensitive content and is prohibited from use.
268490008Token not published; token operations are not allowed.
268490009User `session_key` does not exist or has expired. Please log in again.
268490011Data is being generated. Please call this API later to retrieve it.
268490012Batch task is running. Please wait for it to complete before running it again.
268490013Refunds are prohibited for orders in verified status.
268490014Refund operation in progress. Please retry with the same parameters later.
268490015Rate limit.
268490016The `left_fee` field for the refund does not match the actual value. Please verify using the `query_order` API.
268490018Ad fund recharge account industry ID mismatch.
268490019Ad fund recharge account ID is already bound to another appid.
268490020Ad fund recharge account entity name is incorrect.
268490021Account onboarding is not complete.
268490022Invalid ad fund recharge account.
268490023Insufficient ad fund balance.
268490024Ad fund recharge amount must be greater than 0.

7. Applicable Scope

The callable account types for this API are not yet clear, or are determined by the calling parameters in business. Please refer to the actual calling situation.