API 使用手冊API manualAPI マニュアル
jt-ipam 的 REST API、phpIPAM 相容層、Graylog 查表與 MCP。以下所有網址請把 https://ipam.example.com 換成你自己的位址。
The jt-ipam REST API, phpIPAM compatibility layer, Graylog lookups and MCP. Replace https://ipam.example.com below with your own address.jt-ipam の REST API、phpIPAM 互換レイヤ、Graylog 用のルックアップ、そして MCP です。以下の URL の https://ipam.example.com は、ご自身のアドレスに置き換えてください。
curl 要加 -k(或把 CA 加進信任庫)。
The API is HTTPS-only. jt-ipam enforces HTTPS and does not serve plain HTTP. If your instance uses a self-signed certificate, add -k to curl (or add the CA to your trust store).API は HTTPS のみです。jt-ipam は HTTPS を強制し、平文の HTTP では応答しません。自己署名証明書を使っている場合は curl に -k を付けてください(または CA を信頼ストアに追加します)。
1認證:API 權杖Auth: API tokens認証:API トークン
外部程式一律用 API 權杖,不要用帳號密碼登入拿 JWT(JWT 只有 15 分鐘、是給網頁前端用的)。 External programs should always use an API token rather than logging in for a JWT (JWTs last 15 minutes and exist for the web UI).外部のプログラムからは必ず API トークンを使ってください。ユーザー名とパスワードでログインして JWT を取得する方法は避けてください(JWT は 15 分で切れ、Web UI のためのものです)。
怎麼取得權杖Getting a tokenトークンの取得
登入 jt-ipam → 右上角使用者選單 → API 權杖 → 新增。填名稱、有效天數(1~365,預設 90)、權限範圍,按儲存。 Sign in to jt-ipam → user menu (top right) → API tokens → Add. Give it a name, a lifetime (1–365 days, default 90) and a scope, then save.jt-ipam にログイン → 右上のユーザーメニュー → API トークン → 追加。名称、有効日数(1~365、既定は 90)、スコープを入力して保存します。
怎麼帶權杖Sending the tokenトークンの送り方
curl -H "Authorization: Bearer jt_prod_xxxxxxxxxxxxxxxx" \
https://ipam.example.com/api/v1/subnets
權杖首碼 jt_ 會讓後端自動辨識為 API 權杖(沒有這個首碼則當成 JWT 解析)。
The jt_ prefix tells the backend this is an API token (without it, the value is parsed as a JWT).先頭の jt_ によって、バックエンドはこれが API トークンだと判断します(この接頭辞が無ければ JWT として解析されます)。
權限範圍(scope)Scopesスコープ
| scopes | 效果Effect効果 |
|---|---|
[] |
不限制 —— 沿用權杖擁有者的權限,可讀可寫。 Unrestricted — inherits the owner's permissions, read and write.制限なし。トークンの所有者の権限をそのまま引き継ぎ、読み書きできます。 |
["read"] |
唯讀 —— GET/HEAD/OPTIONS 可用;POST/PATCH/PUT/DELETE 一律回 403。
Read-only — GET/HEAD/OPTIONS work; POST/PATCH/PUT/DELETE always return 403.読み取り専用。GET/HEAD/OPTIONS は使えます。POST/PATCH/PUT/DELETE は常に 403 を返します。 |
目前只支援這兩種。填其他值(例如 write、subnets:read)建立時就會被拒絕回 422 —— 這是刻意的:不提供無法真正強制執行的權限旋鈕。
These are the only two supported. Any other value (e.g. write, subnets:read) is rejected with 422 at creation — deliberately, so there is no knob that looks like a restriction but isn't enforced.対応しているのはこの二つだけです。それ以外の値(write や subnets:read など)は作成時に 422 で拒否されます。これは意図的な仕様で、実際には強制されない「制限のように見えるつまみ」を用意しないためです。
object_filters 欄位目前保留但不生效,別依賴它。
A token inherits its owner's permissions. A token created by an admin is a full-privilege admin key. To give a third party restricted access: create a low-privilege user, grant it the objects it needs (sections / subnets / devices…) under Admin → Permissions, then sign in as that user to create the token. The object_filters field is reserved but not enforced — do not rely on it.トークンは所有者の権限を引き継ぎます。admin アカウントで作ったトークンは、admin の全権限を持つ鍵そのものです。第三者に限定的なアクセスを渡すには、権限の低いユーザーを別に作り、「管理 → 権限」で必要なオブジェクト(セクション/サブネット/機器など)を許可し、そのアカウントでログインしてトークンを作成してください。object_filters 項目は予約されていますが強制されません。これに依存しないでください。
用 API 管理權杖Managing tokens via the APIAPI からのトークン管理
| 方法Methodメソッド | 路徑Pathパス | 說明Description説明 |
|---|---|---|
| GET | /api/v1/api-tokens |
列出自己的權杖(admin 可加 ?user_id= 看別人的)List your own tokens (admins may add ?user_id=)自分のトークンを一覧(admin は ?user_id= で他人の分も参照可) |
| POST | /api/v1/api-tokens |
建立,回應含一次性明文Create; the response carries the one-time plaintext作成。応答に一度だけの平文が含まれます |
| DELETE | /api/v1/api-tokens/{id} |
撤銷(立即失效,不可復原)Revoke (immediate, irreversible)失効(即時、取り消し不可) |
curl -X POST https://ipam.example.com/api/v1/api-tokens \
-H "Authorization: Bearer <jwt-or-token>" \
-H "Content-Type: application/json" \
-d '{"name":"monitoring","expires_in_days":180,"scopes":["read"]}'
{
"id": "3f1c...", "name": "monitoring",
"token": "jt_prod_XXXXXXXXXXXXXXXXXXXX",
"token_prefix": "jt_prod_", "expires_at": "2027-01-26T00:00:00Z",
"scopes": ["read"]
}
2通用慣例Conventions共通の決まり
- 基底路徑:
/api/v1。所有請求與回應都是 JSON(Content-Type: application/json),除少數明講的 CSV 端點。 Base path:/api/v1. Requests and responses are JSON (Content-Type: application/json), apart from a few explicitly-CSV endpoints.ベースパスは/api/v1です。明示的に CSV と記載された一部を除き、リクエストもレスポンスも JSON(Content-Type: application/json)です。 - 識別碼是 UUID,不是遞增整數。 Identifiers are UUIDs, not incrementing integers.識別子は UUID であり、連番の整数ではありません。
- 時間一律 ISO 8601、UTC(
2026-07-30T12:34:56Z)。 Timestamps are ISO 8601 in UTC (2026-07-30T12:34:56Z).時刻はすべて ISO 8601 の UTC です(2026-07-30T12:34:56Z)。 - 未知欄位會被拒絕。寫入用的 schema 是嚴格模式(
extra=forbid)—— 多送一個拼錯的欄位會回422,而不是安靜忽略。 Unknown fields are rejected. Write schemas are strict (extra=forbid) — a misspelled extra field returns422instead of being silently ignored.未知の項目は拒否されます。書き込み用のスキーマは厳格モード(extra=forbid)です。綴りを誤った項目を余分に送ると、黙って無視されるのではなく422が返ります。 - 部分更新用
PATCH,只送要改的欄位。 UsePATCHfor partial updates, sending only the fields you want to change.部分更新にはPATCHを使い、変更したい項目だけを送ってください。
分頁Paginationページング
列表端點吃 page(從 1 起算)與 page_size,回應固定是這個外層:
List endpoints take page (1-based) and page_size, and always return this envelope:一覧系のエンドポイントは page(1 起算)と page_size を受け取り、常にこの外枠を返します。
{ "items": [ … ], "total": 1234, "page": 1, "page_size": 50 }
page_size 上限視端點而定(多數是 200)。要抓完整資料就依 total 逐頁取。
The page_size cap depends on the endpoint (usually 200). To fetch everything, page through using total.page_size の上限はエンドポイントによります(多くは 200)。全件取得するには total を見ながらページを進めてください。
3錯誤與狀態碼Errors & status codesエラーとステータスコード
錯誤回應一律是 {"detail": "…"};422 另外附 errors 陣列指出哪個欄位不合法。伺服器端不會回 stack trace。
Errors are always {"detail": "…"}; 422 additionally carries an errors array pinpointing the invalid fields. Stack traces are never returned.エラーは常に {"detail": "…"} の形です。422 の場合はどの項目が不正かを示す errors 配列も付きます。スタックトレースが返ることはありません。
{ "detail": "Invalid request",
"errors": [ { "loc": ["body","cidr"], "msg": "value is not a valid IPv4 network", "type": "value_error" } ] }
| 狀態Statusステータス | 意義與常見原因Meaning & common cause意味とよくある原因 |
|---|---|
200 / 201 / 204 | 成功(204 用於刪除,無內容)Success (204 for deletes, no body)成功(削除は本文なしの 204) |
401 | 沒帶權杖、權杖無效、已撤銷或已到期Missing, invalid, revoked or expired tokenトークンが無い、無効、失効済み、または期限切れ |
403 | 認證過但不准 —— RBAC 不足,或是唯讀權杖試圖寫入Authenticated but not allowed — insufficient RBAC, or a read-only token attempting a write認証は通ったが許可されていない。RBAC が不足しているか、読み取り専用トークンで書き込もうとした |
404 | 不存在 —— 也用於「存在但你無權看見」,以免洩漏存在性Not found — also returned for "exists but you may not see it", to avoid leaking existence存在しない。「存在するが閲覧権限が無い」場合にもこれを返し、存在そのものが漏れないようにしています |
409 | 衝突,例如重疊網段、或刪除仍被引用的物件Conflict, e.g. overlapping subnets, or deleting a still-referenced object競合。サブネットの重複や、まだ参照されているオブジェクトの削除など |
422 | 欄位驗證失敗(含未知欄位、不支援的 scope)Validation failed (including unknown fields and unsupported scopes)項目の検証に失敗(未知の項目や未対応のスコープを含む) |
429 | 超過速率限制,回應帶 Retry-AfterRate limited; the response carries Retry-Afterレート制限の超過。応答に Retry-After が付きます |
4權限模型Permission model権限モデル
jt-ipam 是預設關閉(deny by default)。你的權杖看得到什麼,完全取決於擁有者被授權了什麼: jt-ipam is deny by default. What your token can see depends entirely on what its owner has been granted:jt-ipam は既定で拒否(deny by default)です。トークンで何が見えるかは、その所有者に何が許可されているかで決まります。
- 可逐物件授權的資料(區段/子網路/IP/裝置/機櫃/地點/客戶)→ 只回你可見範圍內的,連
total、統計與趨勢都會跟著縮放。 Per-object data (sections / subnets / IPs / devices / racks / locations / customers) → only what you can see, andtotal, counts and trends scale with it.オブジェクト単位で許可されるデータ(セクション/サブネット/IP/機器/ラック/拠点/顧客)→ 閲覧可能な範囲だけが返り、total・集計・傾向もその範囲に合わせて縮小します。 - 全域基礎設施資料(VLAN/VRF/NAT/防火牆/DNS/虛擬化/佈線/電力…)→ 需要「全域讀取」(admin 或萬用讀取授權)。只被指派特定物件的帳號會拿到
403。 Global infrastructure (VLAN / VRF / NAT / firewalls / DNS / virtualization / cabling / power…) → requires global read (admin or a wildcard read grant). Accounts scoped to specific objects get403.全体に関わる基盤データ(VLAN/VRF/NAT/ファイアウォール/DNS/仮想化/配線/電源など)→ 全体の読み取り権限(admin またはワイルドカードの読み取り許可)が必要です。特定のオブジェクトだけを割り当てられたアカウントは403になります。 - 純管理資料(稽核記錄、使用者/群組/權限、系統與整合設定)→ 需要 admin。 Administrative data (audit log, users / groups / permissions, system and integration settings) → requires admin.管理系のデータ(監査ログ、ユーザー/グループ/権限、システムと連携の設定)→ admin が必要です。
想知道自己這把權杖有什麼能力,打 GET /api/v1/me:回應含 is_admin、has_visibility、has_global_read。
To discover what your token can do, call GET /api/v1/me: the response includes is_admin, has_visibility and has_global_read.自分のトークンに何ができるかを知るには GET /api/v1/me を呼びます。応答に is_admin・has_visibility・has_global_read が含まれます。
5區段(Sections)Sectionsセクション(Sections)
最上層的分組容器,子網路掛在區段底下。可有父子階層。 The top-level grouping container that subnets belong to. Supports parent/child nesting.最上位のグループ用コンテナで、サブネットはこの下にぶら下がります。親子の入れ子にも対応します。
| 方法Methodメソッド | 路徑Pathパス | 說明Description説明 |
|---|---|---|
| GET | /api/v1/sections | 列出(分頁)List (paginated)一覧(ページング) |
| GET | /api/v1/sections/{id} | 單筆詳情Get one単件の詳細 |
| POST | /api/v1/sections | 建立Create作成 |
| PATCH | /api/v1/sections/{id} | 部分更新Partial update部分更新 |
| DELETE | /api/v1/sections/{id} | 刪除Delete削除 |
| POST | /api/v1/sections/bulk-delete | 批次刪除({"ids":[…]})Bulk delete ({"ids":[…]})一括削除({"ids":[…]}) |
建立區段Create a sectionセクションの作成
| 欄位Field項目 | 型別Type型 | 必填Required必須 | 說明Description説明 |
|---|---|---|---|
name | string | 是yesはい | 1~128 字1–128 chars1~128 文字 |
description | string | — | 最多 1024 字up to 1024 chars最大 1024 文字 |
parent_id | uuid | — | 上層區段Parent section親セクション |
customer_id | uuid | — | 歸屬客戶/管理單位Owning customer / managing unit所属する顧客/管理組織 |
strict_mode | bool | — | 嚴格模式Strict mode厳格モード |
display_order | int | — | 顯示排序(0~10000)Display order (0–10000)表示順(0~10000) |
curl -X POST https://ipam.example.com/api/v1/sections \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"name":"Taipei DC","description":"main site"}'
6子網路(Subnets)Subnetsサブネット(Subnets)
| 方法Methodメソッド | 路徑Pathパス | 說明Description説明 |
|---|---|---|
| GET | /api/v1/subnets | 列出。可加 section_id、archived、page、page_sizeList. Accepts section_id, archived, page, page_size一覧。section_id・archived・page・page_size を受け取ります |
| GET | /api/v1/subnets/{id} | 單筆詳情Get one単件の詳細 |
| GET | /api/v1/subnets/{id}/usage | 使用率統計(已用/可用/可配發)Usage stats (used / free / usable)使用率の集計(使用中/空き/割り当て可能) |
| GET | /api/v1/subnets/{id}/first_free_address | 第一個可用 IPFirst free IP最初の空き IP |
| POST | /api/v1/subnets | 建立Create作成 |
| PATCH | /api/v1/subnets/{id} | 部分更新Partial update部分更新 |
| POST | /api/v1/subnets/{id}/archive | 封存 / /unarchive 取消封存Archive / /unarchive to restoreアーカイブ(/unarchive で復帰) |
| POST | /api/v1/subnets/{id}/scan | 要求掃描代理立刻掃一次Ask the scan agent to sweep it nowスキャンエージェントに即時スキャンを依頼 |
| DELETE | /api/v1/subnets/{id} | 刪除(底下仍有 IP/下層時會被擋)Delete (blocked while it still holds IPs or children)削除(配下に IP や下位要素が残っていると拒否されます) |
| GET | /api/v1/subnets/overlaps/exists | 是否存在重疊網段(admin)Whether any overlapping subnets exist (admin)サブネットの重複が存在するか(admin) |
/usage,不要自己算 CIDR。jt-ipam 的「已用/可用」是依實際 IP 記錄與網段設定算的,跟純數學的 CIDR 容量不一樣(會扣掉網路位址、廣播位址、保留與 DHCP 範圍等)。
Use /usage rather than computing from the CIDR. jt-ipam's used/free figures come from the actual IP records and subnet settings, which differ from raw CIDR arithmetic (network and broadcast addresses, reservations, DHCP pools and so on).使用率は CIDR から自分で計算せず /usage を使ってください。jt-ipam の「使用中/空き」は実際の IP レコードとサブネットの設定から算出しており、単純な CIDR の計算とは異なります(ネットワークアドレス、ブロードキャストアドレス、予約、DHCP 範囲などが差し引かれます)。
curl -X POST https://ipam.example.com/api/v1/subnets \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"cidr":"192.0.2.0/24","section_id":"<section-uuid>","description":"office LAN"}'
7IP 位址(Addresses)IP addressesIP アドレス(Addresses)
| 方法Methodメソッド | 路徑Pathパス | 說明Description説明 |
|---|---|---|
| GET | /api/v1/addresses | 列出/查詢(見下方參數)List / query (parameters below)一覧/検索(パラメータは下記) |
| GET | /api/v1/addresses/{id} | 單筆詳情Get one単件の詳細 |
| GET | /api/v1/addresses/{id}/history | 異動記錄Change history変更履歴 |
| GET | /api/v1/addresses/{id}/relations | 關聯物件Related objects関連するオブジェクト |
| GET | /api/v1/addresses/{id}/switch-port | 對應的交換器連接埠The switch port it is seen onその IP が観測されたスイッチのポート |
| GET | /api/v1/addresses/export.csv | 匯出 CSVExport as CSVCSV としてエクスポート |
| POST | /api/v1/addresses | 建立Create作成 |
| POST | /api/v1/addresses/first_free | 取得並配發第一個可用 IPClaim the first free IP最初の空き IP を確保する |
| PATCH | /api/v1/addresses/{id} | 部分更新Partial update部分更新 |
| DELETE | /api/v1/addresses/{id} | 刪除Delete削除 |
| POST | /api/v1/addresses/bulk-state | 批次改狀態Bulk state change状態の一括変更 |
| POST | /api/v1/addresses/import | 批次匯入Bulk import一括取り込み |
查詢參數Query parametersクエリパラメータ
| 參數Parameterパラメータ | 說明Description説明 |
|---|---|
subnet_id | 限定某個子網路Restrict to one subnet特定のサブネットに限定 |
section_id | 限定某個區段Restrict to one section特定のセクションに限定 |
customer_id | 限定某個客戶/管理單位Restrict to one customer特定の顧客/管理組織に限定 |
device_id | 限定掛在某個裝置上Restrict to one device特定の機器に紐づくものに限定 |
q | 關鍵字(IP、主機名稱、MAC、說明…)Free text (IP, hostname, MAC, description…)キーワード(IP、ホスト名、MAC、説明など) |
exact | 精準比對而非模糊Exact match instead of fuzzyあいまい検索ではなく完全一致 |
sort / order | 排序欄位 / asc|descSort field / asc|desc並べ替えの項目 / asc|desc |
# 查某網段裡所有 IP
curl -G https://ipam.example.com/api/v1/addresses \
-H "Authorization: Bearer $TOKEN" \
--data-urlencode "subnet_id=<subnet-uuid>" --data-urlencode "page_size=200"
# 依主機名稱找
curl -G https://ipam.example.com/api/v1/addresses \
-H "Authorization: Bearer $TOKEN" --data-urlencode "q=web01"
192.168.1.0/24)的環境裡,同一個 IP 會跨多個子網路各有一筆 —— 這是設計如此。用 subnet_id 限定範圍,不要假設 IP 唯一。
The same IP string may appear more than once. The unique key is (subnet, IP), so with overlapping subnets (different customers sharing 192.168.1.0/24) one IP legitimately has a row per subnet. Scope your queries with subnet_id; don't assume an IP is unique.同じ IP 文字列が複数件現れることがあります。一意キーは「サブネット + IP」です。したがって重複するサブネット(異なる顧客が同じ 198.51.100.0/24 を使っている環境)では、同じ IP がサブネットごとに 1 件ずつ存在します。これは仕様です。subnet_id で範囲を限定し、IP が一意であると仮定しないでください。
8裝置(Devices)Devices機器(Devices)
| 方法Methodメソッド | 路徑Pathパス | 說明Description説明 |
|---|---|---|
| GET | /api/v1/devices | 列出List一覧 |
| GET | /api/v1/devices/{id} | 單筆詳情Get one単件の詳細 |
| GET | /api/v1/devices/{id}/relations | 關聯(IP/機櫃/佈線…)Relations (IPs / rack / cabling…)関連(IP/ラック/配線など) |
| GET | /api/v1/devices/{id}/integrations | 各整合帶回的資料Data pulled in by integrations各連携が取り込んだデータ |
| GET | /api/v1/devices/{id}/vlans | VLAN 對應VLAN mappingsVLAN の対応 |
| POST | /api/v1/devices | 建立Create作成 |
| PATCH | /api/v1/devices/{id} | 部分更新Partial update部分更新 |
| DELETE | /api/v1/devices/{id} | 刪除Delete削除 |
9搜尋與 IP 工具Search & IP tools検索と IP ツール
GET /api/v1/search?q=…&limit_per_type=… 是全域搜尋,跨區段/子網路/IP/裝置/客戶等型別,並依你的可見範圍過濾。支援部分 MAC 首碼(如 bc:24)。
GET /api/v1/search?q=…&limit_per_type=… searches across sections, subnets, IPs, devices, customers and more, filtered to what you may see. Partial MAC prefixes (e.g. bc:24) work.GET /api/v1/search?q=…&limit_per_type=… は横断検索で、セクション/サブネット/IP/機器/顧客などの種別をまたぎ、閲覧可能な範囲に絞って返します。MAC の部分的な接頭辞(bc:24 など)にも対応します。
/api/v1/tools/* 是一組無副作用的計算端點,適合腳本直接呼叫:
/api/v1/tools/* is a set of side-effect-free calculators handy for scripts:/api/v1/tools/* は副作用のない計算用エンドポイント群で、スクリプトから直接呼ぶのに向いています。
| 端點Endpointエンドポイント | 用途Purpose用途 |
|---|---|
ip-info / cidr-info | IP/網段基本資訊IP / CIDR factsIP/ネットワークの基本情報 |
cidr-split / aggregate | 切分 / 聚合網段Split / aggregate prefixesネットワークの分割・集約 |
ip-in-cidr / cidr-relation | 包含關係判斷Containment and relation checks包含関係の判定 |
range-to-cidr / cidr-to-range | 範圍 ↔ 網段互轉Range ↔ CIDR conversion範囲 ↔ ネットワークの相互変換 |
netmask / eui64 / mac-format | 遮罩換算、EUI-64、MAC 格式化Netmask conversion, EUI-64, MAC formattingサブネットマスクの換算、EUI-64、MAC の整形 |
dns-lookup / fqdn / dns-mail / geoip | DNS 查詢、FQDN 解析、郵件記錄、GeoIPDNS lookups, FQDN parsing, mail records, GeoIPDNS の問い合わせ、FQDN の解析、メール関連レコード、GeoIP |
10完整資源索引Full resource indexリソース一覧
API 共約 500 條路由。上面詳述的是最常用的核心資源;其餘資源大多遵循同一套 GET 列表 / GET {id} / POST / PATCH / DELETE 慣例。
The API has roughly 500 routes. The sections above cover the core resources in detail; most others follow the same GET list / GET {id} / POST / PATCH / DELETE convention.API の経路はおよそ 500 本あります。上で詳しく説明したのは最もよく使う中核のリソースで、それ以外の多くは同じ GET 一覧 / GET {id} / POST / PATCH / DELETE の作法に従います。
| 分類Area分類 | 基底路徑Base pathsベースパス | 權限Access権限 |
|---|---|---|
| 核心 IPAMCore IPAMIPAM のコア | /sections /subnets /addresses /devices /customers /racks /locations |
逐物件可見性Per-object visibilityオブジェクト単位の可視性 |
| 網路資源Network resourcesネットワーク資源 | /vlans /vlan-domains /vrfs /asns /nat /dhcp-ranges /vpn-tunnels /wireless |
全域讀取Global read全体の読み取り |
| 實體層Physical layer物理層 | /cables /cable-terminations /device-ports /ports /power-feeds /power-panels /power-outlets /device-power-ports |
全域讀取Global read全体の読み取り |
| 商務/組織Business / orgビジネス/組織 | /tenants /tenant-groups /providers /circuits /circuit-types /contacts /contact-groups /contact-assignments |
全域讀取Global read全体の読み取り |
| 整合Integrations連携 | /firewalls(OPNsense)/pfsense /fortigate /paloalto /mikrotik /windows-dhcp /librenms /wazuh /zabbix /adguard /dns /virt |
設定需 admin;唯讀檢視需全域讀取admin to configure; global read to view設定には admin、閲覧のみなら全体の読み取り |
| 代理與憑證Agents & certificatesエージェントと証明書 | /scan-agents /cert-agents /certificates /ssh-credentials |
admin |
| 流程與通知Workflow & notificationsワークフローと通知 | /ip-requests /notifications /webhooks /tasks /anomalies /ip-changes |
視端點而定Variesエンドポイントによる |
| 分析與 AIAnalytics & AI分析と AI | /dashboard /topology /search /tools /oui /ai |
視端點而定Variesエンドポイントによる |
| 管理Administration管理 | /users /groups /audit /system /custom-fields /plugins /import /migration |
admin |
| 自助Self-serviceセルフサービス | /me /me/preferences /api-tokens /auth |
任何已認證帳號Any authenticated account認証済みの任意のアカウント |
11phpIPAM 相容 API-compatible API 互換 API
給既有的 phpIPAM 腳本用的相容層:換掉網址與權杖就能沿用,回應是 phpIPAM 的外層格式。 A compatibility layer for existing phpIPAM scripts: change the URL and token and they keep working, with phpIPAM-shaped response envelopes.既存の phpIPAM 用スクリプトのための互換レイヤです。URL とトークンを差し替えればそのまま使え、応答も phpIPAM と同じ外枠の形で返します。
基底路徑:/api/phpipam/<app_id>/。<app_id> 沿用你原本 phpIPAM 的 App ID 字串。
Base path: /api/phpipam/<app_id>/, where <app_id> is whatever App ID string your scripts already use.ベースパスは /api/phpipam/<app_id>/ です。<app_id> には、これまで使っていた phpIPAM の App ID 文字列をそのまま指定します。
認證Authentication認証
三種標頭都收(挑一個就好):token: jt_…、phpipam-token: jt_…、Authorization: Bearer jt_…。也可以用帳號密碼走 Basic Auth 換一把 30 天的權杖:
Any one of three headers works: token: jt_…, phpipam-token: jt_…, or Authorization: Bearer jt_…. You can also exchange username/password over Basic Auth for a 30-day token:次の三つのヘッダのいずれでも構いません。token: jt_…、phpipam-token: jt_…、Authorization: Bearer jt_…。また、Basic 認証でユーザー名とパスワードを送り、30 日間有効なトークンと交換することもできます。
curl -X POST -u 'user:password' \
https://ipam.example.com/api/phpipam/myapp/user/
{ "code":200, "success":true, "data":{ "token":"jt_prod_…", "expires":"…" }, "time":0.01 }
| 方法Methodメソッド | 路徑(接在基底之後)Path (after the base)パス(ベースに続く部分) | 說明Description説明 |
|---|---|---|
| POST | user/ | Basic Auth 換權杖Exchange Basic Auth for a tokenBasic 認証をトークンと交換する |
| GET | user/ | 權杖資訊Token infoトークンの情報 |
| PATCH | user/ | 延長權杖期限Extend the tokenトークンの期限を延長する |
| DELETE | user/ | 撤銷權杖(登出)Revoke the token (log out)トークンを失効させる(ログアウト) |
| GET | sections/ · sections/{id} · sections/{id}/subnets/ | 區段Sectionsセクション |
| GET | subnets/{id}/ · subnets/cidr/{cidr}/ · subnets/{id}/usage/ · subnets/{id}/first_free/ · subnets/{id}/addresses/ | 子網路Subnetsサブネット |
| GET | addresses/{id}/ · addresses/{ip}/{subnet_id}/ · addresses/search/{ip}/ · addresses/search_hostname/{host}/ · addresses/first_free/{subnet_id}/ | IP 位址IP addressesIP アドレス |
POST PATCH DELETE sections/ · subnets/ · addresses/ | 建立/更新/刪除Create / update / delete作成/更新/削除 | |
docs/PHPIPAM_API_MAPPING.md。新寫的整合建議直接用上面的原生 REST API。
The layer covers the commonly-used subset of the phpIPAM API, not every call. See docs/PHPIPAM_API_MAPPING.md in the source for the full mapping. For new integrations, prefer the native REST API above.この互換レイヤが覆うのは phpIPAM API のうちよく使われる一部であり、一対一の対応ではありません。完全な対応表はソース内の docs/PHPIPAM_API_MAPPING.md にあります。新しく連携を書く場合は、上記のネイティブな REST API を直接使うことをおすすめします。
POST/PATCH 會被擋成 403。唯一例外是 DELETE user/(撤銷自己的權杖)—— 那是降權、不是異動資料,所以照樣放行,老腳本的「登入 → 查詢 → 登出」流程不會斷。
Read-only tokens are enforced here too: POST/PATCH get 403. The one exception is DELETE user/ (revoking your own token) — that reduces privilege rather than changing data, so it is allowed and the classic login → query → logout flow keeps working.読み取り専用トークンはこのレイヤでも有効で、POST/PATCH は 403 で拒否されます。唯一の例外は DELETE user/(自分のトークンの失効)です。これは権限を下げる操作であってデータの変更ではないため許可され、従来からの「ログイン → 問い合わせ → ログアウト」という流れが壊れません。
12Graylog DSV 查表 lookups ルックアップ
給 Graylog 的「DSV File from HTTP」配接器用的免登入唯讀端點,回 CSV。認證是一把系統層級的權杖,走網址參數 ?token=(由 admin 在「管理 → Graylog DSV」產生),因為 Graylog 抓檔時不能帶自訂標頭。
Unauthenticated, read-only CSV endpoints for Graylog's "DSV File from HTTP" adapter. They are gated by a system-level token passed as ?token= (generated under Admin → Graylog DSV), because Graylog cannot send custom headers when fetching.Graylog の「DSV File from HTTP」アダプタ向けの認証不要・読み取り専用の CSV エンドポイントです。Graylog は取得時に独自ヘッダを送れないため、認証はシステムレベルのトークンを URL パラメータ ?token= で渡す方式です(admin が「管理 → Graylog DSV」で生成します)。
| 路徑Pathパス | 對照Mapping対応 |
|---|---|
/api/v1/lookup/{name} | IP → 主機名稱IP → hostnameIP → ホスト名 |
/api/v1/lookup/firewall/{id}/rule-aliases | OPNsense 規則 rid → 別名OPNsense rule rid → aliasOPNsense のルール rid → エイリアス |
/api/v1/lookup/firewall/{id}/aliases | OPNsense 別名 → 成員OPNsense alias → membersOPNsense のエイリアス → メンバー |
/api/v1/lookup/pfsense/{id}/rules | pfSense tracker → 說明pfSense tracker → descriptionpfSense の tracker → 説明 |
/api/v1/lookup/pfsense/{id}/aliases | pfSense 別名 → 成員pfSense alias → memberspfSense のエイリアス → メンバー |
/api/v1/lookup/proxmox/vms | 全部叢集:vmid → VM 名稱All clusters: vmid → VM name全クラスタ:vmid → VM 名 |
/api/v1/lookup/proxmox/{cluster_id}/vms | 單一叢集:vmid → VM 名稱One cluster: vmid → VM name単一クラスタ:vmid → VM 名 |
curl "https://ipam.example.com/api/v1/lookup/hostnames?token=<dsv-token>"
"192.0.2.10","web01"
"192.0.2.11","db01"
在 Graylog 的 DSV 配接器裡,Key column = 0、Value column = 1(欄位索引從 0 起算)。防火牆相關端點要先在該台整合設定裡勾選「提供防火牆 DSV」才會有資料。 In Graylog's DSV adapter set Key column = 0 and Value column = 1 (indices are 0-based). The firewall endpoints only return data once "expose firewall DSV" is enabled on that instance.Graylog の DSV アダプタでは Key column = 0、Value column = 1 に設定してください(索引は 0 起算です)。ファイアウォール関連のエンドポイントは、その連携の設定で「ファイアウォール DSV を提供する」を有効にして初めてデータを返します。
13MCP(給 LLM 用) (for LLMs)(LLM 向け)
jt-ipam 內建 MCP(Model Context Protocol)伺服器,讓 LLM 用自然語言查 IPAM。走 JSON-RPC 2.0: jt-ipam ships an MCP (Model Context Protocol) server so an LLM can query the IPAM in natural language, over JSON-RPC 2.0:jt-ipam には MCP(Model Context Protocol)サーバーが組み込まれており、LLM が自然言語で IPAM を問い合わせられます。通信は JSON-RPC 2.0 です。
- Streamable HTTP:
POST /api/mcp。initialize的回應會帶Mcp-Session-Id標頭。支援initialize、ping、tools/list、tools/call。 Streamable HTTP:POST /api/mcp. Theinitializeresponse carries anMcp-Session-Idheader. Supportsinitialize,ping,tools/listandtools/call.Streamable HTTP:POST /api/mcp。initializeの応答にMcp-Session-Idヘッダが付きます。initialize・ping・tools/list・tools/callに対応します。 - stdio(本機用,例如 Claude Desktop):
python -m app.mcp.stdio_server,權杖放環境變數JT_IPAM_MCP_TOKEN。 stdio (local, e.g. Claude Desktop):python -m app.mcp.stdio_server, with the token inJT_IPAM_MCP_TOKEN.stdio(ローカル用。Claude Desktop など):python -m app.mcp.stdio_server。トークンは環境変数JT_IPAM_MCP_TOKENに入れます。
認證用 X-Auth-Token 或 Authorization: Bearer,可以是:
Authentication uses X-Auth-Token or Authorization: Bearer, with either:認証は X-Auth-Token または Authorization: Bearer で行い、次のいずれかを使えます。
- 對外唯讀 MCP 金鑰(
jtmcp_…,admin 在「管理 → LLM/AI」產生並輪替)—— 只看得到唯讀工具,異動類工具會被隱藏並擋下。要先啟用「對外 MCP」才會生效。 A read-only external MCP key (jtmcp_…, generated and rotated by an admin under Admin → LLM/AI) — read-only tools only; mutating tools are hidden and blocked. External MCP must be enabled first.外部向けの読み取り専用 MCP キー(jtmcp_…。admin が「管理 → LLM/AI」で生成・更新します)。読み取り専用のツールだけが見え、変更系のツールは隠され、実行も拒否されます。先に「外部 MCP」を有効にする必要があります。 - 一般 API 權杖(
jt_…)—— 依該權杖擁有者的權限。若這把權杖是唯讀 scope,MCP 同樣只給唯讀工具。 A regular API token (jt_…) — scoped to its owner's permissions. If the token is read-only, MCP likewise exposes only read-only tools.通常の API トークン(jt_…)。そのトークンの所有者の権限に従います。読み取り専用スコープのトークンであれば、MCP でも読み取り専用のツールだけが提供されます。
curl -X POST https://ipam.example.com/api/mcp \
-H "X-Auth-Token: jtmcp_xxxxxxxx" -H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
14代理協定Agent protocolsエージェントのプロトコル
掃描代理與憑證派送代理有自己的通道,用各自獨立的金鑰(X-Agent-Key 標頭,建立代理時產生、只存雜湊),不是 API 權杖。這些端點是給代理程式用的,一般整合不需要碰。
The scan agent and certificate-distribution agent have their own channel, authenticated by per-agent keys (the X-Agent-Key header, issued when the agent is created and stored only as a hash) rather than API tokens. These endpoints are for the agents themselves; normal integrations don't need them.スキャンエージェントと証明書配布エージェントは専用の経路を持ち、API トークンではなくエージェントごとの鍵で認証します(X-Agent-Key ヘッダ。エージェント作成時に発行され、ハッシュだけが保存されます)。これらのエンドポイントはエージェント自身のためのもので、通常の連携で触る必要はありません。
| 路徑Pathパス | 用途Purpose用途 |
|---|---|
GET /api/v1/scan-agents/poll | 代理取得要掃的子網路與方法Agent fetches the subnets and probes to runエージェントがスキャン対象のサブネットと方法を取得する |
POST /api/v1/scan-agents/report | 代理回報存活 IP、MAC、主機名稱Agent reports live IPs, MACs and hostnamesエージェントが生存 IP・MAC・ホスト名を報告する |
GET /api/v1/cert-agents/check | 代理比對指紋與到期日Agent compares fingerprints and expiryエージェントがフィンガープリントと有効期限を照合する |
GET /api/v1/cert-agents/bundle/raw | 代理取憑證內容(多種格式)Agent fetches certificate material (several formats)エージェントが証明書の内容を取得する(複数の形式) |
POST /api/v1/cert-agents/report | 代理回報派送結果Agent reports deployment resultsエージェントが配備の結果を報告する |
GET /api/v1/cert-agents/agent.shGET /api/v1/cert-agents/agent.ps1 | 代理程式本體(Linux / Windows),公開可取、無密鑰;代理據此自我更新The agent itself (Linux / Windows). Public, contains no secrets; agents self-update from itエージェント本体(Linux / Windows)。公開されており秘密情報は含みません。エージェントはこれを使って自己更新します |
bundle/raw?part=pkcs12 可帶 X-Pfx-Password 標頭。帶了就回以該密碼加密、且 Windows 匯得進去的 PKCS#12(PBESv1-SHA1-3DES)—— PBESv1 是 Windows CryptoAPI 全版本都吃的形式;函式庫預設的 PBESv2/AES-256 失敗時訊息是誤導的「密碼不正確」。不帶標頭時行為不變(不加密)。Windows 代理每次執行自產一組隨機密碼且只留在記憶體,私鑰不會為了匯入而寫到磁碟。
bundle/raw?part=pkcs12 accepts an X-Pfx-Password header. With it you get a PKCS#12 encrypted with that password using the encryption Windows can actually import (PBESv1-SHA1-3DES) — PBESv1 is the form every version of the Windows CryptoAPI accepts; the library default, PBESv2/AES-256, fails with a misleading "the password is incorrect". Without the header the behaviour is unchanged (unencrypted). The Windows agent generates a random password per run and keeps it in memory, so the private key is never written to disk on the way in.bundle/raw?part=pkcs12 は X-Pfx-Password ヘッダを受け付けます。付けると、そのパスワードで暗号化されかつ Windows が実際に取り込める PKCS#12(PBESv1-SHA1-3DES)が返ります。PBESv1 はどのバージョンの Windows CryptoAPI でも受け付ける形式です。ライブラリの既定である PBESv2/AES-256 は、失敗したときに「パスワードが正しくありません」という誤解を招くメッセージになります。ヘッダを付けない場合の挙動は従来どおり(暗号化なし)です。Windows エージェントは実行のたびにランダムなパスワードを生成してメモリ上にだけ保持するため、取り込みのために秘密鍵がディスクへ書き出されることはありません。
X-Agent-Key 等同於它 scope 內所有憑證的私鑰,請當成最高敏感憑證保管。
The certificate bundle endpoint decrypts and returns private keys (HTTPS-only, audited on every fetch). That X-Agent-Key is equivalent to the private keys of every certificate in its scope — treat it as a top-tier secret.証明書の取得エンドポイントはその場で復号して秘密鍵を返します(HTTPS 必須、取得のたびに監査に記録)。その X-Agent-Key は、スコープ内のすべての証明書の秘密鍵と同等です。最高機密として扱ってください。
另有兩支完全免認證的健康檢查端點,給負載平衡器用:GET /healthz(存活)與 GET /readyz(就緒,DB/Redis 不通時回 503)。
Two entirely unauthenticated health endpoints exist for load balancers: GET /healthz (liveness) and GET /readyz (readiness, returning 503 when the DB or Redis is unreachable).ロードバランサ向けに、認証がまったく不要なヘルスチェック用エンドポイントが二つあります。GET /healthz(生存確認)と GET /readyz(準備確認。DB や Redis に到達できないときは 503 を返します)。
15速率限制與 CORSRate limits & CORSレート制限と CORS
依來源 IP 分桶限流,超過回 429 並帶 Retry-After(秒)。預設值(可在後端設定調整):
Rate limits are bucketed per source IP; exceeding one returns 429 with Retry-After (seconds). Defaults (configurable in the backend):送信元 IP ごとにバケットを分けて制限し、超過すると Retry-After(秒)を付けて 429 を返します。既定値(バックエンドの設定で変更可)は次のとおりです。
| 分桶Bucketバケット | 預設Default既定 | 適用Applies to対象 |
|---|---|---|
api_token | 600 / min | 用 API 權杖呼叫API-token callsAPI トークンによる呼び出し |
default | 100 / min | 一般請求General requests通常のリクエスト |
auth | 10 / min | 登入等認證端點Login and other auth endpointsログインなどの認証系エンドポイント |
ai | 20 / min | LLM 推論(昂貴,較嚴格)LLM inference (expensive, tighter)LLM の推論(負荷が高いため厳しめ) |
CORS:正式環境只允許明確列出的 HTTPS 來源(不接受 *、不接受 HTTP)。因此瀏覽器端的跨網域呼叫預設不會通 —— 第三方整合請走伺服器對伺服器。
CORS: in production only explicitly-listed HTTPS origins are allowed (no *, no HTTP). So cross-origin browser calls will not work by default — do third-party integrations server-to-server.CORS:本番環境では明示的に列挙された HTTPS のオリジンだけを許可します(* も HTTP も不可)。そのためブラウザからのクロスオリジン呼び出しは既定では通りません。第三者との連携はサーバー間で行ってください。
16OpenAPI
後端是 FastAPI,會自動產生 OpenAPI 規格。但正式環境(APP_ENV=production)一律關閉 /docs、/redoc 與 /openapi.json,避免對外洩漏完整攻擊面。
The backend is FastAPI and generates an OpenAPI spec automatically. However /docs, /redoc and /openapi.json are disabled in production (APP_ENV=production) so the full attack surface isn't published.バックエンドは FastAPI なので OpenAPI 仕様が自動生成されます。ただし本番環境(APP_ENV=production)では /docs・/redoc・/openapi.json をすべて無効化し、攻撃面の全体像が外部に公開されないようにしています。
要拿完整的機器可讀規格(含每個端點的全部欄位),在非正式環境的實例上開一台即可: To get the complete machine-readable spec (every field of every endpoint), run a non-production instance:機械可読の完全な仕様(各エンドポイントの全項目を含む)が必要な場合は、本番以外の環境でインスタンスを一つ起動してください。
APP_ENV=development uvicorn app.main:app
curl http://127.0.0.1:8000/openapi.json > jt-ipam-openapi.json
拿到 openapi.json 之後可以直接餵給 openapi-generator 產出各語言的 client。
Feed that openapi.json to openapi-generator to produce a client in your language of choice.取得した openapi.json を openapi-generator に渡せば、好きな言語のクライアントを生成できます。