{
  "openapi": "3.1.0",
  "info": {
    "title": "REST API SmsManager",
    "description": "API pro správu účtů a dalších zdrojů SmsManageru.\n",
    "version": "v1",
    "contact": {
      "url": "https://smsmanager.com",
      "email": "cc@smsmanager.com"
    }
  },
  "servers": [
    {
      "url": "https://rest-api.smsmngr.com/v1",
      "description": "Odpoví s daty vašeho požadavku"
    }
  ],
  "components": {
    "securitySchemes": {
      "x-api-key": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    }
  },
  "security": [
    {
      "x-api-key": []
    }
  ],
  "paths": {
    "/apikey/me": {
      "get": {
        "tags": [
          "api"
        ],
        "summary": "Získat informace o aktuálním API klíči",
        "responses": {
          "200": {
            "description": "Informace o API klíči",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": true
                    },
                    "me": {
                      "type": "object",
                      "description": "Informace o API klíči.",
                      "properties": {
                        "note": {
                          "type": "string",
                          "description": "Poznámka k API klíči (může být prázdná). Můžete ji použít k uložení jakýchkoli informací při vytváření API klíče."
                        },
                        "default_callback_url": {
                          "type": "string",
                          "description": "Výchozí URL pro zpětné volání pro tento API klíč."
                        },
                        "account": {
                          "type": "string",
                          "description": "Typ účtu.",
                          "enum": [
                            "prepaid",
                            "postpaid"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Špatný požadavek",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": false
                    },
                    "message": {
                      "type": "string",
                      "description": "Chybová zpráva.",
                      "example": "Nepodařilo se přečíst API klíč"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/apikey/add": {
      "post": {
        "tags": [
          "api"
        ],
        "summary": "Vytvořit nový API klíč",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "shared": {
                    "type": "boolean",
                    "description": "Pokud je true, nový API klíč bude sdílet váš kreditní limit. Pokud je false, nový API klíč bude mít vlastní kredit."
                  },
                  "currency": {
                    "type": "string",
                    "description": "Měna pro API klíč. Pokud je nový API klíč sdílený, měna musí být stejná jako u rodičovského API klíče(!)",
                    "default": "CZK",
                    "enum": [
                      "EUR",
                      "CZK"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Nový API klíč",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": true
                    },
                    "apikey": {
                      "type": "string",
                      "description": "Nový API klíč.",
                      "example": "1234567890"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/apikey/update": {
      "post": {
        "tags": [
          "api"
        ],
        "summary": "Aktualizovat API klíč",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "default_callback_url": {
                    "type": "string",
                    "description": "Výchozí URL pro zpětné volání pro tento API klíč. Tato URL bude použita pro příchozí zprávy bez vazby na odchozí zprávy."
                  },
                  "note": {
                    "type": "string",
                    "description": "Poznámka k API klíči."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Aktualizovaný API klíč",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/credit": {
      "get": {
        "tags": [
          "credit"
        ],
        "summary": "Získat aktuální stav kreditu pro API klíč",
        "responses": {
          "200": {
            "description": "Informace o stavu kreditu",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": true
                    },
                    "credit": {
                      "type": "object",
                      "description": "Informace o stavu kreditu.",
                      "properties": {
                        "credit_czk": {
                          "type": "number",
                          "description": "Stav kreditu v CZK."
                        },
                        "credit_eur": {
                          "type": "number",
                          "description": "Stav kreditu v EUR."
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Špatný požadavek",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": false
                    },
                    "message": {
                      "type": "string",
                      "description": "Chybová zpráva.",
                      "example": "Nepodařilo se načíst stav kreditu"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/message": {
      "get": {
        "tags": [
          "status"
        ],
        "summary": "Přečíst stav odeslané zprávy",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "description": "ID zprávy",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Informace o zprávě",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu."
                    },
                    "message": {
                      "type": "object",
                      "description": "Zpráva.",
                      "properties": {
                        "request_id": {
                          "type": "string",
                          "description": "ID požadavku."
                        },
                        "status_code": {
                          "type": "string",
                          "description": "Stavový kód zprávy."
                        },
                        "delivery_code": {
                          "type": "string",
                          "description": "Stavová zpráva doručení."
                        },
                        "tag": {
                          "type": "string",
                          "description": "Tag zprávy."
                        },
                        "ts_sent": {
                          "type": "integer",
                          "description": "Časové razítko odeslání zprávy."
                        },
                        "ts_delivered": {
                          "type": "integer",
                          "description": "Časové razítko doručení zprávy."
                        },
                        "ts_created": {
                          "type": "integer",
                          "description": "Časové razítko vytvoření zprávy."
                        },
                        "body": {
                          "type": "string",
                          "description": "Zpráva."
                        },
                        "flow": {
                          "type": "string",
                          "description": "Tok zprávy."
                        },
                        "price": {
                          "type": "object",
                          "description": "Cena zprávy.",
                          "properties": {
                            "price_czk": {
                              "type": "number",
                              "description": "Cena v CZK."
                            },
                            "price_eur": {
                              "type": "number",
                              "description": "Cena v EUR."
                            },
                            "mcc": {
                              "type": "string",
                              "description": "MCC zprávy."
                            },
                            "mnc": {
                              "type": "string",
                              "description": "MNC zprávy."
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Špatný požadavek",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": false
                    },
                    "message": {
                      "type": "string",
                      "description": "Chybová zpráva.",
                      "example": "Registrace na WhatsApp se nezdařila"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/messages": {
      "get": {
        "tags": [
          "status"
        ],
        "summary": "Přečíst odeslané zprávy",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "Datum ve formátu RRRR-MM-DD",
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2025-01-01"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Informace o zprávě",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": true
                    },
                    "messages": {
                      "type": "array",
                      "description": "Pole zpráv.",
                      "items": {
                        "type": "object",
                        "properties": {
                          "message_id": {
                            "type": "string",
                            "description": "ID zprávy."
                          },
                          "message_parts": {
                            "type": "number",
                            "description": "Počet částí zprávy."
                          },
                          "ts_sent": {
                            "type": "integer",
                            "description": "Časové razítko odeslání zprávy."
                          },
                          "ts_delivered": {
                            "type": "integer",
                            "description": "Časové razítko doručení zprávy."
                          },
                          "sent": {
                            "type": "integer",
                            "description": "Počet odeslaných zpráv."
                          },
                          "delivered": {
                            "type": "integer",
                            "description": "Počet doručených zpráv."
                          },
                          "nondelivered": {
                            "type": "integer",
                            "description": "Počet nedoručených zpráv."
                          },
                          "body": {
                            "type": "string",
                            "description": "Tělo zprávy."
                          },
                          "sender": {
                            "type": "string",
                            "description": "Odesílatel."
                          },
                          "to": {
                            "type": "string",
                            "description": "Příjemce."
                          },
                          "flow": {
                            "type": "string",
                            "description": "Definice toku. Obvykle \"whatsapp\" nebo \"sms\" atd."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Špatný požadavek",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": false
                    },
                    "message": {
                      "type": "string",
                      "description": "Chybová zpráva.",
                      "example": "Registrace na WhatsApp se nezdařila"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/requests": {
      "get": {
        "tags": [
          "status"
        ],
        "summary": "Přečíst odeslané požadavky",
        "parameters": [
          {
            "name": "dates",
            "in": "query",
            "required": true,
            "description": "Data ve formátu RRRR-MM-DD oddělená čárkou",
            "schema": {
              "type": "string",
              "example": "2025-01-01,2025-01-02"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Informace o požadavcích",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": true
                    },
                    "requests": {
                      "type": "array",
                      "description": "Pole požadavků.",
                      "items": {
                        "type": "object",
                        "properties": {
                          "date": {
                            "type": "string",
                            "description": "Datum ve formátu RRRR-MM-DD."
                          },
                          "stats": {
                            "type": "object",
                            "description": "Statistiky pro požadavek.",
                            "properties": {
                              "count_delivered": {
                                "type": "integer",
                                "description": "Počet doručených zpráv."
                              },
                              "count_nondelivered": {
                                "type": "integer",
                                "description": "Počet nedoručených zpráv."
                              },
                              "count_sent": {
                                "type": "integer",
                                "description": "Počet odeslaných zpráv."
                              },
                              "count_notsent": {
                                "type": "integer",
                                "description": "Počet neodeslaných zpráv."
                              },
                              "msg_sent": {
                                "type": "integer",
                                "description": "Počet odeslaných zpráv."
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Špatný požadavek",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "description": "Stav úspěchu.",
                      "example": false
                    },
                    "message": {
                      "type": "string",
                      "description": "Chybová zpráva.",
                      "example": "Registrace na WhatsApp se nezdařila"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/inbox": {
      "get": {
        "tags": [
          "inbox"
        ],
        "summary": "Get inbox messages",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "Date in format YYYY-MM-DD",
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2025-01-01"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Inbox messages",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean",
                      "example": true
                    },
                    "messages": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Message ID."
                          },
                          "from": {
                            "type": "string",
                            "description": "Sender."
                          },
                          "to": {
                            "type": "string",
                            "description": "Recipient."
                          },
                          "body": {
                            "type": "string",
                            "description": "Message body."
                          },
                          "ts_received": {
                            "type": "integer",
                            "description": "Timestamp of the message creation."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "api",
      "x-displayName": "API klíč",
      "description": "Pro správu API klíčů použijte následující koncové body.\n"
    },
    {
      "name": "status",
      "x-displayName": "Stav",
      "description": "Pro čtení stavu odeslaných zpráv použijte následující koncové body.\n"
    },
    {
      "name": "inbox",
      "x-displayName": "Inbox",
      "description": "For reading inbox messages use the following endpoints.\n"
    },
    {
      "name": "credit",
      "x-displayName": "Credit",
      "description": "For reading credit balance or pricelist info use the following endpoints.\n"
    }
  ]
}