{
  "openapi": "3.1.0",
  "info": {
    "title": "vybeflow API — billing",
    "version": "0.1.0",
    "description": "Setiap endpoint memerlukan API key tenant (Pengaturan → API Key di konsol vybeflow) dan hanya berjalan jika kunci itu mencakup izin yang tercantum pada x-vybeflow-scope. Permintaan dibatasi per kunci dan per tenant; setiap jawaban membawa header RateLimit-*, dan penolakan 429 membawa Retry-After."
  },
  "servers": [
    {
      "url": "https://vybeflow.vyber.id"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Kunci berformat vf_live_… Boleh juga dikirim sebagai Authorization: Bearer."
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "tags": [
    {
      "name": "contact"
    },
    {
      "name": "campaign"
    },
    {
      "name": "inbox"
    },
    {
      "name": "channel"
    },
    {
      "name": "product"
    },
    {
      "name": "billing"
    },
    {
      "name": "tenant"
    }
  ],
  "paths": {
    "/api/payment/v1/payment/history": {
      "get": {
        "operationId": "billing.history",
        "summary": "Riwayat transaksi pembayaran tenant.",
        "tags": [
          "billing"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "billing.read",
        "x-vybeflow-risk": "safe",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer"
                    },
                    "errorCode": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "orderID": {},
                          "amount": {},
                          "status": {},
                          "productName": {},
                          "createdAt": {},
                          "paidAt": {}
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `billing.read`"
          },
          "429": {
            "description": "Batas permintaan terlampaui. Tunggu selama `Retry-After` detik lalu ulangi permintaan yang sama.",
            "headers": {
              "Retry-After": {
                "description": "Detik sampai permintaan ini bisa berhasil.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Permintaan per menit untuk kunci ini.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Sisa token pada bucket.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Detik sampai bucket penuh kembali.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/api/payment/v1/payment/history/{orderID}": {
      "get": {
        "operationId": "billing.transaction",
        "summary": "Satu transaksi berdasarkan orderID.",
        "tags": [
          "billing"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "billing.read",
        "x-vybeflow-risk": "safe",
        "parameters": [
          {
            "name": "orderID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer"
                    },
                    "errorCode": {
                      "type": "integer"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "orderID": {},
                          "amount": {},
                          "status": {},
                          "productName": {},
                          "createdAt": {},
                          "paidAt": {}
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `billing.read`"
          },
          "429": {
            "description": "Batas permintaan terlampaui. Tunggu selama `Retry-After` detik lalu ulangi permintaan yang sama.",
            "headers": {
              "Retry-After": {
                "description": "Detik sampai permintaan ini bisa berhasil.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Permintaan per menit untuk kunci ini.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Sisa token pada bucket.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Detik sampai bucket penuh kembali.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/api/user/v1/dashboard/subscription": {
      "get": {
        "operationId": "billing.subscription",
        "summary": "Paket langganan yang sedang aktif.",
        "tags": [
          "billing"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "billing.read",
        "x-vybeflow-risk": "safe",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer"
                    },
                    "errorCode": {
                      "type": "integer"
                    },
                    "data": {}
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `billing.read`"
          },
          "429": {
            "description": "Batas permintaan terlampaui. Tunggu selama `Retry-After` detik lalu ulangi permintaan yang sama.",
            "headers": {
              "Retry-After": {
                "description": "Detik sampai permintaan ini bisa berhasil.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Permintaan per menit untuk kunci ini.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Sisa token pada bucket.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Detik sampai bucket penuh kembali.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/api/ai/v1/quota": {
      "get": {
        "operationId": "billing.quota",
        "summary": "Sisa kuota AI dan pesan untuk tenant ini.",
        "tags": [
          "billing"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "quota.read",
        "x-vybeflow-risk": "safe",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer"
                    },
                    "errorCode": {
                      "type": "integer"
                    },
                    "data": {}
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `quota.read`"
          },
          "429": {
            "description": "Batas permintaan terlampaui. Tunggu selama `Retry-After` detik lalu ulangi permintaan yang sama.",
            "headers": {
              "Retry-After": {
                "description": "Detik sampai permintaan ini bisa berhasil.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Permintaan per menit untuk kunci ini.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Sisa token pada bucket.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Detik sampai bucket penuh kembali.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    },
    "/api/ai/v1/usage": {
      "get": {
        "operationId": "billing.usage",
        "summary": "Riwayat pemakaian kuota.",
        "tags": [
          "billing"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "quota.read",
        "x-vybeflow-risk": "safe",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "integer"
                    },
                    "errorCode": {
                      "type": "integer"
                    },
                    "data": {}
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `quota.read`"
          },
          "429": {
            "description": "Batas permintaan terlampaui. Tunggu selama `Retry-After` detik lalu ulangi permintaan yang sama.",
            "headers": {
              "Retry-After": {
                "description": "Detik sampai permintaan ini bisa berhasil.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Permintaan per menit untuk kunci ini.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Sisa token pada bucket.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Detik sampai bucket penuh kembali.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  }
}
