{
  "openapi": "3.1.0",
  "info": {
    "title": "Partner API Hanshop",
    "version": "1.0.0",
    "description": "API server-to-server untuk saldo, katalog, transaksi, dan webhook. Mode ditentukan oleh API key. Gunakan kredensial TEST untuk pengujian dan LIVE untuk transaksi saldo nyata. Simpan api_secret pada backend. Semua contoh merupakan data ilustrasi."
  },
  "servers": [
    {
      "url": "https://api2.hansdigi.biz.id/api/v1",
      "description": "Origin Partner API Hanshop untuk TEST dan LIVE."
    }
  ],
  "externalDocs": {
    "description": "Panduan publik Partner API Hanshop",
    "url": "https://docs.hansdigi.biz.id/"
  },
  "security": [
    {
      "ApiKey": [],
      "Timestamp": [],
      "Nonce": [],
      "Signature": []
    }
  ],
  "tags": [
    {
      "name": "Saldo"
    },
    {
      "name": "Katalog"
    },
    {
      "name": "Transaksi"
    },
    {
      "name": "Webhook"
    }
  ],
  "paths": {
    "/balance": {
      "get": {
        "operationId": "getBalance",
        "tags": [
          "Saldo"
        ],
        "summary": "Cek saldo partner",
        "description": "Mengembalikan saldo rupiah, tier, dan mode kredensial. Saldo TEST terpisah dari saldo LIVE.",
        "x-hanshop-scope": "balance:read",
        "responses": {
          "200": {
            "description": "Saldo partner berhasil dimuat",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Balance"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Saldo partner berhasil dimuat",
                  "data": {
                    "balance": 100000,
                    "currency": "IDR",
                    "tier": "REGULAR",
                    "environment": "test"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/products": {
      "get": {
        "operationId": "listProducts",
        "tags": [
          "Katalog"
        ],
        "summary": "Lihat katalog",
        "description": "Membaca snapshot produk. Filter layanan, kategori, dan pencarian dapat digabungkan. Gunakan filter yang sama saat meneruskan next_cursor sebagai cursor. Terapkan cache dan ikuti batas permintaan.",
        "x-hanshop-scope": "catalog:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Cursor halaman berikutnya dari next_cursor."
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Cari kode atau nama produk."
          },
          {
            "name": "service_code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Filter kode layanan, misalnya PULSA."
          },
          {
            "name": "category_code",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 100
            },
            "description": "Filter kode kategori, misalnya AXIS."
          }
        ],
        "responses": {
          "200": {
            "description": "Katalog partner berhasil dimuat",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Catalog"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Katalog partner berhasil dimuat",
                  "data": {
                    "items": [
                      {
                        "code": "AX10",
                        "name": "Axiata 10.000",
                        "category_code": "AXIS",
                        "category_name": "AXIS",
                        "service_code": "PULSA",
                        "price": 12000,
                        "availability": "AVAILABLE",
                        "updated_at": "2026-11-30T03:20:00.000Z"
                      }
                    ],
                    "next_cursor": null,
                    "has_more": false
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/products/{code}": {
      "get": {
        "operationId": "getProduct",
        "tags": [
          "Katalog"
        ],
        "summary": "Lihat detail produk",
        "description": "Mengembalikan harga sesuai tier dan status ketersediaan saat ini.",
        "x-hanshop-scope": "catalog:read",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Kode produk dari katalog."
          }
        ],
        "responses": {
          "200": {
            "description": "Produk berhasil dimuat",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Product"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Produk berhasil dimuat",
                  "data": {
                    "code": "AX10",
                    "name": "Axiata 10.000",
                    "category_code": "AXIS",
                    "category_name": "AXIS",
                    "service_code": "PULSA",
                    "price": 12000,
                    "availability": "AVAILABLE",
                    "updated_at": "2026-11-30T03:20:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/transactions": {
      "post": {
        "operationId": "createTransaction",
        "tags": [
          "Transaksi"
        ],
        "summary": "Buat transaksi",
        "description": "Pembayaran menggunakan saldo partner. Gunakan external_id unik. Jika header Idempotency-Key tidak dikirim, server menurunkannya dari external_id. HTTP 202 berarti pesanan diterima. Cek transaction_status untuk hasil. Pesanan premium tetap memerlukan destination.",
        "x-hanshop-scope": "transaction:create",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9._:-]{8,128}$"
            },
            "description": "Header lama. Jika dikirim, gunakan nilai yang sama saat mengulang pesanan. Jika header tidak dikirim, identitas pengulangan berasal dari external_id."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransactionInput"
              },
              "example": {
                "external_id": "INV-20261130-0001",
                "product_code": "AX10",
                "destination": "08123456789",
                "max_price": 12000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transaksi idempotent ditemukan",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "Idempotent-Replayed": {
                "description": "Permintaan ini mengembalikan pesanan lama.",
                "schema": {
                  "type": "string",
                  "const": "true"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Transaction"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Transaksi idempotent ditemukan",
                  "data": {
                    "request_id": "req_contoh123",
                    "transaction_id": "trx_contoh123",
                    "external_id": "INV-20261130-0001",
                    "transaction_status": "PENDING",
                    "product_code": "AX10",
                    "product_name": "Axiata 10.000",
                    "destination": "08123456789",
                    "price": 12000,
                    "sn": null,
                    "detail_akun": null,
                    "failure_code": null,
                    "created_at": "2026-11-30T03:20:00.000Z",
                    "updated_at": "2026-11-30T03:20:00.000Z",
                    "completed_at": null,
                    "status_message": "Pesanan diterima dan menunggu diproses."
                  }
                }
              }
            }
          },
          "202": {
            "description": "Transaksi diterima dan sedang diproses",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Transaction"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Transaksi diterima dan sedang diproses",
                  "data": {
                    "request_id": "req_contoh123",
                    "transaction_id": "trx_contoh123",
                    "external_id": "INV-20261130-0001",
                    "transaction_status": "PENDING",
                    "product_code": "AX10",
                    "product_name": "Axiata 10.000",
                    "destination": "08123456789",
                    "price": 12000,
                    "sn": null,
                    "detail_akun": null,
                    "failure_code": null,
                    "created_at": "2026-11-30T03:20:00.000Z",
                    "updated_at": "2026-11-30T03:20:00.000Z",
                    "completed_at": null,
                    "status_message": "Pesanan diterima dan menunggu diproses."
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/TransactionConflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/transactions/{transactionId}": {
      "get": {
        "operationId": "getTransaction",
        "tags": [
          "Transaksi"
        ],
        "summary": "Cek status menurut ID transaksi",
        "description": "Gunakan transaction_id dari respons pembuatan pesanan.",
        "x-hanshop-scope": "transaction:read",
        "parameters": [
          {
            "name": "transactionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID transaksi dari Hanshop."
          }
        ],
        "responses": {
          "200": {
            "description": "Status transaksi berhasil dimuat",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Transaction"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Status transaksi berhasil dimuat",
                  "data": {
                    "request_id": "req_contoh123",
                    "transaction_id": "trx_contoh123",
                    "external_id": "INV-20261130-0001",
                    "transaction_status": "PENDING",
                    "product_code": "AX10",
                    "product_name": "Axiata 10.000",
                    "destination": "08123456789",
                    "price": 12000,
                    "sn": null,
                    "detail_akun": null,
                    "failure_code": null,
                    "created_at": "2026-11-30T03:20:00.000Z",
                    "updated_at": "2026-11-30T03:20:00.000Z",
                    "completed_at": null,
                    "status_message": "Pesanan diterima dan menunggu diproses."
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/transactions/external/{externalId}": {
      "get": {
        "operationId": "getTransactionByExternalId",
        "tags": [
          "Transaksi"
        ],
        "summary": "Cek status menurut referensi aplikasi",
        "description": "Cari pesanan dengan external_id ketika respons awal terlambat atau terputus.",
        "x-hanshop-scope": "transaction:read",
        "parameters": [
          {
            "name": "externalId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Referensi pesanan dari aplikasi Anda."
          }
        ],
        "responses": {
          "200": {
            "description": "Status transaksi berhasil dimuat",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Transaction"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Status transaksi berhasil dimuat",
                  "data": {
                    "request_id": "req_contoh123",
                    "transaction_id": "trx_contoh123",
                    "external_id": "INV-20261130-0001",
                    "transaction_status": "PENDING",
                    "product_code": "AX10",
                    "product_name": "Axiata 10.000",
                    "destination": "08123456789",
                    "price": 12000,
                    "sn": null,
                    "detail_akun": null,
                    "failure_code": null,
                    "created_at": "2026-11-30T03:20:00.000Z",
                    "updated_at": "2026-11-30T03:20:00.000Z",
                    "completed_at": null,
                    "status_message": "Pesanan diterima dan menunggu diproses."
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/webhooks": {
      "get": {
        "operationId": "listWebhooks",
        "tags": [
          "Webhook"
        ],
        "summary": "Lihat webhook",
        "description": "Menampilkan tujuan webhook milik partner. Secret ditampilkan sekali pada saat membuat webhook.",
        "x-hanshop-scope": "webhook:read",
        "responses": {
          "200": {
            "description": "Webhook berhasil dimuat",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Webhook"
                      }
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Webhook berhasil dimuat",
                  "data": [
                    {
                      "id_webhook": 12,
                      "id_partner": 8,
                      "url": "https://aplikasi.example/webhooks/hanshop",
                      "events": [
                        "transaction.success",
                        "transaction.failed"
                      ],
                      "status": "ACTIVE",
                      "created_at": "2026-11-30T03:20:00.000Z",
                      "updated_at": "2026-11-30T03:20:00.000Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "post": {
        "operationId": "createWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Buat webhook",
        "description": "Gunakan URL publik HTTPS dan simpan webhook_secret saat diperoleh. Maksimal tiga webhook aktif per partner.",
        "x-hanshop-scope": "webhook:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookInput"
              },
              "example": {
                "url": "https://aplikasi.example/webhooks/hanshop",
                "events": [
                  "transaction.success",
                  "transaction.failed"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook berhasil dibuat. Simpan secret sekarang.",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/WebhookCreated"
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Webhook berhasil dibuat. Simpan secret sekarang.",
                  "data": {
                    "id_webhook": 12,
                    "url": "https://aplikasi.example/webhooks/hanshop",
                    "events": [
                      "transaction.success",
                      "transaction.failed"
                    ],
                    "webhook_secret": "RAHASIA_WEBHOOK_CONTOH",
                    "shown_once": true
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/WebhookConflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/webhooks/{webhookId}": {
      "patch": {
        "operationId": "updateWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Perbarui webhook",
        "description": "Perbarui langganan event atau status webhook.",
        "x-hanshop-scope": "webhook:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Kirim minimal satu kolom antara events dan status. Buat webhook baru jika URL tujuan berubah.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookUpdate"
              },
              "example": {
                "events": [
                  "transaction.success",
                  "transaction.failed"
                ],
                "status": "ACTIVE"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Webhook berhasil diperbarui",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "updated"
                      ],
                      "properties": {
                        "updated": {
                          "const": true
                        }
                      }
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Webhook berhasil diperbarui",
                  "data": {
                    "updated": true
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/WebhookConflict"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "operationId": "disableWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Nonaktifkan webhook",
        "description": "Mengubah status webhook menjadi DISABLED.",
        "x-hanshop-scope": "webhook:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook berhasil dinonaktifkan",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "disabled"
                      ],
                      "properties": {
                        "disabled": {
                          "const": true
                        }
                      }
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Webhook berhasil dinonaktifkan",
                  "data": {
                    "disabled": true
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/webhooks/{webhookId}/test": {
      "post": {
        "operationId": "testWebhook",
        "tags": [
          "Webhook"
        ],
        "summary": "Kirim event uji",
        "description": "Antrekan webhook.test ke tujuan aktif. Periksa riwayat pengiriman menggunakan event_id.",
        "x-hanshop-scope": "webhook:write",
        "parameters": [
          {
            "$ref": "#/components/parameters/WebhookId"
          }
        ],
        "responses": {
          "202": {
            "description": "Test webhook masuk antrean",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "event_id",
                        "queued"
                      ],
                      "properties": {
                        "event_id": {
                          "type": "string"
                        },
                        "queued": {
                          "const": true
                        }
                      }
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Test webhook masuk antrean",
                  "data": {
                    "event_id": "evt_contoh34",
                    "queued": true
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/webhook-deliveries": {
      "get": {
        "operationId": "listWebhookDeliveries",
        "tags": [
          "Webhook"
        ],
        "summary": "Lihat riwayat pengiriman",
        "description": "Lihat hasil, status HTTP, percobaan, dan jadwal pengiriman ulang terbaru.",
        "x-hanshop-scope": "webhook:read",
        "parameters": [
          {
            "$ref": "#/components/parameters/Limit"
          }
        ],
        "responses": {
          "200": {
            "description": "Riwayat delivery berhasil dimuat",
            "headers": {
              "X-Request-ID": {
                "required": true,
                "schema": {
                  "type": "string"
                },
                "description": "ID permintaan untuk dukungan."
              },
              "X-RateLimit-Limit": {
                "description": "Batas request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Remaining": {
                "description": "Sisa request dalam grup.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              },
              "X-RateLimit-Reset": {
                "description": "Waktu reset dalam detik Unix.",
                "schema": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "message",
                    "data"
                  ],
                  "properties": {
                    "status": {
                      "const": "SUCCESS"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/WebhookDelivery"
                      }
                    }
                  }
                },
                "example": {
                  "status": "SUCCESS",
                  "message": "Riwayat delivery berhasil dimuat",
                  "data": [
                    {
                      "delivery_id": "dlv_contoh12",
                      "event_id": "evt_contoh12",
                      "event_name": "transaction.success",
                      "id_webhook": 12,
                      "attempt_no": 1,
                      "outcome": "DELIVERED",
                      "http_status": 204,
                      "latency_ms": 143,
                      "response_excerpt": null,
                      "error_message": null,
                      "attempted_at": "2026-11-30T03:20:00.000Z",
                      "next_retry_at": null
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/RateLimit"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "webhooks": {
    "hanshopEvent": {
      "post": {
        "operationId": "receiveHanshopEvent",
        "tags": [
          "Webhook"
        ],
        "summary": "Terima event dari Hanshop",
        "description": "Rute ini berada di aplikasi partner. Verifikasi tanda tangan raw body, simpan event_id secara idempoten dan balas 2xx setelah penyimpanan. Pengiriman mengikuti mode tujuan. Retry mempertahankan event_id.",
        "security": [],
        "parameters": [
          {
            "name": "X-Hanshop-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "transaction.created",
                "transaction.processing",
                "transaction.success",
                "transaction.failed",
                "transaction.manual_review",
                "webhook.test"
              ]
            },
            "description": "Nama event."
          },
          {
            "name": "X-Hanshop-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID event pada pengiriman."
          },
          {
            "name": "X-Hanshop-Timestamp",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Waktu Unix detik."
          },
          {
            "name": "X-Hanshop-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "HMAC atas timestamp, tanda titik, dan byte body asli."
          },
          {
            "name": "X-Hanshop-Environment",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "TEST",
                "LIVE"
              ],
              "description": "Mode pengiriman webhook."
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/TransactionEvent"
                  },
                  {
                    "$ref": "#/components/schemas/WebhookTestEvent"
                  }
                ]
              },
              "examples": {
                "transaction": {
                  "value": {
                    "event_id": "evt_contoh12",
                    "event": "transaction.success",
                    "api_version": "v1",
                    "created_at": "2026-11-30T03:20:00.000Z",
                    "data": {
                      "transaction": {
                        "transaction_id": "trx_contoh123",
                        "external_id": "INV-20261130-0001",
                        "transaction_status": "SUCCESS",
                        "product_code": "AX10",
                        "product_name": "Axiata 10.000",
                        "destination": "08123456789",
                        "price": 12000,
                        "sn": "SN-CONTOH-001",
                        "detail_akun": null,
                        "failure_code": null,
                        "created_at": "2026-11-30T03:20:00.000Z",
                        "updated_at": "2026-11-30T03:20:00.000Z",
                        "completed_at": "2026-11-30T03:20:00.000Z"
                      }
                    },
                    "environment": "LIVE"
                  }
                },
                "test": {
                  "value": {
                    "event_id": "evt_contoh34",
                    "event": "webhook.test",
                    "api_version": "v1",
                    "created_at": "2026-11-30T03:20:00.000Z",
                    "data": {
                      "partner_code": "PARTNER-CONTOH",
                      "webhook_id": 12,
                      "message": "Hanshop partner webhook test"
                    },
                    "environment": "TEST"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Payload tidak valid."
          },
          "401": {
            "description": "Signature tidak valid."
          },
          "2XX": {
            "description": "Event diterima."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API key dari portal, berawalan hsp_test_ atau hsp_live_."
      },
      "Timestamp": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Timestamp",
        "description": "Waktu Unix dalam detik, toleransi default 300 detik."
      },
      "Nonce": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Nonce",
        "description": "Nilai unik tiap request, sepanjang 8–128 karakter."
      },
      "Signature": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Signature",
        "description": "sha256=<hex HMAC-SHA256 atas string kanonis>."
      }
    },
    "parameters": {
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 50
        },
        "description": "Jumlah item, 1 hingga 100. Default 50."
      },
      "WebhookId": {
        "name": "webhookId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "integer",
          "minimum": 1
        },
        "description": "ID webhook yang berada pada akun partner."
      }
    },
    "schemas": {
      "Balance": {
        "type": "object",
        "required": [
          "balance",
          "currency",
          "tier",
          "environment"
        ],
        "properties": {
          "balance": {
            "type": "integer"
          },
          "currency": {
            "const": "IDR"
          },
          "tier": {
            "type": "string",
            "enum": [
              "REGULAR",
              "VIP"
            ]
          },
          "environment": {
            "type": "string",
            "enum": [
              "test",
              "live"
            ]
          }
        }
      },
      "Product": {
        "type": "object",
        "required": [
          "code",
          "name",
          "category_code",
          "category_name",
          "service_code",
          "price",
          "availability",
          "updated_at"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "category_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "category_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "service_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": "integer"
          },
          "availability": {
            "type": "string",
            "enum": [
              "AVAILABLE",
              "UNAVAILABLE"
            ],
            "description": "Apakah produk bisa dipesan saat katalog dibaca. Produk dapat UNAVAILABLE meski stok tercatat, misalnya ketika semua jalur ditutup atau terganggu."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "fulfillment_mode": {
            "type": "string",
            "enum": [
              "MANUAL"
            ],
            "description": "Pesanan ditangani admin jika properti ini ada."
          },
          "maintenance_scope": {
            "type": "string",
            "enum": ["SERVICE", "CATEGORY", "PRODUCT"],
            "description": "Tingkat penutupan pemesanan jika admin menandai katalog sedang gangguan. Saat field ini muncul, availability bernilai UNAVAILABLE."
          },
          "stock_label": {
            "type": "string",
            "example": "Stok 7",
            "description": "Keterangan stok produk premium atau produk yang diproses manual. Contoh Stok 7, Stok habis, Stok tersedia, Stok belum diketahui, atau Tanyakan admin. Gunakan availability untuk memutuskan apakah produk bisa dipesan."
          }
        }
      },
      "Catalog": {
        "type": "object",
        "required": [
          "items",
          "next_cursor",
          "has_more"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Product"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          },
          "has_more": {
            "type": "boolean"
          }
        }
      },
      "TransactionInput": {
        "type": "object",
        "required": [
          "external_id",
          "product_code",
          "destination"
        ],
        "properties": {
          "external_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100,
            "description": "Referensi unik pesanan yang dibuat aplikasi Anda."
          },
          "product_code": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Kode produk dari katalog atau kode simulasi khusus TEST."
          },
          "destination": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Tujuan sesuai produk. Untuk produk premium di mode TEST, gunakan tujuan contoh yang sesuai dengan skenario."
          },
          "max_price": {
            "type": "integer",
            "minimum": 1,
            "description": "Batas harga jual dalam rupiah bulat positif. Jika harga produk melampauinya, pesanan ditolak."
          }
        }
      },
      "Transaction": {
        "allOf": [
          {
            "$ref": "#/components/schemas/TransactionFields"
          },
          {
            "type": "object",
            "properties": {
              "request_id": {
                "type": "string"
              },
              "status_message": {
                "type": "string",
                "description": "Pesan untuk tampilan. Gunakan transaction_status dan failure_code untuk logika aplikasi."
              }
            }
          }
        ]
      },
      "TransactionFields": {
        "type": "object",
        "required": [
          "transaction_id",
          "external_id",
          "transaction_status",
          "product_code",
          "product_name",
          "destination",
          "price",
          "sn",
          "detail_akun",
          "failure_code",
          "created_at",
          "updated_at",
          "completed_at"
        ],
        "properties": {
          "transaction_id": {
            "type": "string"
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "transaction_status": {
            "type": "string",
            "enum": [
              "PENDING",
              "PROCESSING",
              "SUCCESS",
              "FAILED",
              "MANUAL_REVIEW"
            ]
          },
          "product_code": {
            "type": "string"
          },
          "product_name": {
            "type": [
              "string",
              "null"
            ]
          },
          "destination": {
            "type": [
              "string",
              "null"
            ]
          },
          "price": {
            "type": "integer"
          },
          "sn": {
            "type": [
              "string",
              "null"
            ]
          },
          "detail_akun": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {
              "type": "string"
            }
          },
          "failure_code": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "fulfillment_mode": {
            "type": "string",
            "enum": [
              "MANUAL"
            ],
            "description": "Pesanan ditangani admin jika properti ini ada."
          }
        }
      },
      "WebhookInput": {
        "type": "object",
        "required": [
          "url",
          "events"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 1000,
            "description": "URL publik HTTPS yang menerima POST tanpa redirect."
          },
          "events": {
            "type": "array",
            "description": "Daftar event yang ingin diterima. Pilih minimal satu.",
            "items": {
              "type": "string",
              "enum": [
                "transaction.created",
                "transaction.processing",
                "transaction.success",
                "transaction.failed",
                "transaction.manual_review",
                "webhook.test"
              ]
            },
            "minItems": 1
          }
        }
      },
      "WebhookUpdate": {
        "type": "object",
        "anyOf": [
          { "required": ["events"] },
          { "required": ["status"] }
        ],
        "properties": {
          "events": {
            "type": "array",
            "description": "Ganti seluruh daftar event. Pilih minimal satu jika kolom dikirim.",
            "items": {
              "type": "string",
              "enum": [
                "transaction.created",
                "transaction.processing",
                "transaction.success",
                "transaction.failed",
                "transaction.manual_review",
                "webhook.test"
              ]
            },
            "minItems": 1
          },
          "status": {
            "type": "string",
            "description": "Aktifkan atau nonaktifkan pengiriman webhook.",
            "enum": [
              "ACTIVE",
              "DISABLED"
            ]
          }
        }
      },
      "Webhook": {
        "type": "object",
        "required": [
          "id_webhook",
          "id_partner",
          "url",
          "events",
          "status",
          "created_at",
          "updated_at",
          "environment"
        ],
        "properties": {
          "id_webhook": {
            "type": "integer"
          },
          "id_partner": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 1000
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "transaction.created",
                "transaction.processing",
                "transaction.success",
                "transaction.failed",
                "transaction.manual_review",
                "webhook.test"
              ]
            },
            "minItems": 1
          },
          "status": {
            "type": "string",
            "enum": [
              "ACTIVE",
              "DISABLED"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "environment": {
            "type": "string",
            "enum": [
              "TEST",
              "LIVE"
            ],
            "description": "Mode pengiriman webhook."
          }
        }
      },
      "WebhookCreated": {
        "type": "object",
        "required": [
          "id_webhook",
          "url",
          "events",
          "webhook_secret",
          "shown_once",
          "environment"
        ],
        "properties": {
          "id_webhook": {
            "type": "integer"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 1000
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "transaction.created",
                "transaction.processing",
                "transaction.success",
                "transaction.failed",
                "transaction.manual_review",
                "webhook.test"
              ]
            },
            "minItems": 1
          },
          "webhook_secret": {
            "type": "string"
          },
          "shown_once": {
            "const": true
          },
          "environment": {
            "type": "string",
            "enum": [
              "TEST",
              "LIVE"
            ],
            "description": "Mode pengiriman webhook."
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "required": [
          "delivery_id",
          "event_id",
          "event_name",
          "id_webhook",
          "attempt_no",
          "outcome",
          "http_status",
          "latency_ms",
          "response_excerpt",
          "error_message",
          "attempted_at",
          "next_retry_at",
          "environment"
        ],
        "properties": {
          "delivery_id": {
            "type": "string"
          },
          "event_id": {
            "type": "string"
          },
          "event_name": {
            "type": "string",
            "enum": [
              "transaction.created",
              "transaction.processing",
              "transaction.success",
              "transaction.failed",
              "transaction.manual_review",
              "webhook.test"
            ]
          },
          "id_webhook": {
            "type": "integer"
          },
          "attempt_no": {
            "type": "integer"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "DELIVERED",
              "FAILED"
            ]
          },
          "http_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "latency_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "response_excerpt": {
            "type": [
              "string",
              "null"
            ]
          },
          "error_message": {
            "type": [
              "string",
              "null"
            ]
          },
          "attempted_at": {
            "type": "string",
            "format": "date-time"
          },
          "next_retry_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "environment": {
            "type": "string",
            "enum": [
              "TEST",
              "LIVE"
            ],
            "description": "Mode pengiriman webhook."
          },
          "retry_available": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "1 jika tujuan aktif dan percobaan otomatis telah habis."
          }
        }
      },
      "TransactionEvent": {
        "type": "object",
        "required": [
          "event_id",
          "api_version",
          "created_at",
          "event",
          "data",
          "environment"
        ],
        "properties": {
          "event_id": {
            "type": "string"
          },
          "api_version": {
            "const": "v1"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "event": {
            "type": "string",
            "enum": [
              "transaction.created",
              "transaction.processing",
              "transaction.success",
              "transaction.failed",
              "transaction.manual_review"
            ]
          },
          "data": {
            "type": "object",
            "required": [
              "transaction"
            ],
            "properties": {
              "transaction": {
                "$ref": "#/components/schemas/TransactionFields"
              }
            }
          },
          "environment": {
            "type": "string",
            "enum": [
              "TEST",
              "LIVE"
            ],
            "description": "Mode pengiriman webhook."
          }
        }
      },
      "WebhookTestEvent": {
        "type": "object",
        "required": [
          "event_id",
          "api_version",
          "created_at",
          "event",
          "data",
          "environment"
        ],
        "properties": {
          "event_id": {
            "type": "string"
          },
          "api_version": {
            "const": "v1"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "event": {
            "const": "webhook.test"
          },
          "data": {
            "type": "object",
            "required": [
              "partner_code",
              "webhook_id",
              "message"
            ],
            "properties": {
              "partner_code": {
                "type": "string"
              },
              "webhook_id": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "environment": {
            "type": "string",
            "enum": [
              "TEST",
              "LIVE"
            ],
            "description": "Mode pengiriman webhook."
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "status",
          "message",
          "data"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "FAILED",
              "ERROR"
            ]
          },
          "message": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "required": [
              "code",
              "request_id",
              "retryable"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "request_id": {
                "type": "string"
              },
              "retryable": {
                "type": "boolean"
              },
              "hint": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Permintaan atau header tidak valid.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "FAILED",
              "message": "Permintaan atau header tidak valid.",
              "data": {
                "code": "VALIDATION_ERROR",
                "request_id": "req_contoh123",
                "retryable": false
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Autentikasi ditolak.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "FAILED",
              "message": "Autentikasi ditolak.",
              "data": {
                "code": "SIGNATURE_INVALID",
                "request_id": "req_contoh123",
                "retryable": false
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "Akses tidak diizinkan.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "FAILED",
              "message": "Akses tidak diizinkan.",
              "data": {
                "code": "IP_NOT_ALLOWED",
                "request_id": "req_contoh123",
                "retryable": false
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Referensi tidak ditemukan atau produk tidak tersedia.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "FAILED",
              "message": "Referensi tidak ditemukan atau produk tidak tersedia.",
              "data": {
                "code": "TRANSACTION_NOT_FOUND",
                "request_id": "req_contoh123",
                "retryable": false
              }
            }
          }
        }
      },
      "TransactionConflict": {
        "description": "Permintaan berkonflik dengan harga, saldo, atau referensi transaksi.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "FAILED",
              "message": "Permintaan berkonflik dengan harga, saldo, atau referensi transaksi.",
              "data": {
                "code": "IDEMPOTENCY_CONFLICT",
                "request_id": "req_contoh123",
                "retryable": false
              }
            }
          }
        }
      },
      "WebhookConflict": {
        "description": "Batas webhook aktif tercapai.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "FAILED",
              "message": "Batas webhook aktif tercapai.",
              "data": {
                "code": "WEBHOOK_LIMIT_REACHED",
                "request_id": "req_contoh123",
                "retryable": false
              }
            }
          }
        }
      },
      "RateLimit": {
        "description": "Batas permintaan terlampaui.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          },
          "X-RateLimit-Limit": {
            "description": "Batas request dalam grup.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          "X-RateLimit-Remaining": {
            "description": "Sisa request dalam grup.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          "X-RateLimit-Reset": {
            "description": "Waktu reset dalam detik Unix.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          "Retry-After": {
            "description": "Lama tunggu dalam detik, jika tersedia.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "FAILED",
              "message": "Batas permintaan terlampaui.",
              "data": {
                "code": "RATE_LIMITED",
                "request_id": "req_contoh123",
                "retryable": true
              }
            }
          }
        }
      },
      "InternalError": {
        "description": "Server gagal memproses permintaan.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "ERROR",
              "message": "Server gagal memproses permintaan.",
              "data": {
                "code": "INTERNAL_ERROR",
                "request_id": "req_contoh123",
                "retryable": false
              }
            }
          }
        }
      },
      "Unavailable": {
        "description": "Layanan sementara tidak tersedia.",
        "headers": {
          "X-Request-ID": {
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ID permintaan untuk dukungan."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "status": "ERROR",
              "message": "Layanan sementara tidak tersedia.",
              "data": {
                "code": "SERVICE_UNAVAILABLE",
                "request_id": "req_contoh123",
                "retryable": true
              }
            }
          }
        }
      }
    }
  }
}
