{
    "openapi": "3.1.0",
    "info": {
        "title": "Spektakular API",
        "version": "1.0.0",
        "description": "Spektakular integration API: connect your applications (management, accounting, website, ticketing, warehouse…) with your profiles on Spektakular. Every call is HTTPS and JSON. Method, parameter and code names are in English; this documentation can be read in any language.\n\n## Authentication\n\nEvery call carries an API key in the «Authorization: Bearer <key>» header (or «X-Api-Key: <key>»). Spektakular administration generates the keys: each one belongs to a user and to ONE of their profiles, and only allows the methods of that profile type the user has enabled. Keep it like a password: it is only shown once. If it is compromised, ask for it to be revoked.\n\n## Live and test zones\n\nKeys starting with «spk_live_» work with live data; keys starting with «spk_test_» work with the test database, where you can try your integration safely. The address is the same: the key decides the zone. Every response states its zone in «meta.zone».\n\n## Rate limits\n\nPer key: 60 calls per minute and 2000 per hour (each method in a batch request counts). Batch requests: 5 per hour with up to 20 methods each. Per IP: 120 requests per minute; after 20 authentication failures the IP is blocked for 15 minutes. Maximum body: 256 KB; maximum time per call: 10 s.\nWhen a limit is exceeded the response is 429 with the «Retry-After» header (seconds to wait). The «X-RateLimit-Limit», «X-RateLimit-Remaining» and «X-RateLimit-Reset» headers show your hourly quota. Recommended: retry with increasing back-off and group calls into batch requests."
    },
    "servers": [
        {
            "url": "https://api.spektakular.horion.cloud/v1",
            "description": "API server (version 1)"
        }
    ],
    "tags": [
        {
            "name": "Batch",
            "description": "Batch requests"
        },
        {
            "name": "Account",
            "description": "Account"
        },
        {
            "name": "System",
            "description": "System"
        }
    ],
    "paths": {
        "/batch": {
            "post": {
                "operationId": "batch",
                "tags": [
                    "Batch"
                ],
                "summary": "Batch request",
                "description": "Call several methods in a single request: POST /v1/batch with {\"requests\": [{\"id\": \"…\", \"method\": \"…\", \"params\": {…}}, …]}. Up to 20 methods per request and 5 batch requests per hour. Each method is resolved independently: the response returns, in the same order, {\"id\", \"ok\", \"data\" | \"error\"} for each one, and a failure in one does not affect the others.",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/BatchRequest"
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/BatchResponse"
                                }
                            }
                        }
                    },
                    "4XX": {
                        "$ref": "#/components/responses/Error"
                    },
                    "5XX": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            }
        },
        "/me.get": {
            "post": {
                "operationId": "meGet",
                "tags": [
                    "Account"
                ],
                "summary": "Who am I: user, profile and permissions of the key",
                "description": "Returns the user and profile you connect as, the methods you can use with this key and your limits. It is the recommended first call to check a key.",
                "security": [
                    {
                        "bearerAuth": []
                    }
                ],
                "x-profile-types": [
                    "individual",
                    "professional",
                    "representative",
                    "client",
                    "provider"
                ],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ok",
                                        "data",
                                        "meta"
                                    ],
                                    "properties": {
                                        "ok": {
                                            "type": "boolean",
                                            "const": true
                                        },
                                        "data": {
                                            "type": "object",
                                            "properties": {
                                                "user": {
                                                    "type": "object",
                                                    "description": "User who owns the key.",
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer"
                                                        },
                                                        "username": {
                                                            "type": "string"
                                                        },
                                                        "locale": {
                                                            "type": "string"
                                                        }
                                                    }
                                                },
                                                "profile": {
                                                    "type": "object",
                                                    "description": "Profile the key connects as.",
                                                    "properties": {
                                                        "id": {
                                                            "type": "integer"
                                                        },
                                                        "type": {
                                                            "type": "string",
                                                            "enum": [
                                                                "individual",
                                                                "professional",
                                                                "representative",
                                                                "client",
                                                                "provider"
                                                            ]
                                                        },
                                                        "slug": {
                                                            "type": "string"
                                                        },
                                                        "name": {
                                                            "type": "string"
                                                        }
                                                    }
                                                },
                                                "key": {
                                                    "type": "object",
                                                    "description": "Key used (without the secret).",
                                                    "properties": {
                                                        "id": {
                                                            "type": "string"
                                                        },
                                                        "label": {
                                                            "type": "string"
                                                        },
                                                        "zone": {
                                                            "type": "string",
                                                            "enum": [
                                                                "live",
                                                                "test"
                                                            ]
                                                        }
                                                    }
                                                },
                                                "methods": {
                                                    "type": "array",
                                                    "items": {
                                                        "type": "string"
                                                    },
                                                    "description": "Methods this key can use."
                                                },
                                                "limits": {
                                                    "type": "object",
                                                    "description": "Rate limits in force."
                                                },
                                                "base_url": {
                                                    "type": "string",
                                                    "description": "Base address of the methods."
                                                }
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "$ref": "#/components/responses/Error"
                    },
                    "5XX": {
                        "$ref": "#/components/responses/Error"
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": []
                            }
                        }
                    }
                }
            }
        },
        "/system.ping": {
            "get": {
                "operationId": "systemPingGet",
                "tags": [
                    "System"
                ],
                "summary": "Check that the API is up",
                "description": "No key needed. Use it to check the connection and the server time.",
                "security": [],
                "x-profile-types": [],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ok",
                                        "data",
                                        "meta"
                                    ],
                                    "properties": {
                                        "ok": {
                                            "type": "boolean",
                                            "const": true
                                        },
                                        "data": {
                                            "type": "object",
                                            "required": [
                                                "pong",
                                                "time"
                                            ],
                                            "properties": {
                                                "pong": {
                                                    "type": "boolean",
                                                    "description": "Always true."
                                                },
                                                "time": {
                                                    "type": "string",
                                                    "format": "date-time",
                                                    "description": "Server time."
                                                },
                                                "api_version": {
                                                    "type": "string",
                                                    "description": "API version."
                                                }
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "$ref": "#/components/responses/Error"
                    },
                    "5XX": {
                        "$ref": "#/components/responses/Error"
                    }
                }
            },
            "post": {
                "operationId": "systemPing",
                "tags": [
                    "System"
                ],
                "summary": "Check that the API is up",
                "description": "No key needed. Use it to check the connection and the server time.",
                "security": [],
                "x-profile-types": [],
                "responses": {
                    "200": {
                        "description": "Successful response",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ok",
                                        "data",
                                        "meta"
                                    ],
                                    "properties": {
                                        "ok": {
                                            "type": "boolean",
                                            "const": true
                                        },
                                        "data": {
                                            "type": "object",
                                            "required": [
                                                "pong",
                                                "time"
                                            ],
                                            "properties": {
                                                "pong": {
                                                    "type": "boolean",
                                                    "description": "Always true."
                                                },
                                                "time": {
                                                    "type": "string",
                                                    "format": "date-time",
                                                    "description": "Server time."
                                                },
                                                "api_version": {
                                                    "type": "string",
                                                    "description": "API version."
                                                }
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "4XX": {
                        "$ref": "#/components/responses/Error"
                    },
                    "5XX": {
                        "$ref": "#/components/responses/Error"
                    }
                },
                "requestBody": {
                    "required": false,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": []
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "bearerAuth": {
                "type": "http",
                "scheme": "bearer",
                "bearerFormat": "spk_live_xxxxxxxxxxxx_… / spk_test_…",
                "description": "Every call carries an API key in the «Authorization: Bearer <key>» header (or «X-Api-Key: <key>»). Spektakular administration generates the keys: each one belongs to a user and to ONE of their profiles, and only allows the methods of that profile type the user has enabled. Keep it like a password: it is only shown once. If it is compromised, ask for it to be revoked."
            }
        },
        "schemas": {
            "Meta": {
                "type": "object",
                "properties": {
                    "request_id": {
                        "type": "string",
                        "description": "Request identifier (quote it if you contact us)."
                    },
                    "zone": {
                        "type": "string",
                        "enum": [
                            "live",
                            "test"
                        ],
                        "description": "Zone: live (live data) or test."
                    },
                    "api_version": {
                        "type": "string"
                    }
                }
            },
            "Error": {
                "type": "object",
                "required": [
                    "code",
                    "message"
                ],
                "properties": {
                    "code": {
                        "type": "string",
                        "enum": [
                            "invalid_request",
                            "invalid_json",
                            "invalid_params",
                            "payload_too_large",
                            "unauthorized",
                            "invalid_key",
                            "key_revoked",
                            "key_expired",
                            "ip_not_allowed",
                            "user_inactive",
                            "user_blocked",
                            "user_locked",
                            "api_access_denied",
                            "profile_not_found",
                            "profile_inactive",
                            "method_not_found",
                            "method_not_allowed",
                            "http_method_not_allowed",
                            "not_found",
                            "rate_limited",
                            "batch_limit",
                            "too_many_failures",
                            "timeout",
                            "test_zone_unavailable",
                            "service_unavailable",
                            "internal_error"
                        ],
                        "description": "Stable error code (in English)."
                    },
                    "message": {
                        "type": "string",
                        "description": "Error message (in English)."
                    },
                    "details": {
                        "type": "object",
                        "description": "More information (for example, which parameters failed)."
                    }
                }
            },
            "ErrorResponse": {
                "type": "object",
                "required": [
                    "ok",
                    "error",
                    "meta"
                ],
                "properties": {
                    "ok": {
                        "type": "boolean",
                        "const": false
                    },
                    "error": {
                        "$ref": "#/components/schemas/Error"
                    },
                    "meta": {
                        "$ref": "#/components/schemas/Meta"
                    }
                }
            },
            "BatchRequest": {
                "type": "object",
                "required": [
                    "requests"
                ],
                "properties": {
                    "requests": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 20,
                        "items": {
                            "type": "object",
                            "required": [
                                "id",
                                "method"
                            ],
                            "properties": {
                                "id": {
                                    "oneOf": [
                                        {
                                            "type": "string"
                                        },
                                        {
                                            "type": "integer"
                                        }
                                    ],
                                    "description": "Your identifier for this call: it is returned with its result."
                                },
                                "method": {
                                    "type": "string",
                                    "enum": [
                                        "me.get"
                                    ]
                                },
                                "params": {
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            },
            "BatchResponse": {
                "type": "object",
                "properties": {
                    "ok": {
                        "type": "boolean"
                    },
                    "data": {
                        "type": "object",
                        "properties": {
                            "responses": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "id": {
                                            "oneOf": [
                                                {
                                                    "type": "string"
                                                },
                                                {
                                                    "type": "integer"
                                                }
                                            ]
                                        },
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "data": {
                                            "type": "object"
                                        },
                                        "error": {
                                            "$ref": "#/components/schemas/Error"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "meta": {
                        "$ref": "#/components/schemas/Meta"
                    }
                }
            }
        },
        "responses": {
            "Error": {
                "description": "Error (see the error codes)",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/ErrorResponse"
                        }
                    }
                }
            }
        }
    },
    "x-error-codes": {
        "invalid_request": {
            "status": 400,
            "description": "The request is not valid (structure, identifiers…)."
        },
        "invalid_json": {
            "status": 400,
            "description": "The body is not a valid JSON object."
        },
        "invalid_params": {
            "status": 422,
            "description": "Parameters are missing or not valid; «details.errors» says which."
        },
        "payload_too_large": {
            "status": 413,
            "description": "The body exceeds the maximum size."
        },
        "unauthorized": {
            "status": 401,
            "description": "The API key is missing."
        },
        "invalid_key": {
            "status": 401,
            "description": "The key is not valid."
        },
        "key_revoked": {
            "status": 401,
            "description": "The key has been revoked."
        },
        "key_expired": {
            "status": 401,
            "description": "The key has expired."
        },
        "ip_not_allowed": {
            "status": 403,
            "description": "The key cannot be used from this IP."
        },
        "user_inactive": {
            "status": 403,
            "description": "The user account is not active."
        },
        "user_blocked": {
            "status": 403,
            "description": "The user account is blocked."
        },
        "user_locked": {
            "status": 403,
            "description": "The account is temporarily locked after failed sign-in attempts."
        },
        "api_access_denied": {
            "status": 403,
            "description": "The user has no API access."
        },
        "profile_not_found": {
            "status": 403,
            "description": "The key’s profile does not exist."
        },
        "profile_inactive": {
            "status": 403,
            "description": "The key’s profile is not active."
        },
        "method_not_found": {
            "status": 404,
            "description": "The method does not exist."
        },
        "method_not_allowed": {
            "status": 403,
            "description": "This key cannot use this method."
        },
        "http_method_not_allowed": {
            "status": 405,
            "description": "HTTP verb not allowed on this address."
        },
        "not_found": {
            "status": 404,
            "description": "The address does not exist."
        },
        "rate_limited": {
            "status": 429,
            "description": "Too many requests: wait as indicated by «Retry-After»."
        },
        "batch_limit": {
            "status": 429,
            "description": "The batch request limit for this hour has been reached."
        },
        "too_many_failures": {
            "status": 429,
            "description": "Too many authentication failures from this IP: it is temporarily blocked."
        },
        "timeout": {
            "status": 504,
            "description": "The request was taking too long and was stopped."
        },
        "test_zone_unavailable": {
            "status": 503,
            "description": "The test zone is not available right now."
        },
        "service_unavailable": {
            "status": 503,
            "description": "The API is temporarily unavailable (maintenance or overload): retry later."
        },
        "internal_error": {
            "status": 500,
            "description": "Internal error: it has been logged."
        }
    },
    "x-rate-limits": {
        "per_minute": 60,
        "per_hour": 2000,
        "batch_per_hour": 5,
        "batch_max": 20,
        "ip_per_minute": 120,
        "auth_fail_per_ip": 20,
        "auth_block_minutes": 15,
        "max_body_kb": 256,
        "time_limit": 10
    }
}