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 an Airbnb reservation that is already cancelled.
  • Accepting an Airbnb reservation request that has already been accepted or has expired.
  • Sending a webhook test event when the webhook has no signing secret.
  • Replaying a delivery whose subscription has been deleted.
  • 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

  1. Read err.message — it tells you the current state and the operation you tried.
  2. Re-fetch the resource to get the canonical current state.
  3. If your state machine is out of sync (e.g. you cached a stale value), refresh from the GET endpoint and retry.
  4. For webhooks specifically, rotate the secret first if the message mentions a missing signing secret.

Examples

curl

# Bad: cancelling an already-cancelled Airbnb reservation.
# Cancellation is a host action on the channel, not a generic reservation route.
curl -X POST https://api.repull.dev/v1/channels/airbnb/reservations/HMABCD1234 \
  -H "Authorization: Bearer sk_live_YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"action": "cancel"}'

# {
#   "error": {
#     "code": "invalid_state",
#     "message": "Reservation is already cancelled."
#   }
# }

TypeScript

// The hand-written facade has no method for this action yet, so call it
// directly. Cancellation lives on the channel that owns the booking.
const res = await fetch(
  'https://api.repull.dev/v1/channels/airbnb/reservations/HMABCD1234',
  {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.REPULL_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ action: 'cancel' }),
  },
)

if (!res.ok) {
  const { error } = await res.json()
  if (error.code === 'invalid_state') {
    // Treat as a soft-success — the user wanted it cancelled and it is.
    console.warn('Already in target state:', error.message)
  } else {
    throw new Error(error.message)
  }
}

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.

Hit an error that isn't covered? Email hello@repull.dev with the request id from the response headers.

AI