Skip to content

Commit e9c9112

Browse files
feat(Added Delete endpoint and API doc):
1 parent 32924b0 commit e9c9112

File tree

2 files changed

+168
-0
lines changed

2 files changed

+168
-0
lines changed

API.md

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Bolna API Documentation
2+
3+
## Endpoints
4+
5+
### Get Agent
6+
Retrieves an agent's information by agent id.
7+
8+
**Endpoint:** `GET /agent/{agent_id}`
9+
10+
**Parameters:**
11+
- `agent_id` (path) - string, required: Unique identifier of the agent
12+
13+
### Create Agent
14+
Creates a new agent with specified configuration.
15+
16+
**Endpoint:** `POST /agent`
17+
18+
**Request Body:**
19+
```json
20+
{
21+
{
22+
"agent_config": {
23+
"agent_name": "Alfred",
24+
"agent_type": "other",
25+
"agent_welcome_message": "How are you doing Bruce?",
26+
"tasks": [
27+
{
28+
"task_type": "conversation",
29+
"toolchain": {
30+
"execution": "parallel",
31+
"pipelines": [
32+
[
33+
"transcriber",
34+
"llm",
35+
"synthesizer"
36+
]
37+
]
38+
},
39+
"tools_config": {
40+
"input": {
41+
"format": "wav",
42+
"provider": "twilio"
43+
},
44+
"llm_agent": {
45+
"agent_type": "simple_llm_agent",
46+
"agent_flow_type": "streaming",
47+
"routes": null,
48+
"llm_config": {
49+
"agent_flow_type": "streaming",
50+
"provider": "openai",
51+
"request_json": true,
52+
"model": "gpt-4o-mini"
53+
}
54+
},
55+
"output": {
56+
"format": "wav",
57+
"provider": "twilio"
58+
},
59+
"synthesizer": {
60+
"audio_format": "wav",
61+
"provider": "elevenlabs",
62+
"stream": true,
63+
"provider_config": {
64+
"voice": "George",
65+
"model": "eleven_turbo_v2_5",
66+
"voice_id": "JBFqnCBsd6RMkjVDRZzb"
67+
},
68+
"buffer_size": 100.0
69+
},
70+
"transcriber": {
71+
"encoding": "linear16",
72+
"language": "en",
73+
"provider": "deepgram",
74+
"stream": true
75+
}
76+
},
77+
"task_config": {
78+
"hangup_after_silence": 30.0
79+
}
80+
}
81+
]
82+
},
83+
"agent_prompts": {
84+
"task_1": {
85+
"system_prompt": "Why Do We Fall, Sir? So That We Can Learn To Pick Ourselves Up."
86+
}
87+
}
88+
}
89+
90+
91+
92+
}
93+
```
94+
95+
**Response:**
96+
```json
97+
200 OK
98+
{
99+
"agent_id": "uuid-string",
100+
"state": "created"
101+
}
102+
```
103+
104+
### Edit Agent
105+
Updates an existing agent's configuration.
106+
107+
**Endpoint:** `PUT /agent/{agent_id}`
108+
109+
**Parameters:**
110+
- `agent_id` (path) - string, required: Unique identifier of the agent
111+
112+
**Request Body:**
113+
Same as Create Agent endpoint
114+
115+
116+
### Delete Agent
117+
Deletes an agent from the system.
118+
119+
**Endpoint:** `DELETE /agent/{agent_id}`
120+
121+
**Parameters:**
122+
- `agent_id` (path) - string, required: Unique identifier of the agent
123+
124+
**Response:**
125+
```json
126+
200 OK
127+
{
128+
"agent_id": "string",
129+
"state": "deleted"
130+
}
131+
```
132+
133+
134+
### Get All Agents
135+
Retrieves all agents from the system.
136+
137+
**Endpoint:** `GET /all`
138+
139+
**Response:**
140+
```json
141+
200 OK
142+
{
143+
"agents": [
144+
{
145+
"agent_id": "string",
146+
"data": {
147+
// Agent configuration object
148+
}
149+
}
150+
]
151+
}
152+
```

local_setup/quickstart_server.py

+16
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ async def edit_agent(agent_id: str, agent_data: CreateAgentPayload = Body(...)):
132132
logger.error(f"Error updating agent {agent_id}: {e}", exc_info=True)
133133
raise HTTPException(status_code=500, detail="Internal server error")
134134

135+
@app.delete("/agent/{agent_id}")
136+
async def delete_agent(agent_id: str):
137+
"""Deletes an agent by ID."""
138+
try:
139+
agent_exists = await redis_client.exists(agent_id)
140+
if not agent_exists:
141+
raise HTTPException(status_code=404, detail="Agent not found")
142+
143+
await redis_client.delete(agent_id)
144+
return {"agent_id": agent_id, "state": "deleted"}
145+
146+
except Exception as e:
147+
logger.error(f"Error deleting agent {agent_id}: {e}", exc_info=True)
148+
raise HTTPException(status_code=500, detail="Internal server error")
149+
150+
135151
@app.get("/all")
136152
async def get_all_agents():
137153
"""Fetches all agents stored in Redis."""

0 commit comments

Comments
 (0)