Token Package Upload API

Last updated: 2021-03-31 16:48:24

    API Description

    Request method: POST

    Service URL/v3/push/package/upload
    

    API service URLs correspond to service access points one by one. Please select the service URL corresponding to the service access point of your application.

    Feature: you can upload a token package file for a batch of device tokens, and messages will be pushed by the tokens in it.

    Request Parameters

    Parameter Type Required Description
    file form-data Yes
  • Token package file name: [1, 100] characters
  • Token package format and size: .zip, .txt, or .csv file within 100 MB
  • .zip file requirements: contains a single .txt or .csv file but not folders
  • .txt file requirements: encoded in UTF-8; one token (36 characters) per row
  • .csv file requirements: one column only; one token (36 characters) per row
  • Response Parameters

    Parameter Type Required Description
    retCode Integer Yes Error code
    errMsg String Yes Error message when a request error occurs
    uploadId Integer Yes When a file is uploaded, uploadId is provided as a positive integer, which represents the ID of the uploaded file. It is provided to the push API for token package push.

    Sample Request

    Curl sample

    curl -X POST 
    https://api.tpns.tencent.com/v3/push/package/upload 
       
    -H 'Authorization: Basic application authorization information' 
    -F 'file=@C:\Absolute path of the uploaded file'
    

    Python sample

    import requests
    
    url = "https://api.tpns.tencent.com/v3/push/package/upload"
    
    files = {'file':open('file name', 'rb')}
    upload_data={"fileName": "absolute file address"}
    
    headers = {
        'Authorization': "Basic application authorization information",
        }
    
    response = requests.request("POST", url, data=upload_data, headers=headers, files=files, verify=False)
    print(response.text.encode('utf-8'))
    

    Note:

    For more information on the application authorization, please see Basic Auth Verification.