Goldilocks Docs
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/v1

Authentication

Include your API key in the Authorization header:

Authorization: Bearer your-api-key

For 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 /documents

Query Parameters:

ParamTypeDescription
statusstringFilter by status: active, draft, all
limitnumberResults per page (default: 20, max: 100)
offsetnumberPagination 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/:id

Response:

{
  "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 /documents

Body:

{
  "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/:id

Body:

{
  "title": "Updated Title",
  "content": "Updated content...",
  "status": "active"
}

Delete Document

DELETE /documents/:id

Response:

{
  "success": true,
  "data": {
    "deleted": true
  }
}

FAQs API

List FAQs

GET /faqs

Query Parameters:

ParamTypeDescription
statusstringapproved, pending, draft, all
categorystringFilter by category slug
limitnumberResults per page
offsetnumberPagination offset

Get FAQ

GET /faqs/:id

Create FAQ

POST /faqs

Body:

{
  "question": "How do I reset my password?",
  "answer": "To reset your password...",
  "category": "account",
  "status": "approved"
}

Update FAQ

PUT /faqs/:id

Delete FAQ

DELETE /faqs/:id

Conversations API

List Conversations

GET /conversations

Query Parameters:

ParamTypeDescription
statusstringactive, ended, escalated, all
fromstringStart date (ISO 8601)
tostringEnd date (ISO 8601)
customerIdstringFilter by customer
limitnumberResults per page
offsetnumberPagination offset

Get Conversation

GET /conversations/:id

Response:

{
  "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/overview

Query Parameters:

ParamTypeDescription
fromstringStart date (ISO 8601)
tostringEnd date (ISO 8601)

Response:

{
  "success": true,
  "data": {
    "conversations": 1234,
    "messages": 5678,
    "resolutionRate": 0.78,
    "escalationRate": 0.15,
    "averageMessages": 4.6
  }
}

Get Topics

GET /analytics/topics

Response:

{
  "success": true,
  "data": {
    "topics": [
      { "name": "Shipping", "count": 245, "percentage": 0.23 },
      { "name": "Returns", "count": 189, "percentage": 0.18 }
    ]
  }
}

Webhooks API

List Webhooks

GET /webhooks

Create Webhook

POST /webhooks

Body:

{
  "url": "https://yoursite.com/webhook",
  "events": ["conversation.started", "conversation.escalated"],
  "secret": "your-webhook-secret"
}

Update Webhook

PUT /webhooks/:id

Delete Webhook

DELETE /webhooks/:id

Rate Limits

PlanRequests/minuteRequests/day
Free601,000
Pro30010,000
Business1,00050,000
EnterpriseCustomCustom

Rate limit headers:

X-RateLimit-Limit: 300
X-RateLimit-Remaining: 299
X-RateLimit-Reset: 1640000000

Error Codes

CodeHTTP StatusDescription
INVALID_REQUEST400Malformed request
UNAUTHORIZED401Invalid or missing API key
FORBIDDEN403Insufficient permissions
NOT_FOUND404Resource not found
RATE_LIMITED429Too many requests
SERVER_ERROR500Internal server error

SDKs

Official SDKs coming soon:

  • Node.js
  • Python
  • PHP

For now, use any HTTP client to interact with the API.