{
    "openapi": "3.0.3",
    "info": {
        "title": "LovelikeTH API",
        "version": "1.0.0",
        "description": "Server-to-server API. Send POST requests as application/x-www-form-urlencoded or application/json."
    },
    "servers": [
        {
            "url": "https://loveliketh.com/",
            "description": "Current website"
        }
    ],
    "paths": {
        "/api/v1": {
            "post": {
                "summary": "Execute an API action",
                "operationId": "executeApiAction",
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/x-www-form-urlencoded": {
                            "schema": {
                                "$ref": "#/components/schemas/ApiRequest"
                            }
                        },
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/ApiRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful response"
                    },
                    "400": {
                        "description": "Invalid request parameters"
                    },
                    "401": {
                        "description": "Invalid or disabled API key"
                    },
                    "403": {
                        "description": "Order blocked by blacklist policy"
                    },
                    "404": {
                        "description": "Service or order not found"
                    },
                    "405": {
                        "description": "Only POST is accepted"
                    },
                    "409": {
                        "description": "Duplicate or idempotency conflict"
                    },
                    "422": {
                        "description": "Request is valid but cannot be processed"
                    },
                    "429": {
                        "description": "Rate limit exceeded"
                    },
                    "500": {
                        "description": "Internal processing error"
                    },
                    "501": {
                        "description": "Feature is not available in this build"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "ApiRequest": {
                "type": "object",
                "required": [
                    "key",
                    "action"
                ],
                "properties": {
                    "key": {
                        "type": "string",
                        "description": "API key from the profile page"
                    },
                    "action": {
                        "type": "string",
                        "enum": [
                            "services",
                            "add",
                            "status",
                            "balance",
                            "refill",
                            "refill_status"
                        ]
                    },
                    "service": {
                        "type": "integer"
                    },
                    "link": {
                        "type": "string"
                    },
                    "quantity": {
                        "type": "integer"
                    },
                    "order": {
                        "type": "integer"
                    },
                    "orders": {
                        "type": "string",
                        "description": "Comma-separated order IDs"
                    },
                    "comments": {
                        "type": "string",
                        "description": "Newline-separated comments"
                    },
                    "usernames": {
                        "type": "string",
                        "description": "Newline-separated usernames"
                    },
                    "hashtags": {
                        "type": "string",
                        "description": "Newline-separated hashtags"
                    },
                    "hashtag": {
                        "type": "string"
                    },
                    "username": {
                        "type": "string"
                    },
                    "media_url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "posts": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "delay": {
                        "type": "integer",
                        "enum": [
                            0,
                            5,
                            10,
                            15,
                            30,
                            60,
                            90
                        ]
                    },
                    "expiry": {
                        "type": "string",
                        "format": "date"
                    },
                    "runs": {
                        "type": "integer",
                        "minimum": 1
                    },
                    "interval": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 1440
                    },
                    "idempotency_key": {
                        "type": "string",
                        "minLength": 8,
                        "maxLength": 64,
                        "pattern": "^[A-Za-z0-9._:-]+$"
                    }
                }
            }
        }
    }
}