Developers
API Reference
REST API endpoints for server-side integration
The Goldilocks REST API allows server-side integration for content management, analytics, and advanced workflows.
Overview
Base URL
https://api.goldilocks.chat/v1Authentication
Include your API key in the Authorization header:
Authorization: Bearer your-api-keyFor server-side operations, use a server API key (available on Pro+ plans).
Response Format
All responses are JSON:
{
"success": true,
"data": { ... }
}Errors return:
{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Description of the error"
}
}Documents API
List Documents
GET /documentsQuery Parameters:
| Param | Type | Description |
|---|---|---|
status | string | Filter by status: active, draft, all |
limit | number | Results per page (default: 20, max: 100) |
offset | number | Pagination offset |
Response:
{
"success": true,
"data": {
"documents": [
{
"id": "doc_abc123",
"title": "Return Policy",
"status": "active",
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z"
}
],
"total": 42,
"limit": 20,
"offset": 0
}
}Get Document
GET /documents/:idResponse:
{
"success": true,
"data": {
"id": "doc_abc123",
"title": "Return Policy",
"content": "Our return policy allows...",
"status": "active",
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z"
}
}Create Document
POST /documentsBody:
{
"title": "New Document",
"content": "Document content here...",
"status": "active"
}Response:
{
"success": true,
"data": {
"id": "doc_new123",
"title": "New Document",
"status": "active",
"createdAt": "2024-01-15T10:00:00Z"
}
}Update Document
PUT /documents/:idBody:
{
"title": "Updated Title",
"content": "Updated content...",
"status": "active"
}Delete Document
DELETE /documents/:idResponse:
{
"success": true,
"data": {
"deleted": true
}
}FAQs API
List FAQs
GET /faqsQuery Parameters:
| Param | Type | Description |
|---|---|---|
status | string | approved, pending, draft, all |
category | string | Filter by category slug |
limit | number | Results per page |
offset | number | Pagination offset |
Get FAQ
GET /faqs/:idCreate FAQ
POST /faqsBody:
{
"question": "How do I reset my password?",
"answer": "To reset your password...",
"category": "account",
"status": "approved"
}Update FAQ
PUT /faqs/:idDelete FAQ
DELETE /faqs/:idConversations API
List Conversations
GET /conversationsQuery Parameters:
| Param | Type | Description |
|---|---|---|
status | string | active, ended, escalated, all |
from | string | Start date (ISO 8601) |
to | string | End date (ISO 8601) |
customerId | string | Filter by customer |
limit | number | Results per page |
offset | number | Pagination offset |
Get Conversation
GET /conversations/:idResponse:
{
"success": true,
"data": {
"id": "conv_abc123",
"customerId": "cust_12345",
"status": "ended",
"messages": [
{
"role": "customer",
"content": "How do I return my order?",
"timestamp": "2024-01-15T10:00:00Z"
},
{
"role": "assistant",
"content": "To return your order...",
"timestamp": "2024-01-15T10:00:05Z",
"sources": ["doc_abc123"]
}
],
"tags": ["returns", "orders"],
"createdAt": "2024-01-15T10:00:00Z",
"endedAt": "2024-01-15T10:05:00Z"
}
}Analytics API
Get Overview
GET /analytics/overviewQuery Parameters:
| Param | Type | Description |
|---|---|---|
from | string | Start date (ISO 8601) |
to | string | End date (ISO 8601) |
Response:
{
"success": true,
"data": {
"conversations": 1234,
"messages": 5678,
"resolutionRate": 0.78,
"escalationRate": 0.15,
"averageMessages": 4.6
}
}Get Topics
GET /analytics/topicsResponse:
{
"success": true,
"data": {
"topics": [
{ "name": "Shipping", "count": 245, "percentage": 0.23 },
{ "name": "Returns", "count": 189, "percentage": 0.18 }
]
}
}Webhooks API
List Webhooks
GET /webhooksCreate Webhook
POST /webhooksBody:
{
"url": "https://yoursite.com/webhook",
"events": ["conversation.started", "conversation.escalated"],
"secret": "your-webhook-secret"
}Update Webhook
PUT /webhooks/:idDelete Webhook
DELETE /webhooks/:idRate Limits
| Plan | Requests/minute | Requests/day |
|---|---|---|
| Free | 60 | 1,000 |
| Pro | 300 | 10,000 |
| Business | 1,000 | 50,000 |
| Enterprise | Custom | Custom |
Rate limit headers:
X-RateLimit-Limit: 300
X-RateLimit-Remaining: 299
X-RateLimit-Reset: 1640000000Error Codes
| Code | HTTP Status | Description |
|---|---|---|
INVALID_REQUEST | 400 | Malformed request |
UNAUTHORIZED | 401 | Invalid or missing API key |
FORBIDDEN | 403 | Insufficient permissions |
NOT_FOUND | 404 | Resource not found |
RATE_LIMITED | 429 | Too many requests |
SERVER_ERROR | 500 | Internal server error |
SDKs
Official SDKs coming soon:
- Node.js
- Python
- PHP
For now, use any HTTP client to interact with the API.