invalid_state
The resource is not in a state that allows this operation.
HTTP 409The resource is not in a state that allows this operation.
When it fires
The resource exists, but it is not in a state that allows the operation you tried. Examples:
- Cancelling a reservation that is already cancelled.
- Sending a webhook test event when the webhook has no signing secret.
- Replaying a delivery whose subscription has been deleted.
- Confirming a reservation that is already confirmed.
- Going live with a Booking.com property that has not passed the readiness check.
Response shape
Every Repull error follows the same envelope. The code is stable and safe to switch on.
{
"error": {
"code": "invalid_state",
"message": "<human-readable explanation of what went wrong>",
"docs_url": "https://repull.dev/docs/errors/invalid_state"
}
}How to fix
- Read err.message — it tells you the current state and the operation you tried.
- Re-fetch the resource to get the canonical current state.
- If your state machine is out of sync (e.g. you cached a stale value), refresh from the GET endpoint and retry.
- For webhooks specifically, rotate the secret first if the message mentions a missing signing secret.
Examples
curl
# Bad: cancelling an already-cancelled reservation
curl -X POST https://api.repull.dev/v1/reservations/abc123/cancel \
-H "Authorization: Bearer sk_test_YOUR_KEY"
# {
# "error": {
# "code": "invalid_state",
# "message": "Reservation is already cancelled."
# }
# }TypeScript
import { Repull } from '@repull/sdk'
const repull = new Repull({ apiKey: process.env.REPULL_KEY! })
try {
await repull.reservations.cancel('abc123')
} catch (err: any) {
if (err.code === 'invalid_state') {
// Treat as a soft-success — the user wanted it cancelled and it is.
console.warn('Already in target state:', err.message)
return
}
throw err
}If you're an AI agent
The action you tried does not apply to the resource's current state. Re-fetch the resource, check its state, and decide whether the request is now redundant or whether you need a different action.
Related
- Error reference — the full table of error codes
- Using Repull from AI agents — patterns for handling errors in agent loops
Hit an error that isn't covered? Email hello@repull.dev with the request id from the response headers.
AI