Skip to main content
POST
/
v1
/
end-conversations
End Conversations
curl --request POST \
  --url https://api.getbluejay.ai/v1/end-conversations \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <x-api-key>' \
  --data '
{
  "test_result_ids": [
    123
  ]
}
'
{
  "success": true,
  "ended_count": 123,
  "test_result_ids": [
    123
  ],
  "message": "<string>",
  "failed_ids": [
    123
  ]
}
Integration Prompt for AI Agents
# Bluejay — Testing & Monitoring Platform for Conversational AI Agents

You are a senior backend engineer integrating the Bluejay API. Think step-by-step: first understand the endpoint, then plan the integration, then implement with minimal changes.

## End Conversations — POST /v1/end-conversations

> **What this endpoint does:** End multiple running conversations by marking them in Redis for the LiveKit agent to terminate. This endpoint: 1. Checks that each test result exists and is in RUNNING status 2. Writes control objects to Redis for the LiveKit agent to pick up 3. Schedules a 30-second fallback watchdog for each conversation 4. Returns which conversations were successfully marked for ending and which failed The fallback watchdog ensures that if LiveKit fails to respond, the conversation status will be updated after 30 seconds to prevent it from appearing stuck forever.

**Endpoint:** POST `https://api.getbluejay.ai/v1/end-conversations`
**Auth:** `X-API-Key` header
**Content-Type:** application/json

### Required Parameters
| Name | Type | Description |
|------|------|-------------|
| X-API-Key | string | API key required to authenticate requests. |
| test_result_ids | array[integer] | List of test result IDs to end |

### Request Body (required fields)
```json
{
  "test_result_ids": [
    123
  ]
}
```

Refer to the full schema at https://docs.getbluejay.ai/api-reference/endpoint/end-conversations. Include optional fields that serve the goal of setting up for testing and monitoring on Bluejay.

### Example
**POST with body:**
```python
import requests

def end_conversations(payload: dict, api_key: str) -> dict:
    url = "https://api.getbluejay.ai/v1/end-conversations"
    headers = {"X-API-Key": api_key}
    response = requests.post(url, headers=headers, json=payload)
    response.raise_for_status()
    return response.json()
```

### Constraints
- Minimal changes — only add/change files needed for this integration.
- Match existing codebase patterns (naming, file structure, error handling).
- Include error handling for 422: Validation Error.

### Integration Checklist
Before writing code, verify:
1. Which module/service owns this API domain in the codebase?
2. What HTTP client and error-handling patterns does the project use?
3. Are there existing types/interfaces to extend?

Then implement the integration, export it, and confirm it compiles/passes lint.
End multiple running conversations by marking them for termination. Once marked, conversations will end within 20 seconds.

Headers

X-API-Key
string
required

API key required to authenticate requests.

Body

application/json

Pydantic model for ending multiple conversations

test_result_ids
integer[]
required

List of test result IDs to end

Minimum array length: 1

Response

Successful Response

Response for end conversations request

success
boolean
required

Whether the operation was successful

ended_count
integer
required

Number of conversations marked for ending

test_result_ids
integer[]
required

Test result IDs that were processed

message
string
required

Status message

failed_ids
integer[] | null

Test result IDs that failed to process (if any)