Skip to content
SibiSibi Developers
Esc
↑↓navigate↵open⌘Jpreview
On this page

Upload a Comment Attachment

Request a pre-signed URL to attach an image or PDF to a project comment

Attaching an image or PDF to a project comment is a three-step flow:

  1. Call this endpoint with the file’s contentType. It returns an imageKey and a short-lived, pre-signed url plus a set of fields.
  2. Upload the file with a multipart/form-data POST to url, sending the returned fields (verbatim) followed by the file part. Do not send your bearer token on this request — the policy is already signed.
  3. Pass the returned imageKey in the imageKeys array when you Post a Project Comment.

Repeat steps 1–2 for each file you want to attach (up to 50 per comment). Each file must be no larger than 15 MiB — the signed policy enforces this server-side, so you don’t declare a size.

Endpoint: https://api.sibipro.com/projects/v1/phases/{projectPhaseId}/comment-images

Authentication: Bearer token with the write:phase-images scope (Authorization: Bearer {accessToken})

Path parameters

projectPhaseId

string — Required. ID of the project phase whose comment the file will be attached to (returned from Create Project or project webhooks).

Request body

{
  "contentType": "image/jpeg"
}

contentType

"image/jpeg" | "image/png" | "image/heic" | "image/webp" | "application/pdf" — Required. MIME type of the file you intend to upload. The multipart POST must send a matching Content-Type field (it’s included in the returned fields).

Response 200

{
  "imageKey": "comment/phase_xyz/V1StGXR8_Z5jdHi6B-myT.pdf",
  "url": "https://...",
  "fields": {
    "key": "comment/phase_xyz/V1StGXR8_Z5jdHi6B-myT.pdf",
    "Content-Type": "application/pdf",
    "bucket": "...",
    "X-Amz-Algorithm": "AWS4-HMAC-SHA256",
    "X-Amz-Credential": "...",
    "X-Amz-Date": "...",
    "Policy": "...",
    "X-Amz-Signature": "..."
  }
}

imageKey

string — Opaque key for the upload. Pass this in imageKeys when posting a comment on the same project phase. A key issued here cannot be attached to another phase, or to a site visit.

url

string — Pre-signed URL to POST the upload to as multipart/form-data, within one hour. The upload is unauthenticated — the signature travels in fields.

fields

object — Form fields carrying the signed upload policy. Include every field, verbatim, in the multipart body before the file part. The policy caps the upload at 15 MiB and pins the content type; tampering with any field rejects the upload.

Uploading the file

curl -X POST "{url}" \
  -F key="{fields.key}" \
  -F Content-Type="{fields.Content-Type}" \
  -F bucket="{fields.bucket}" \
  -F X-Amz-Algorithm="{fields.X-Amz-Algorithm}" \
  -F X-Amz-Credential="{fields.X-Amz-Credential}" \
  -F X-Amz-Date="{fields.X-Amz-Date}" \
  -F Policy="{fields.Policy}" \
  -F X-Amz-Signature="{fields.X-Amz-Signature}" \
  -F file=@photo.jpg

Send the fields exactly as returned, then the file part last. A successful upload returns 204 with an empty body. Only after the upload succeeds should you reference the imageKey in a comment — the comment request verifies that each key references a real upload.

Error responses

HTTP code When
400 VALIDATION_ERROR Missing or unsupported contentType
401 UNAUTHORIZED Missing or invalid bearer token
403 INSUFFICIENT_SCOPE The token does not carry write:phase-images
403 FORBIDDEN Caller lacks permission to view the project phase, or the phase does not exist or has been cancelled
500 INTERNAL_ERROR Unexpected server error
503 AUTH_UNAVAILABLE The authentication service is temporarily unavailable. Retry shortly

Was this page helpful?