Integrating Squarespace API Key to Access Form Upload Images in ServiceM8

Can ServiceM8 fetch files from external URLs that require an API key in the Authorisation header? I’m helping a client with their Squarespace form uploads that requires API access to view the images. They get an error on the Squarespace end:

{"status":403,"error":"Access denied","message":"Access is denied"}

I understand they can download from Squarespace and upload to ServiceM8, but if it’s possible to add a Squarespace API key so they can immediately access the image from the submission in ServiceM8, that would be better.

Hi Ben,

In ServiceM8, getting an image/file into the Job Diary via the API is done by creating an Attachment record (linked via related_object/related_object_uuid) and then uploading the file’s data to ServiceM8, rather than having ServiceM8 fetch the file from a third-party URL.

The Attachment record itself is based around fields like related_object, related_object_uuid, attachment_name, and file_type (and related_object supports values like “job”, “company”, or “staff”).

Because the attachment flow requires submitting the binary file data to ServiceM8, for a Squarespace upload URL that needs an API key in the Authorization header, the workable approach is to have your integration retrieve the file from Squarespace (including whatever auth Squarespace requires) and then upload it into ServiceM8 as an attachment.

For the ServiceM8 side of that integration, API-key authentication is handled by sending your ServiceM8 API key in the X-API-Key header on your API requests.

Reply here with whether you’re aiming to attach these uploads to a Job or to the Client record, and we’ll confirm the best place to link the Attachment.

Thanks,
Cody