Potpie API
Create Conversation And Message
Convenience endpoint that creates a new conversation and sends a message in a single request. Perfect for one-off queries or integrating Potpie into external tools.
Use Cases:
- Quick code questions without managing conversations
- Integration with CI/CD pipelines
- Chatbot integrations
- API-first workflows
POST
Overview
Create a new conversation and send the first message in a single API call. This streamlined endpoint is perfect for quick interactions where you want to ask a question about your codebase without managing conversation state.Key Benefits
- Simplified Workflow: Combine conversation creation and messaging in one request
- Auto-hidden Conversations: Conversations are automatically hidden from the UI (configurable)
- Default Agent: Uses the Q&A agent by default for codebase queries
- Immediate Response: Get AI responses without managing conversation IDs
Use Cases
- Quick codebase queries without managing conversations
- Automated analysis scripts
- CI/CD integration for code insights
- Stateless API integrations
- One-off questions about specific projects
Authentication
This endpoint requires API key authentication via thex-api-key header.
Request & Response
Request & Response
| Location | Field | Type | Required | Default | Description |
|---|---|---|---|---|---|
| Path | project_id | string | required | - | The ID of the project to query about |
| Query | hidden | boolean | optional | true | Whether to hide this conversation from the web UI |
| Body | content | string | required | - | The message content to send (your question about the codebase) |
| Body | agent_id | string | optional | codebase_qna_agent | The ID of the agent to use |
| Body | node_ids | array[object] | optional | - | Array of node context objects to focus the conversation |
| Response | message | string | - | - | AI agent’s response content |
| Response | citations | array[string] | - | - | Source code references used in the response |
| Response | tool_calls | array | - | - | Tool invocations made by the agent during response generation |
Error Responses
400 Bad Request
400 Bad Request
The endpoint validates that message content is not empty.Causes:
- Empty string provided in
contentfield - Whitespace-only content
- Missing
contentfield
401 Unauthorized
401 Unauthorized
500 Internal Server Error
500 Internal Server Error
The endpoint returns this error when unexpected exceptions occur.Causes:
- Invalid project ID
- Project not yet ready (still parsing)
- Database connection failures
- Invalid agent ID
Complete Workflow
Advanced Usage
With Node Context
Focus the query on specific code elements:Make Visible in UI
Create a conversation that appears in the web interface:Complete Integration Example
Comparison with Standard Flow
| Feature | Create Conversation + Message | Direct Message (This Endpoint) |
|---|---|---|
| API Calls | 2 separate calls | 1 combined call |
| Conversation ID | You manage it | Automatically managed |
| UI Visibility | Configurable | Hidden by default |
| Use Case | Multi-turn conversations | Quick queries |
| Complexity | Higher | Lower |
Troubleshooting
Project not ready
Project not ready
Problem: Error occurs even with valid project ID.Solution:
- Check the project’s parsing status using the Get Parsing Status endpoint
- Wait for parsing to complete before sending messages
- Ensure the project status is “ready” before querying
Response takes too long
Response takes too long
Problem: Request times out or takes very long.Solution:
- Complex queries may take longer to process
- Implement appropriate timeout values (30-60 seconds recommended)
- Consider breaking complex questions into simpler ones
- Check if the project is very large
When to Use Standard vs. Direct Flow
Use This Endpoint When:- Making quick, one-off queries
- Building stateless integrations
- Automating codebase analysis
- Don’t need conversation history
- Building interactive chat experiences
- Need multi-turn conversations
- Managing conversation history
- Require fine-grained control over conversation state
Authorizations
API key authentication. Get your key from potpie settings page
Path Parameters
The project ID to query about
Query Parameters
Whether to hide this conversation from the web UI
Body
application/json

