Skip to main content
POST
/
v1
/
custom-kpi-datasets
/
{dataset_id}
/
responses
Submit Response
const options = {
  method: 'POST',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    organization_id: '<string>',
    campaign_id: '<string>',
    facility_id: '<string>',
    values: {},
    attachment_file_ids: {}
  })
};

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

Submit Response

Submit a Custom KPI response with values and optional evidence attachments. This is the authenticated submission flow — the caller must be a logged-in member of the organization.
For submissions from external data owners via magic-link, see Submit Public Form instead.

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

organization_id
string
required
UUID of the organization this response belongs to
campaign_id
string
required
UUID of the campaign being responded to
facility_id
string
UUID of the facility (optional — used to match an assignment)
values
array[object]
required
KPI values to submit (1–100 entries, no duplicate kpi_id). Each entry:
FieldTypeDescription
kpi_idstringUUID of the KPI definition
value_numericnumberFor number/percentage types (nullable)
value_textstringFor text type, max 10 000 chars (nullable)
value_datestringFor date type, ISO date (nullable)
option_idstringFor select type — UUID of the chosen option (nullable)
attachment_file_ids
array[string]
UUIDs of evidence files previously uploaded via Presigned URL. Max 20 files.

Response

Returns the created response set with saved values and attachment metadata (HTTP 201).
response_set_id
string
Response set UUID
campaign_assignment_id
string
Resolved campaign-assignment UUID
submitted_at
string
ISO 8601 timestamp
values
array[object]
Saved value objects
attachments
array[object]
Attachment metadata:
FieldTypeDescription
file_idstringFile UUID
file_namestringOriginal file name
file_urlstringPresigned download URL

Example

curl -X POST "https://api.dcycle.io/v1/custom-kpi-datasets/${DATASET_ID}/responses" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{
    "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "campaign_id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
    "values": [
      {"kpi_id": "c3d4e5f6-a7b8-9012-cdef-123456789012", "value_numeric": 42.5},
      {"kpi_id": "d4e5f6a7-b8c9-0123-defa-234567890123", "value_text": "Completed audit"}
    ],
    "attachment_file_ids": ["e5f6a7b8-c9d0-1234-efab-345678901234"]
  }'

Successful Response

{
  "response_set_id": "f1a2b3c4-d5e6-7890-abcd-ef9876543210",
  "campaign_assignment_id": "f1a2b3c4-d5e6-7890-abcd-ef1234567890",
  "submitted_at": "2025-06-20T14:30:00Z",
  "values": [
    {
      "id": "e1f2a3b4-c5d6-7890-abcd-ef1234567890",
      "assignment_id": "d4e5f6a7-b8c9-0123-defa-234567890123",
      "response_set_id": "f1a2b3c4-d5e6-7890-abcd-ef9876543210",
      "kpi_id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
      "value_numeric": 42.5,
      "value_text": null,
      "value_date": null,
      "option_id": null,
      "submitted_at": "2025-06-20T14:30:00Z",
      "submitter_email": "admin@company.com",
      "submitter_user_id": "b9f1e2d3-0000-0000-0000-000000000001",
      "created_at": "2025-06-20T14:30:00Z"
    }
  ],
  "attachments": [
    {
      "file_id": "e5f6a7b8-c9d0-1234-efab-345678901234",
      "file_name": "energy-audit-2025.pdf",
      "file_url": "https://storage.dcycle.io/..."
    }
  ]
}

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: Duplicate kpi_id entries in the values array
{
  "detail": [
    {
      "loc": ["body", "values"],
      "msg": "Duplicate kpi_id entries are not allowed in a single submission",
      "type": "value_error"
    }
  ]
}

Presigned URL

Upload evidence files before submitting

Dataset Values

View all submitted values across campaigns