SQLSTATE 23P01exclusion_violationHTTP 400
Postgres error 23P01: exclusion violation
conflicting key value violates exclusion constraint
A row overlaps another row in a way an exclusion constraint forbids, such as two bookings for the same room at the same time.
Common causes
- The new range overlaps an existing one with the same key.
How to fix it
- Treat it as a normal "slot taken" outcome in the app.
- Use half-open ranges ([start, end)) so back-to-back bookings do not count as overlapping.
Through a REST API
PostgREST, the REST layer behind supabase-js and Scribase, answers HTTP 400 for this error and returns the SQLSTATE in the code field of the JSON error body.
Questions
What does Postgres error 23P01 mean?
23P01 is exclusion_violation in class 23 (Integrity Constraint Violation). A row overlaps another row in a way an exclusion constraint forbids, such as two bookings for the same room at the same time.
How do I fix 23P01?
Treat it as a normal "slot taken" outcome in the app. Use half-open ranges ([start, end)) so back-to-back bookings do not count as overlapping.
What HTTP status does a REST API return for 23P01?
PostgREST, the REST layer behind supabase-js, answers 400.