session_terminal
The Connect session is already completed, errored, or cancelled.
HTTP 409The resource is not in a state that allows this operation.
When it fires
You called a Connect session endpoint, but the session is already in a terminal state — either completed, errored, or cancelled. Terminal sessions cannot be re-used.
Response shape
Every Repull error follows the same envelope. The code is stable and safe to switch on.
{
"error": {
"code": "session_terminal",
"message": "<human-readable explanation of what went wrong>",
"docs_url": "https://repull.dev/docs/errors/session_terminal"
}
}How to fix
- Read error.message — it includes the terminal state, so you know whether the connection actually succeeded (`completed`) or failed (`errored` / `cancelled`).
- If the state is `completed`, the channel is already connected. Do not start a new session — list connections instead.
- If the state is `errored` or `cancelled`, mint a fresh session with POST /v1/connect/{provider}.
Examples
curl
# Binding a provider to a session that already completed.
# No API key here — the session id is the capability token.
curl -X POST https://api.repull.dev/v1/connect/sessions/cs_01HXYZ/select-provider \
-H "Content-Type: application/json" \
-d '{"provider": "hostaway"}'
# {
# "error": {
# "code": "session_terminal",
# "message": "Session is in terminal state: completed"
# }
# }TypeScript
import { Repull } from '@repull/sdk'
const repull = new Repull({ apiKey: process.env.REPULL_API_KEY! })
// Session endpoints take the session id as the capability token (no API key).
const res = await fetch(
`https://api.repull.dev/v1/connect/sessions/${sessionId}/select-provider`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ provider: 'hostaway' }),
},
)
if (!res.ok) {
const { error } = await res.json()
if (error.code === 'session_terminal') {
if (error.message.includes('completed')) {
// Already connected — list the workspace's connections to find it
const connections = await repull.connect.list()
return { connections }
}
// Errored or cancelled — start over with a fresh picker session
const fresh = await repull.connect.createSession({ redirectUrl: 'https://your-app.com/callback' })
return { redirectTo: fresh.url }
}
throw new Error(`${error.code}: ${error.message}`)
}If you're an AI agent
The Connect session is done — either successful or failed. If error.message says 'completed', the connection is already in place; list connections to find it. Otherwise, mint a new session.
Related
- Error reference — the full table of error codes
- Using Repull from AI agents — patterns for handling errors in agent loops
- Connect (multi-channel)
Hit an error that isn't covered? Email hello@repull.dev with the request id from the response headers.
AI