{"info":{"name":"MikroPanel Agent API","schema":"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},"auth":{"type":"bearer","bearer":[{"key":"token","value":"{{api_key}}","type":"string"}]},"variable":[{"key":"base_url","value":"https://api.mikropanel.ir/v1"},{"key":"api_key","value":""},{"key":"client_id","value":"1"},{"key":"peer_id","value":"1"},{"key":"plan_id","value":"1"},{"key":"router_id","value":"1"}],"item":[{"name":"Account","item":[{"name":"Who this key is, what it may do and its limits","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/me","host":["{{base_url}}"],"path":["me"],"query":[]}}},{"name":"Traffic credit, peer quota and plan credits","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/me/balance","host":["{{base_url}}"],"path":["me","balance"],"query":[]}}},{"name":"Peer counts and traffic sold","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/me/stats","host":["{{base_url}}"],"path":["me","stats"],"query":[]}}}]},{"name":"Routers","item":[{"name":"Routers assigned to you, with limits and availability","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/routers","host":["{{base_url}}"],"path":["routers"],"query":[]}}},{"name":"One assigned router","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/routers/{{router_id}}","host":["{{base_url}}"],"path":["routers","{{router_id}}"],"query":[]}}}]},{"name":"Plans","item":[{"name":"Your credit plans with remaining credits","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/plans","host":["{{base_url}}"],"path":["plans"],"query":[]}}},{"name":"One credit plan","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/plans/{{plan_id}}","host":["{{base_url}}"],"path":["plans","{{plan_id}}"],"query":[]}}}]},{"name":"L2TP clients","item":[{"name":"Routers where you can sell L2TP","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/l2tp-servers","host":["{{base_url}}"],"path":["l2tp-servers"],"query":[]}}},{"name":"List your clients, newest first","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/clients","host":["{{base_url}}"],"path":["clients"],"query":[{"key":"limit","value":"1","description":"Items per page (default 50).","disabled":true},{"key":"cursor","value":"1","description":"next_cursor of the previous page.","disabled":true},{"key":"status","value":"inactive","description":"Only this status.","disabled":true},{"key":"router_id","value":"1","description":"Only this router.","disabled":true},{"key":"name","value":"text","description":"Name contains this text.","disabled":true},{"key":"updated_since","value":"2027-01-01T00:00:00+03:30","description":"Changed at or after this time.","disabled":true}]}}},{"name":"One client with its accounts","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/clients/{{client_id}}","host":["{{base_url}}"],"path":["clients","{{client_id}}"],"query":[]}}},{"name":"L2TP login of a client","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/clients/{{client_id}}/credentials","host":["{{base_url}}"],"path":["clients","{{client_id}}","credentials"],"query":[]}}},{"name":"Turn one of your peers into a client","request":{"method":"POST","description":"The client takes over the peer's limit, expiry and usage; L2TP is added. A peer made from a plan can only get the protocols of that plan.","header":[{"key":"Idempotency-Key","value":"{{$guid}}"},{"key":"Content-Type","value":"application/json"}],"url":{"raw":"{{base_url}}/clients/from-peer","host":["{{base_url}}"],"path":["clients","from-peer"],"query":[]},"body":{"mode":"raw","raw":"{\n  \"peer_id\": 1\n}"}}},{"name":"Add L2TP to a client","request":{"method":"POST","description":"","header":[{"key":"Idempotency-Key","value":"{{$guid}}"}],"url":{"raw":"{{base_url}}/clients/{{client_id}}/l2tp","host":["{{base_url}}"],"path":["clients","{{client_id}}","l2tp"],"query":[]}}},{"name":"Start a new period for a client","request":{"method":"POST","description":"Give plan_id, or both traffic (or unlimited_traffic) and days (or unlimited_time). Usage restarts. Limited agents: at most 90 days.","header":[{"key":"Idempotency-Key","value":"{{$guid}}"},{"key":"Content-Type","value":"application/json"}],"url":{"raw":"{{base_url}}/clients/{{client_id}}/renew","host":["{{base_url}}"],"path":["clients","{{client_id}}","renew"],"query":[]},"body":{"mode":"raw","raw":"{\n  \"traffic_bytes\": 32212254720,\n  \"days\": 30\n}"}}},{"name":"Raise a client's traffic limit","request":{"method":"POST","description":"A limited agent pays the added traffic from its wallet.","header":[{"key":"Idempotency-Key","value":"{{$guid}}"},{"key":"Content-Type","value":"application/json"}],"url":{"raw":"{{base_url}}/clients/{{client_id}}/add-traffic","host":["{{base_url}}"],"path":["clients","{{client_id}}","add-traffic"],"query":[]},"body":{"mode":"raw","raw":"{\n  \"traffic_bytes\": 10737418240\n}"}}},{"name":"Disable a client (all protocols)","request":{"method":"POST","description":"","header":[],"url":{"raw":"{{base_url}}/clients/{{client_id}}/disable","host":["{{base_url}}"],"path":["clients","{{client_id}}","disable"],"query":[]}}},{"name":"Enable a client","request":{"method":"POST","description":"Refused with renew_required when the traffic or time is used up.","header":[],"url":{"raw":"{{base_url}}/clients/{{client_id}}/enable","host":["{{base_url}}"],"path":["clients","{{client_id}}","enable"],"query":[]}}},{"name":"Delete a client","request":{"method":"DELETE","description":"The L2TP account is removed. The WireGuard peer stays, switched off; delete it with DELETE /peers/{id} (a limited agent is refunded then).","header":[],"url":{"raw":"{{base_url}}/clients/{{client_id}}","host":["{{base_url}}"],"path":["clients","{{client_id}}"],"query":[]}}}]},{"name":"Peers","item":[{"name":"List your peers, newest first","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/peers","host":["{{base_url}}"],"path":["peers"],"query":[{"key":"limit","value":"1","description":"Items per page (default 50).","disabled":true},{"key":"cursor","value":"1","description":"next_cursor of the previous page.","disabled":true},{"key":"status","value":"suspended","description":"Only this status.","disabled":true},{"key":"router_id","value":"1","description":"Only this router.","disabled":true},{"key":"name","value":"text","description":"Name contains this text.","disabled":true},{"key":"external_ref","value":"text","description":"Exactly this external_ref.","disabled":true},{"key":"customer_telegram_id","value":"1","description":"Exactly this Telegram id.","disabled":true},{"key":"updated_since","value":"2027-01-01T00:00:00+03:30","description":"Settings or status changed at or after this time (traffic counters alone do not count).","disabled":true}]}}},{"name":"One peer with its gift code and public page link","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/peers/{{peer_id}}","host":["{{base_url}}"],"path":["peers","{{peer_id}}"],"query":[]}}},{"name":"WireGuard configuration","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/peers/{{peer_id}}/config","host":["{{base_url}}"],"path":["peers","{{peer_id}}","config"],"query":[{"key":"format","value":"json","description":"json (default) or file.","disabled":true},{"key":"use_domain","value":"False","description":"Use the router's current domain as endpoint (default true).","disabled":true}]}}},{"name":"QR code of the configuration (PNG)","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/peers/{{peer_id}}/qr","host":["{{base_url}}"],"path":["peers","{{peer_id}}","qr"],"query":[{"key":"use_domain","value":"False","description":"Use the router's current domain as endpoint (default true).","disabled":true}]}}},{"name":"Create a peer (WireGuard, optionally with L2TP)","request":{"method":"POST","description":"Give plan_id, or your own traffic and duration. Unlimited traffic or time must be asked for explicitly and only unlimited agents may do it. With protocols [\"wireguard\",\"l2tp\"] both are made, or neither. The answer includes the config only when the key has the peers:config scope.","header":[{"key":"Idempotency-Key","value":"{{$guid}}"},{"key":"Content-Type","value":"application/json"}],"url":{"raw":"{{base_url}}/peers","host":["{{base_url}}"],"path":["peers"],"query":[]},"body":{"mode":"raw","raw":"{\n  \"name\": \"ali-phone\",\n  \"traffic_bytes\": 32212254720,\n  \"days\": 30\n}"}}},{"name":"Change name, description or your own references","request":{"method":"PATCH","description":"","header":[{"key":"Content-Type","value":"application/json"}],"url":{"raw":"{{base_url}}/peers/{{peer_id}}","host":["{{base_url}}"],"path":["peers","{{peer_id}}"],"query":[]},"body":{"mode":"raw","raw":"{}"}}},{"name":"Renew a peer with a plan or your own limits","request":{"method":"POST","description":"mode \"set\" (default) replaces the limits, \"add\" adds to them. Limited agents: at most 90 days; lowering the traffic returns nothing at once, the unused amount comes back on delete or reset. A peer that also has L2TP is renewed as a whole (set only, new traffic and duration, usage restarts). The answer includes the config only when the key has the peers:config scope.","header":[{"key":"Idempotency-Key","value":"{{$guid}}"},{"key":"Content-Type","value":"application/json"}],"url":{"raw":"{{base_url}}/peers/{{peer_id}}/renew","host":["{{base_url}}"],"path":["peers","{{peer_id}}","renew"],"query":[]},"body":{"mode":"raw","raw":"{\n  \"traffic_bytes\": 32212254720,\n  \"days\": 30\n}"}}},{"name":"Suspend a peer","request":{"method":"POST","description":"","header":[],"url":{"raw":"{{base_url}}/peers/{{peer_id}}/suspend","host":["{{base_url}}"],"path":["peers","{{peer_id}}","suspend"],"query":[]}}},{"name":"Lift a suspension","request":{"method":"POST","description":"Refused with renew_required when the traffic or time is used up.","header":[],"url":{"raw":"{{base_url}}/peers/{{peer_id}}/unsuspend","host":["{{base_url}}"],"path":["peers","{{peer_id}}","unsuspend"],"query":[]}}},{"name":"Delete a peer","request":{"method":"DELETE","description":"A limited agent gets the unused traffic back as the panel does. A peer with L2TP is deleted together with its client.","header":[],"url":{"raw":"{{base_url}}/peers/{{peer_id}}","host":["{{base_url}}"],"path":["peers","{{peer_id}}"],"query":[]}}}]},{"name":"Service","item":[{"name":"Is the API up and can it reach its database","request":{"method":"GET","description":"","header":[],"auth":{"type":"noauth"},"url":{"raw":"{{base_url}}/health","host":["{{base_url}}"],"path":["health"],"query":[]}}},{"name":"OpenAPI 3.1 description","request":{"method":"GET","description":"","header":[],"auth":{"type":"noauth"},"url":{"raw":"{{base_url}}/openapi.json","host":["{{base_url}}"],"path":["openapi.json"],"query":[]}}},{"name":"This reference (HTML)","request":{"method":"GET","description":"","header":[],"auth":{"type":"noauth"},"url":{"raw":"{{base_url}}/docs","host":["{{base_url}}"],"path":["docs"],"query":[]}}},{"name":"Postman collection of every endpoint","request":{"method":"GET","description":"","header":[],"auth":{"type":"noauth"},"url":{"raw":"{{base_url}}/postman.json","host":["{{base_url}}"],"path":["postman.json"],"query":[]}}},{"name":"Example client in Python","request":{"method":"GET","description":"","header":[],"auth":{"type":"noauth"},"url":{"raw":"{{base_url}}/examples/mikropanel.py","host":["{{base_url}}"],"path":["examples","mikropanel.py"],"query":[]}}},{"name":"Example client in PHP","request":{"method":"GET","description":"","header":[],"auth":{"type":"noauth"},"url":{"raw":"{{base_url}}/examples/mikropanel.php","host":["{{base_url}}"],"path":["examples","mikropanel.php"],"query":[]}}}]},{"name":"Usage","item":[{"name":"Daily or hourly traffic of one peer","request":{"method":"GET","description":"A day range covers at most 366 days. L2TP traffic has totals only (see the client).","header":[],"url":{"raw":"{{base_url}}/peers/{{peer_id}}/usage","host":["{{base_url}}"],"path":["peers","{{peer_id}}","usage"],"query":[{"key":"interval","value":"day","description":"day (default) or hour.","disabled":true},{"key":"from","value":"2027-01-01","description":"interval=day: first day (default 29 days before \"to\").","disabled":true},{"key":"to","value":"2027-01-01","description":"interval=day: last day (default today).","disabled":true},{"key":"date","value":"2027-01-01","description":"interval=hour: the day (default today).","disabled":true}]}}},{"name":"Daily or hourly traffic of all your peers","request":{"method":"GET","description":"","header":[],"url":{"raw":"{{base_url}}/usage","host":["{{base_url}}"],"path":["usage"],"query":[{"key":"interval","value":"day","description":"day (default) or hour.","disabled":true},{"key":"from","value":"2027-01-01","description":"interval=day: first day (default 29 days before \"to\").","disabled":true},{"key":"to","value":"2027-01-01","description":"interval=day: last day (default today).","disabled":true},{"key":"date","value":"2027-01-01","description":"interval=hour: the day (default today).","disabled":true}]}}}]}]}
