Check Period Overlap
const options = {method: 'GET', headers: {'x-organization-id': '<x-organization-id>'}};
fetch('https://api.dcycle.io/v1/sold-products/periods/check-overlap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/sold-products/periods/check-overlap"
headers = {"x-organization-id": "<x-organization-id>"}
response = requests.get(url, headers=headers)
print(response.text)curl --request GET \
--url https://api.dcycle.io/v1/sold-products/periods/check-overlap \
--header 'x-organization-id: <x-organization-id>'{
"has_overlap": true
}Check Period Overlap
Ask whether any sold product period in your organization already covers a date range, before you create one
GET
/
v1
/
sold-products
/
periods
/
check-overlap
Check Period Overlap
const options = {method: 'GET', headers: {'x-organization-id': '<x-organization-id>'}};
fetch('https://api.dcycle.io/v1/sold-products/periods/check-overlap', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.dcycle.io/v1/sold-products/periods/check-overlap"
headers = {"x-organization-id": "<x-organization-id>"}
response = requests.get(url, headers=headers)
print(response.text)curl --request GET \
--url https://api.dcycle.io/v1/sold-products/periods/check-overlap \
--header 'x-organization-id: <x-organization-id>'{
"has_overlap": true
}← Sold Products API
Ask whether any sold product period in your organization already covers a given date range. Call it before creating a period so you can warn the user instead of silently double-counting the same sales across two overlapping periods.
Cause: A date is not in
One boolean, no detail. The response tells you whether something overlaps, not what. If you need to show the user which period is in the way, follow up with the period list for the product in question.
Request
Headers
string
required
UUID of the organization to check. The search covers every sold product in this organization — not just one product — so a period on any product can produce an overlap.Format: UUID
string
Your API key.
Query Parameters
string
required
First day of the range you want to check.Format:
YYYY-MM-DDstring
required
Last day of the range you want to check.Format:
YYYY-MM-DDBoth bounds are inclusive, on both sides. A period that ends exactly on your
start_date — or begins exactly on your end_date — counts as an overlap. Touching ranges are overlapping ranges here.So checking 2026-04-01 → 2026-06-30 against an existing period of 2026-01-01 → 2026-04-01 returns true, because the two share 1 April. If your model treats consecutive periods as adjacent rather than overlapping, start the new range on the day after the previous one ends.Response
boolean
true when at least one sold product period in the organization intersects the range, false when none does.Example
curl -X GET "https://api.dcycle.io/v1/sold-products/periods/check-overlap?start_date=2026-04-01&end_date=2026-06-30" \
-H "x-api-key: YOUR_API_KEY" \
-H "x-organization-id: YOUR_ORGANIZATION_ID"
import requests
HEADERS = {
"x-api-key": "YOUR_API_KEY",
"x-organization-id": "YOUR_ORGANIZATION_ID",
}
result = requests.get(
"https://api.dcycle.io/v1/sold-products/periods/check-overlap",
headers=HEADERS,
params={"start_date": "2026-04-01", "end_date": "2026-06-30"},
timeout=30,
).json()
if result["has_overlap"]:
raise ValueError("that range is already covered by an existing period")
const params = new URLSearchParams({
start_date: "2026-04-01",
end_date: "2026-06-30",
});
const response = await fetch(
`https://api.dcycle.io/v1/sold-products/periods/check-overlap?${params}`,
{
headers: {
"x-api-key": "YOUR_API_KEY",
"x-organization-id": "YOUR_ORGANIZATION_ID",
},
},
);
const { has_overlap: hasOverlap } = await response.json();
Successful Response
Returns200 OK.
{
"has_overlap": true
}
Common Errors
422 Unprocessable Entity
Cause:start_date or end_date is missing. Both are required — there is no “check from here onwards” mode.
{
"detail": [
{
"loc": ["query", "end_date"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
YYYY-MM-DD form.
{
"detail": [
{
"loc": ["query", "start_date"],
"msg": "invalid date format",
"type": "value_error.date"
}
]
}
Use Cases
Validate before you create, not after
Sold product periods are how sales are attributed to a reporting window. Two periods covering the same days mean the same sales are counted twice, and nothing downstream flags it — the totals simply come out too high. Checking first turns that into a message the user can act on.Guide a user to the next free range
Whenhas_overlap is true, the simplest recovery is to move the start date forward a day and check again. Because the bounds are inclusive, a range starting the day after an existing period ends is guaranteed not to overlap it.
Related Endpoints
List Periods
The periods that already exist, and their dates
List Sold Products
Every sold product in the organization
Sold Products API
Everything the Sold Products API covers
Was this page helpful?