Agency Hosting: Files
Generate upload URL
Generate a file browser upload URL with authentication credentials for uploading files to an Agency Plan website's file storage.
Returns url, auth_key and rest_auth_key. Use these to upload a file to the website's file storage via the TUS resumable upload protocol (TUS 1.0.0). Send X-Auth: {auth_key} and X-Auth-Rest: {rest_auth_key} headers on every request below.
- Create the upload: POST to {url}/{relative_file_path}?override=true with headers upload-length: {file size in bytes} and upload-offset: 0. Expect 201 Created.
- Upload the file: send the file bytes to the same location (any TUS 1.0.0 client, or PATCH requests with an upload-offset header tracking progress) until complete.
relative_file_path is the destination path inside the website's file storage, e.g. app.zip.
Instead of a TUS client, plain curl also works:
FILE=app.zip
SIZE=$(stat -f%z "$FILE") # stat -c%s on Linux
curl -i -X POST "{url}/${FILE}?override=true" \
-H "X-Auth: {auth_key}" \
-H "X-Auth-Rest: {rest_auth_key}" \
-H "Tus-Resumable: 1.0.0" \
-H "Upload-Length: ${SIZE}" \
-H "Upload-Offset: 0"
# -> 201 Created
curl -i -X PATCH "{url}/${FILE}?override=true" \
-H "X-Auth: {auth_key}" \
-H "X-Auth-Rest: {rest_auth_key}" \
-H "Tus-Resumable: 1.0.0" \
-H "Content-Type: application/offset+octet-stream" \
-H "Upload-Offset: 0" \
--data-binary "@${FILE}"
# -> 204 No Content, Upload-Offset response header equals SIZE when done
post/api/agency-hosting/v1/websites/{website_uid}/files/upload-urls
Path parameters
website_uidstring required
Example:zpwlGlp19
Agency Plan website UID
Response
Success response
Example response
{
"url": "https://h5g12345-fm.hstgr.io/rest/1b2b4e5d5a5f795f/api/tus",
"auth_key": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjp7ImlkIjoxfX0.O-x6KeHMkNqnbYvbRcdDEQXOSLcqyE7xNrnKvftbG3A",
"rest_auth_key": "5c3b12fabf3d9652780a23ae705d2feb556c89907d0db50cddb8dffc27c1149d-1b2b4e5d5a5f795f"
}Changes
Changed in 1 of the 91 revisions of this API.1
- ○
endpoint added
endpoint-added
- ○