Upload a File

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.
Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

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);
  }
}
Body Params
customer
object
string

Your shop key

string

An HMAC digest created by concatenating the Shopify customer ID, customer email and your shop key, using your API secret at the key. If you are using the "Headless" widget, you can access the data-customer-digest property that is automatically generated when a customer logs into your Shopify store.

string
string
string

The content type of the file in the formate of a MIME type as defined by IETF's RFC 6838

Responses

Language
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json