Batch Files Upload

IMPORTANT: Unlike Publish Usage Events, this solution will not work out of the box, and you will need to work with support@productiv.com to make sure these files have all the information necessary and can be understood by Productiv.

In some special circumstances, you may need to upload a large batch of files to us. You can use this upload API to send us those files programmatically. Be sure to contact us about the format of these files or they may not get processed properly.

Prerequisites

  • Before this API can be queried you should have already setup the application for which you will be publishing usage events. Once thats done you should have a unique appId that can be used to query these APIs. Visit the Setup an Application section to see how to do so.

  • In order to query this API, you would also need to send an access_token as part of the Authorization header. To see the steps for generating an access token checkout Authorization.

  • To upload files to Productiv, you will need to follow two steps:

    • The first step is to make a GET request to Productiv, specifying the list of filenames to be uploaded. The response of this API call will return signed upload URLs for each filename specified. See Get Upload URLs Endpoint for more details.
    • The second step required to complete the upload to Productiv, is to make a PUT requests with each file to upload, using the signed URL returned for each file in the first step. You can see an example of this PUT request below

Get Upload URLs Endpoint

GET https://api.productiv.com/services/push/v1/customer/apps/{appId}/upload

Include the following headers and path parameters along with your requests:

Headers

Parameter Value
content-type application/json
Authorization Bearer access_token

Path Params

Parameter Description
appId appId represents the App for which the usage events are being pushed. (See Setup an Application)

Query Params

Parameter Description
filenames List of file names to upload.

Example API call

https://api.productiv.com/services/push/v1/customer/apps/myAppId/upload?filenames=foo.json&filenames=bar.json

Response

If the request is successful, a JSON response will be returned. This JSON object will contain a mapping from filename to the upload URL. You may make a PUT request to the upload URL to upload the file.

Example Response Schema

{
    "<filename1>": String,
    "<filename2>": String,
    ...
}

Example response:

{
    "test.json": "https://productiv-data.s3.us-west-2.amazonaws.com/log-connector-data/productiv-ai/myAppId/test.json?AWSAccessKeyId=1234"
}

S3 Direct Upload Endpoint

curl -X PUT -d 'Hello world' https://productiv-data.s3.us-west-2.amazonaws.com/log-connector-data/productiv-ai/myAppId/test.json?AWSAccessKeyId=1234

Response Errors

Error Code Error Message Description
400 Bad Request Returned if any invalid/unexpected query parameter/value is present in the request.
401 Unauthorized Returned if access_token used in request is invalid or expired.
403 Forbidden Returned if access_token does not have the required scope to use this API.
404 Not Found Returned if customer or application specified does not exist.
422 Unprocessable Entity Returned if the request payload is invalid
429 Too Many Requests Returned if rate limit has been exceeded

Example Error Response Schema

{
    "code": "401",
    "message": "Invalid access_token",
    "success": false
}

SLA

  • You must only send a batch of file names not more than 100 at a time.
  • Only events pushed to Productiv within 12 hours of their occurrence are guaranteed to be aggregated and shown on the product page.