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

  1. Read err.message — it includes the terminal state, so you know whether the connection actually succeeded (`completed`) or failed (`errored` / `cancelled`).
  2. If the state is `completed`, the channel is already connected. Do not start a new session — list connections instead.
  3. If the state is `errored` or `cancelled`, mint a fresh session with POST /v1/connect/{provider}.

Examples

curl

# Calling a session that already completed
curl https://api.repull.dev/v1/connect/sessions/cs_01HXYZ \
  -H "Authorization: Bearer sk_test_YOUR_KEY"

# {
#   "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_KEY! })

try {
  await repull.connect.complete(sessionId, payload)
} catch (err: any) {
  if (err.code === 'session_terminal') {
    if (err.message.includes('completed')) {
      // Already connected — list connections to find it
      const connections = await repull.connections.list()
      return { connection: connections[0] }
    }
    // Errored or cancelled — start over
    const fresh = await repull.connect.create({ provider: 'airbnb', redirectUrl: '...' })
    return { redirectTo: fresh.url }
  }
  throw err
}

If you're an AI agent

The Connect session is done — either successful or failed. If err.message says 'completed', the connection is already in place; list connections to find it. Otherwise, mint a new session.

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

AI