Skip to main content
PATCH
/
v1
/
custom-kpi-datasets
/
{dataset_id}
/
campaigns
/
{campaign_id}
Update Campaign
const options = {
  method: 'PATCH',
  headers: {
    'x-api-key': '<x-api-key>',
    'x-organization-id': '<x-organization-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: '<string>',
    period_start: '<string>',
    period_end: '<string>',
    deadline: '<string>'
  })
};

fetch('https://api.dcycle.io/v1/custom-kpi-datasets/{dataset_id}/campaigns/{campaign_id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "id": "<string>",
  "dataset_id": "<string>",
  "name": "<string>",
  "period_start": "<string>",
  "period_end": "<string>",
  "deadline": "<string>",
  "locked_at": {},
  "created_at": {},
  "updated_at": {}
}

Update Campaign

Update the name, reporting period, or deadline of an existing campaign. Only send the fields you want to change.

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
campaign_id
string
required
UUID of the campaign

Body Parameters

All fields are optional.
name
string
Campaign name (1–255 characters)
period_start
string
Start of the reporting period (ISO date)
period_end
string
End of the reporting period. Must be after period_start when both are provided.
deadline
string
Submission deadline. Must be after period_start when both are provided.

Response

Returns the updated campaign (HTTP 200).
id
string
Campaign UUID.
dataset_id
string
UUID of the parent dataset.
name
string
Campaign display name.
period_start
string
Data collection period start date (ISO 8601 date).
period_end
string
Data collection period end date (ISO 8601 date).
deadline
string
Submission deadline (ISO 8601 date).
locked_at
string | null
Timestamp when the campaign was locked. null if still open.
created_at
datetime
Creation timestamp (ISO 8601).
updated_at
string | null
Last update timestamp (ISO 8601).

Example

curl -X PATCH "https://api.dcycle.io/v1/custom-kpi-datasets/${DATASET_ID}/campaigns/${CAMPAIGN_ID}" \
  -H "x-api-key: ${DCYCLE_API_KEY}" \
  -H "x-organization-id: ${DCYCLE_ORG_ID}" \
  -H "Content-Type: application/json" \
  -d '{"deadline": "2025-05-01", "name": "Q1 2025 Water Survey (Extended)"}'

Successful Response

{
  "id": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
  "dataset_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "Q1 2025 Water Survey (Extended)",
  "period_start": "2025-01-01",
  "period_end": "2025-03-31",
  "deadline": "2025-05-01",
  "locked_at": null,
  "created_by": "c3d4e5f6-a7b8-9012-cdef-345678901234",
  "updated_by": "c3d4e5f6-a7b8-9012-cdef-345678901234",
  "created_at": "2025-06-15T10:00:00Z",
  "updated_at": "2025-06-18T14:00:00Z"
}

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"}

404 Not Found

Cause: Campaign not found
{
  "detail": "Campaign not found"
}

422 Validation Error

Cause: Invalid or missing required fields in the request body
{
  "detail": [
    {
      "loc": ["body", "__root__"],
      "msg": "period_end must be after period_start",
      "type": "value_error"
    }
  ]
}

Get Campaign

View campaign with recipients

Lock Campaign

Prevent further submissions