Skip to main content
POST
/
v1
/
custom-kpi-datasets
/
{dataset_id}
/
responses
/
attachments
/
presigned-url
Presigned URL
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({file_name: '<string>', content_type: '<string>', content_length_bytes: 123})
};

fetch('https://api.dcycle.io/v1/custom-kpi-datasets/{dataset_id}/responses/attachments/presigned-url', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "upload_url": "<string>",
  "file_id": "<string>",
  "file_name": "<string>"
}

Presigned URL

Generate a presigned S3 PUT URL for uploading an evidence file. Use this before calling Submit Response — upload the file to the returned URL, then include the file_id in your submission’s attachment_file_ids.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef
x-organization-id
string
required
Your organization UUIDExample: a8315ef3-dd50-43f8-b7ce-d839e68d51fa

Path Parameters

dataset_id
string
required
UUID of the parent dataset

Body Parameters

file_name
string
required
Original file name (1–255 characters)
content_type
string
MIME type of the file (e.g. application/pdf, image/png). Max 255 characters.
content_length_bytes
integer
required
File size in bytes. Must be between 1 and 10 485 760 (10 MB).

Response

Returns the presigned upload URL and file metadata (HTTP 201).
upload_url
string
Presigned S3 PUT URL — upload your file here with a PUT request
file_id
string
File UUID — include this in attachment_file_ids when submitting
file_name
string
Echoed file name

Example

# 1. Get the presigned URL
curl -X POST "https://api.dcycle.io/v1/custom-kpi-datasets/${DATASET_ID}/responses/attachments/presigned-url" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "energy-audit-2025.pdf",
    "content_type": "application/pdf",
    "content_length_bytes": 2048576
  }'

# 2. Upload the file to the presigned URL
curl -X PUT "${UPLOAD_URL}" \
  -H "Content-Type: application/pdf" \
  --data-binary @energy-audit-2025.pdf

Successful Response

{
  "upload_url": "https://dcycle-custom-kpi.s3.eu-west-1.amazonaws.com/attachments/...?X-Amz-Algorithm=AWS4-HMAC-SHA256&...",
  "file_id": "a1b2c3d4-0000-0000-0000-000000000001",
  "file_name": "energy-audit-2025.pdf"
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

422 Validation Error

Cause: File exceeds 10 MB limit
{
  "detail": [
    {
      "loc": ["body", "content_length_bytes"],
      "msg": "ensure this value is less than or equal to 10485760",
      "type": "value_error.number.not_le"
    }
  ]
}

Submit Response

Submit values with the uploaded attachments

Edit Values

Update values for a campaign-assignment