Action an "Upload File" earn rule. This earn rule is actioned in 2 parts;

  1. POST to this endpoint to create the point activity and register points against a customer. The post request also returns a presigned URL in the response body.
  2. Upload a file to a presigned URL generated from the previous step using a PUT request with the file contents as the body.

The following example is how you would upload a file to the pre-signed URL returned from the first POST HTTP request using a PUT HTTP request.


const response = await fetch('https://launcher.api.influence.io/launcher/v1/customer/upload-file', {
  method: 'POST',
  body: JSON.stringify({
    "customer": {
      "id": "123456",
      "email": "[email protected]"
    },
    "shop": "my-shop-key",
    "digest": "a2ea4c87e83eab70edc4f39c2e7077389c3dd010c20cadfb9c58d7278cc3deec",
    "earnRuleId": "00000000-0000-0000-0000-000000000000",
    "filename": "example.jpg",
    "mimeType": "image/jpeg"
  }),
  headers: {
    'Content-Type': 'application/json'
  }
});

const data = await response.json();


// Replace with your pre-signed S3 URL from the previous request
// presigned url will look something like this: https://influenceio130019-prod.s3.amazonaws.com/public/file-upload-earn-rule/your-image.jpg?AWSAccessKeyId=YOUR_ACCESS_KEY&Signature=YOUR_SIGNATURE&Expires=EXPIRATION_TIMESTAMP&Content-Type=image/jpeg
const presignedS3Url = data.url;

const fileInput = document.getElementById('file-input'); // Replace with your file input element
const file = event.target.files[0];

if (file) {
  try {
    const response = await fetch(presignedS3Url, {
      method: 'PUT',
      body: file,
      headers: {
        'Content-Type': file.type // Set the Content-Type based on the file type
      }
    });

    if (response.ok) {
      console.log('File uploaded successfully');
    } else {
      console.error('File upload failed');
    }
  } catch (error) {
    console.error('An error occurred:', error);
  }
}
Language
Click Try It! to start a request and see the response here!