POST /api/v2/wfm/schedules/import returned 409 Conflict. Error: “Schedule already exists for the specified date range and user group.”
Running genesyscloud_wfm_schedule resource in Dev environment (Sydney). Terraform provider v1.32.0. The import payload is identical to the previous state. No manual changes in UI. Is there a race condition in the CI/CD pipeline causing this conflict? Or is the IDempotency key handling broken for bulk imports? Need a workaround for automated promotion.
You need to handle the idempotency key explicitly in your Terraform configuration. The WFM import endpoint requires a unique Idempotency-Key header for every request to prevent duplicate processing during retries or parallel executions. If this header is missing or reused within the same time window, the API returns a 409 Conflict.
In the Genesys Cloud Terraform provider, this is often managed automatically, but bulk imports or rapid CI/CD runs can exhaust the window or cause race conditions if multiple modules try to import overlapping schedules simultaneously.
Check your genesyscloud_wfm_schedule resource block. Ensure you are not relying on implicit state for the import key. A common fix is to use a dynamic attribute for the import_key or ensure the depends_on attribute forces sequential execution of overlapping schedule resources.
resource "genesyscloud_wfm_schedule" "shift_schedule" {
name = "Shift_A"
user_group_id = var.user_group_id
start_date = "2023-10-01"
end_date = "2023-10-31"
# Force unique idempotency for each run if provider fails to auto-generate
import_key = "schedule-${var.user_group_id}-${timestamp()}"
depends_on = [genesyscloud_wfm_usergroup.target_group]
}
The timestamp() function ensures the key changes every apply, avoiding the “already exists” error from previous failed runs. Also, verify that no other pipeline or manual action is creating schedules for the same date range and user group concurrently. The Sydney edge sometimes has slight latency differences that exacerbate race conditions in distributed pipelines.
| Requirement |
Value |
| Provider Version |
v1.32.0+ |
| Idempotency Key |
Unique per request |
| Execution Mode |
Sequential for overlapping ranges |
| Conflict Cause |
Reused key or parallel writes |
This usually resolves the 409 error. If the issue persists, check the API logs for the exact timestamp of the conflict to identify if another process is hitting the same endpoint.
resource “genesyscloud_wfm_schedule” “legal_audit_schedule” {
name = “Legal Discovery Export Schedule”
description = “Automated schedule for bulk recording metadata export”
group_id = var.wfm_group_id
start_date = “2023-10-01”
end_date = “2023-10-31”
Critical for legal hold chain of custody: ensure unique idempotency
idempotency_key = “${var.wfm_group_id}-${timestamp()}”
}
The 409 conflict usually stems from reusing the same idempotency key within the API retention window, which is dangerous for legal discovery workflows. If the CI/CD pipeline retries a failed import with the same key, the system sees it as a duplicate attempt to modify the same schedule, triggering the conflict. For legal holds, we cannot afford gaps in the audit trail, so the key must be unique per deployment cycle.
Using `timestamp()` in Terraform ensures every run generates a fresh key. This prevents the race condition mentioned earlier. However, be careful with bulk exports to S3. If the schedule triggers a bulk export job for digital channels, ensure the S3 bucket policy allows the Genesys Cloud service principal to write objects. A permission error during the export can corrupt the chain of custody, making the recording metadata inadmissible for legal review.
Also, verify that the `start_date` and `end_date` do not overlap with an existing manual schedule in the UI. The API does not merge overlapping ranges; it rejects them. For legal discovery, it is better to use a dedicated user group for automated exports. This isolates the audit trail from regular workforce management changes. Check the bulk export job status in the API logs after the schedule runs. If the job fails, the idempotency key is still consumed, so you must generate a new one for the next attempt. This approach keeps the metadata chain intact and avoids 409 errors during rapid pipeline executions.