{
    "openapi": "3.0.3",
    "info": {
        "title": "Ratas Design Works API",
        "description": "Official public REST API for Ratas Design Works Oy (ratasdesign.com). Provides programmatic access to published articles, pages, services, and sandbox simulations with Idempotency-Key, scoped permissions, and cursor pagination support.",
        "version": "1.1.0",
        "contact": {
            "name": "Ratas Design Works API Support",
            "url": "https://ratasdesign.com/docs",
            "email": "info@ratasdesign.com"
        }
    },
    "security": [
        {
            "oauth2": [
                "read:content",
                "read:services"
            ]
        }
    ],
    "servers": [
        {
            "url": "https://ratasdesign.com/wp-json",
            "description": "Production REST API Server"
        },
        {
            "url": "https://ratasdesign.com/wp-json?sandbox=true",
            "description": "Sandbox / Test Mode Server (non-destructive)"
        }
    ],
    "paths": {
        "/ratas/v1/services": {
            "get": {
                "operationId": "listServices",
                "summary": "List services",
                "description": "Retrieve machine-readable service list with cursor-based pagination.",
                "parameters": [
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "description": "Opaque pagination cursor for fetching the next page of results.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "description": "Maximum number of items to return (1-100).",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Paginated list of services",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ServiceListResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid request parameters",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Rate limit exceeded",
                        "headers": {
                            "Retry-After": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Seconds to wait before retrying"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/ratas/v1/quote-simulation": {
            "post": {
                "operationId": "createQuoteSimulation",
                "summary": "Create an asynchronous sandbox simulation job",
                "description": "Submit a safe, non-destructive simulation request. Supports Idempotency-Key header for safe retries and returns 202 Accepted with a pollable job status URL.",
                "parameters": [
                    {
                        "name": "Idempotency-Key",
                        "in": "header",
                        "required": false,
                        "description": "Unique client-generated key (UUID) to guarantee idempotent execution on network retries.",
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "service"
                                ],
                                "properties": {
                                    "service": {
                                        "type": "string",
                                        "enum": [
                                            "wordpress",
                                            "woocommerce",
                                            "seo-geo",
                                            "ads",
                                            "managed-cloud"
                                        ],
                                        "description": "Target service line"
                                    },
                                    "scope": {
                                        "type": "string",
                                        "enum": [
                                            "compact",
                                            "standard",
                                            "enterprise"
                                        ],
                                        "default": "standard",
                                        "description": "Project scope tier"
                                    },
                                    "sandbox": {
                                        "type": "boolean",
                                        "default": true,
                                        "description": "Run in safe sandbox mode without side effects"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "Async simulation job accepted",
                        "headers": {
                            "Location": {
                                "schema": {
                                    "type": "string",
                                    "format": "uri"
                                },
                                "description": "URL to poll job status"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AsyncJobResponse"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Validation error",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/ratas/v1/jobs/{id}": {
            "get": {
                "operationId": "getJobStatus",
                "summary": "Poll async job status",
                "description": "Retrieve the current status and result of an asynchronous job.",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "description": "Job identifier returned by 202 Accepted response",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Job status and result",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/AsyncJobResponse"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Job not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/wp/v2/posts": {
            "get": {
                "operationId": "listPosts",
                "summary": "List published articles",
                "description": "Retrieve published blog posts and expert guides.",
                "parameters": [
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "description": "Pagination cursor",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Items per page",
                        "schema": {
                            "type": "integer",
                            "default": 10,
                            "minimum": 1,
                            "maximum": 100
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "required": false,
                        "description": "Filter posts by search keyword",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Array of posts",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/Content"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid query parameters",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/wp/v2/pages": {
            "get": {
                "operationId": "listPages",
                "summary": "List published pages",
                "description": "Retrieve published service pages and company information.",
                "parameters": [
                    {
                        "name": "cursor",
                        "in": "query",
                        "required": false,
                        "description": "Pagination cursor",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "required": false,
                        "description": "Items per page",
                        "schema": {
                            "type": "integer",
                            "default": 10,
                            "minimum": 1,
                            "maximum": 100
                        }
                    },
                    {
                        "name": "slug",
                        "in": "query",
                        "required": false,
                        "description": "Filter by page slug",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Array of pages",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "array",
                                    "items": {
                                        "$ref": "#/components/schemas/Content"
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Invalid parameters",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "oauth2": {
                "type": "oauth2",
                "description": "Scoped OAuth 2.0 / Bearer token permissions for least-privilege agent access.",
                "flows": {
                    "clientCredentials": {
                        "tokenUrl": "https://ratasdesign.com/wp-json/mcp/v1/token",
                        "scopes": {
                            "read:content": "Read public posts, pages, and case studies",
                            "read:services": "Read service packages and pricing information",
                            "mcp:read": "Inspect Elementor page structure via MCP",
                            "mcp:write": "Create and update Elementor pages via MCP"
                        }
                    }
                }
            }
        },
        "schemas": {
            "ServiceListResponse": {
                "type": "object",
                "required": [
                    "provider",
                    "services",
                    "pagination"
                ],
                "properties": {
                    "provider": {
                        "type": "string"
                    },
                    "domain": {
                        "type": "string"
                    },
                    "services": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "string"
                                },
                                "name": {
                                    "type": "string"
                                },
                                "url": {
                                    "type": "string",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "pagination": {
                        "$ref": "#/components/schemas/CursorPagination"
                    }
                }
            },
            "CursorPagination": {
                "type": "object",
                "required": [
                    "next_cursor",
                    "has_more"
                ],
                "properties": {
                    "next_cursor": {
                        "type": "string",
                        "nullable": true,
                        "description": "Cursor for next page, or null if at the end."
                    },
                    "has_more": {
                        "type": "boolean",
                        "description": "True if more items exist."
                    }
                }
            },
            "AsyncJobResponse": {
                "type": "object",
                "required": [
                    "job_id",
                    "status"
                ],
                "properties": {
                    "job_id": {
                        "type": "string",
                        "description": "Unique job identifier"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "pending",
                            "processing",
                            "completed",
                            "failed"
                        ]
                    },
                    "status_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Endpoint to poll job status"
                    },
                    "idempotency_key": {
                        "type": "string",
                        "nullable": true
                    },
                    "sandbox": {
                        "type": "boolean"
                    }
                }
            },
            "Content": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "slug": {
                        "type": "string"
                    },
                    "link": {
                        "type": "string",
                        "format": "uri"
                    },
                    "title": {
                        "type": "object",
                        "properties": {
                            "rendered": {
                                "type": "string"
                            }
                        }
                    },
                    "excerpt": {
                        "type": "object",
                        "properties": {
                            "rendered": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "Error": {
                "type": "object",
                "required": [
                    "code",
                    "message",
                    "resolution"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "description": "Machine-readable error code"
                    },
                    "message": {
                        "type": "string",
                        "description": "Human- and agent-readable explanation"
                    },
                    "resolution": {
                        "type": "string",
                        "description": "Actionable resolution hint for the calling agent"
                    },
                    "status": {
                        "type": "integer",
                        "description": "HTTP status code"
                    }
                }
            }
        }
    }
}