{
  "openapi": "3.1.0",
  "info": {
    "title": "vybeflow API — contact",
    "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/user/users": {
      "get": {
        "operationId": "contact.list",
        "summary": "Daftar kontak pelanggan milik tenant.",
        "tags": [
          "contact"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "contact.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": {
                          "_id": {},
                          "name": {},
                          "msisdn": {},
                          "email": {},
                          "tags": {},
                          "createdAt": {}
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `contact.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"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "contact.create",
        "summary": "Tambah satu kontak baru.",
        "tags": [
          "contact"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "contact.manage",
        "x-vybeflow-risk": "confirm",
        "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 `contact.manage`"
          },
          "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"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "msisdn"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "msisdn": {
                    "type": "string",
                    "description": "format 62xxxxxxxxxx"
                  },
                  "email": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/user/users/{id}": {
      "put": {
        "operationId": "contact.update",
        "summary": "Ubah satu kontak.",
        "tags": [
          "contact"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "contact.manage",
        "x-vybeflow-risk": "confirm",
        "parameters": [
          {
            "name": "id",
            "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": {}
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `contact.manage`"
          },
          "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"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "msisdn": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "contact.delete",
        "summary": "Hapus satu kontak. Tidak bisa dibatalkan.",
        "tags": [
          "contact"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "contact.delete",
        "x-vybeflow-risk": "destructive",
        "parameters": [
          {
            "name": "id",
            "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": {}
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `contact.delete`"
          },
          "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"
                }
              }
            }
          }
        },
        "description": "Kontak yang dihapus tidak dapat dikembalikan; riwayat percakapannya tetap ada."
      }
    },
    "/api/user/users/import": {
      "post": {
        "operationId": "contact.import",
        "summary": "Impor banyak kontak sekaligus.",
        "tags": [
          "contact"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "contact.manage",
        "x-vybeflow-risk": "confirm",
        "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 `contact.manage`"
          },
          "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"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "users"
                ],
                "properties": {
                  "users": {
                    "type": "array",
                    "description": "array objek {name, msisdn, email}"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/user/users/campaign/{campaignID}": {
      "get": {
        "operationId": "contact.byCampaign",
        "summary": "Kontak yang termasuk dalam satu kampanye.",
        "tags": [
          "contact"
        ],
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "x-vybeflow-scope": "contact.read",
        "x-vybeflow-risk": "safe",
        "parameters": [
          {
            "name": "campaignID",
            "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": {
                          "_id": {},
                          "name": {},
                          "msisdn": {},
                          "email": {}
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "API key tidak berlaku, dicabut, atau kedaluwarsa"
          },
          "403": {
            "description": "Kunci tidak mencakup `contact.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"
                }
              }
            }
          }
        }
      }
    }
  }
}
