{"openapi":"3.1.0","info":{"title":"MikroPanel Agent API","version":"1.0.0","description":"\n## Start\nCreate a key in the panel: Settings → API access. Your account owner must switch API access on for you first.\nKeep the key on your own server. Never put it inside a mobile or web app: anyone holding it can sell and delete\nyour services.\n```\ncurl https://api.mikropanel.ir/v1/me -H \"Authorization: Bearer mp_live_...\"\n```\n\n## Sell a service in 5 calls\n- `GET /v1/me/balance` — your traffic credit, peer quota and plan credits.\n- `GET /v1/routers` — where you can create (`can_create`, `l2tp_available`).\n- `GET /v1/plans` — your credit plans.\n- `POST /v1/peers` — create it, with your order id as `external_ref`.\n- `GET /v1/peers/{id}/config` or `/qr` — hand it to your customer.\n```\ncurl -X POST https://api.mikropanel.ir/v1/peers \\\n  -H \"Authorization: Bearer mp_live_...\" -H \"Content-Type: application/json\" \\\n  -H \"Idempotency-Key: order-10231-create\" \\\n  -d '{\"name\":\"order10231\",\"router_id\":3,\"traffic_bytes\":32212254720,\"days\":30,\"external_ref\":\"10231\"}'\n```\n\n## Units and time\n- Traffic is always whole bytes (1 GB here = 1073741824 bytes). `null` limit means unlimited.\n- Times are ISO 8601 with the server offset (+03:30). Send times with an offset.\n- Lists return `data` and `next_cursor`; pass it as `cursor` to get the next page.\n- To follow changes use `GET /v1/peers?updated_since=...`. Traffic counters are refreshed by the panel about once a\n  minute (`usage_updated_at`).\n\n## Retries (Idempotency-Key)\nCreating, renewing, adding traffic and adding L2TP need the header `Idempotency-Key`. Make one per operation (for\nexample from your order id) and save it before calling.\n- Network error or timeout: send the same request with the same key. You get the first result, nothing is done twice\n  (the answer has the header `Idempotent-Replayed: true`).\n- `request_in_progress`: wait and retry with the same key.\n- `outcome_unknown`: look the peer up (for example `?external_ref=`) before using a new key.\n- A refused request (for example `insufficient_credit`) frees the key.\n\n## Limits\nWithout fixed IP addresses a key works from anywhere with the lower limits. If your server has a fixed address, add it\nin Settings → API access: then only those addresses can use your keys, and the limits are higher.\nTiers as reads per minute | changes per minute | changes in flight | changes per day. Changes of one account are\napplied one after another: \"in flight\" is how many may be sent at the same time, the extra ones waiting up to\n15 seconds for their turn (then `server_busy`; retry with the same Idempotency-Key).\n- Any address: 600 | 60 | 1 | 5000\n- Fixed addresses: 1200 | 120 | 3 | 20000\nYour account owner may set other values; `GET /v1/me` shows yours. Every answer carries `X-RateLimit-Limit`,\n`X-RateLimit-Remaining` and `X-RateLimit-Reset`; on 429 or 503 wait for `Retry-After` seconds.\n20 wrong keys in a minute block an address for the rest of that minute.\n\n## Errors\nEvery error is `{\"error\": {\"code\", \"message\", \"message_fa\", \"details\", \"request_id\"}}`. Decide by `code`, never by\nthe message. Give `request_id` to support. After `operation_failed`, check the resource before trying again.\n\n## Agent types\n- Limited agents pay from a traffic wallet (one, or one per router), cannot choose unlimited traffic or time (a credit\n  plan your account owner gave you may be unlimited) and renew at most 90 days at a time. Deleting a peer returns the\n  unused traffic.\n- Deleting a client (L2TP) switches its WireGuard peer off and leaves it without limits. Delete that peer to get the\n  unused traffic back, or renew it with new traffic and duration. `DELETE /v1/peers/<built-in function id>` on a peer with L2TP does\n  both steps in one call.\n- Unlimited agents have no traffic wallet; they may send `unlimited_traffic` and `unlimited_time`.\n- Plan-only accounts must use `plan_id`. Peer limits, per router too, apply to everyone. No agent sets a speed per peer.\n\n## Examples and tools\n- A ready client in Python: `GET /v1/examples/mikropanel.py` (standard library only).\n- A ready client in PHP: `GET /v1/examples/mikropanel.php` (curl).\n- Postman collection of every endpoint: `GET /v1/postman.json`. Set the `api_key` variable.\n\n## Changes\n- 1.0.0: first release. Account, routers, plans, peers, L2TP clients and usage.\n"},"servers":[{"url":"https://api.mikropanel.ir"}],"security":[{"apiKey":[]}],"paths":{"/v1/me":{"get":{"operationId":"me","summary":"Who this key is, what it may do and its limits","tags":["Account"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/me/balance":{"get":{"operationId":"balance","summary":"Traffic credit, peer quota and plan credits","tags":["Account"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/me/stats":{"get":{"operationId":"stats","summary":"Peer counts and traffic sold","tags":["Account"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/routers":{"get":{"operationId":"routers_list","summary":"Routers assigned to you, with limits and availability","tags":["Routers"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/routers/{router_id}":{"get":{"operationId":"router_get","summary":"One assigned router","tags":["Routers"],"description":"","parameters":[{"name":"router_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/plans":{"get":{"operationId":"plans_list","summary":"Your credit plans with remaining credits","tags":["Plans"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/plans/{plan_id}":{"get":{"operationId":"plan_get","summary":"One credit plan","tags":["Plans"],"description":"","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/l2tp-servers":{"get":{"operationId":"l2tp_servers","summary":"Routers where you can sell L2TP","tags":["L2TP clients"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/peers":{"get":{"operationId":"list_peers","summary":"List your peers, newest first","tags":["Peers"],"description":"","parameters":[{"name":"limit","in":"query","required":false,"description":"Items per page (default 50).","schema":{"type":"integer","minimum":1,"maximum":200}},{"name":"cursor","in":"query","required":false,"description":"next_cursor of the previous page.","schema":{"type":"integer","minimum":1}},{"name":"status","in":"query","required":false,"description":"Only this status.","schema":{"type":"string","maxLength":255,"enum":["suspended","active","limit_reached","disabled_by_owner","not_started","pending_deletion"]}},{"name":"router_id","in":"query","required":false,"description":"Only this router.","schema":{"type":"integer","minimum":1}},{"name":"name","in":"query","required":false,"description":"Name contains this text.","schema":{"type":"string","maxLength":64}},{"name":"external_ref","in":"query","required":false,"description":"Exactly this external_ref.","schema":{"type":"string","maxLength":128}},{"name":"customer_telegram_id","in":"query","required":false,"description":"Exactly this Telegram id.","schema":{"type":"integer","minimum":1,"maximum":4611686018427387904}},{"name":"updated_since","in":"query","required":false,"description":"Settings or status changed at or after this time (traffic counters alone do not count).","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"},"post":{"operationId":"create_peer","summary":"Create a peer (WireGuard, optionally with L2TP)","tags":["Peers"],"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.","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"A new value for every new operation; the same value on a retry.","schema":{"type":"string","minLength":8,"maxLength":128}}],"responses":{"201":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":64,"examples":["ali-phone"],"description":"3-30 characters: letters, digits, - and _. Unique per router."},"router_id":{"type":"integer","minimum":1,"description":"Needed when you have several routers and the plan does not fix one."},"plan_id":{"type":"integer","minimum":1,"description":"Use a credit plan: it decides every limit."},"start_now":{"type":"boolean","description":"With a plan: start the clock now instead of at the first connection."},"traffic_bytes":{"type":"integer","minimum":1048576,"maximum":107374182400000,"examples":[32212254720],"description":"Traffic limit in bytes."},"unlimited_traffic":{"type":"boolean","description":"No traffic limit (unlimited agents only)."},"days":{"type":"integer","minimum":1,"maximum":3650,"examples":[30],"description":"Duration in days."},"unlimited_time":{"type":"boolean","description":"No expiry (unlimited agents only)."},"expires_at":{"type":"string","format":"date-time","description":"Exact expiry instead of (or besides) days."},"start_on_first_connect":{"type":"boolean","description":"Count the days from the first connection."},"show_as_unlimited":{"type":"boolean","description":"Limited agents: show the customer \"unlimited\" (the limit still applies)."},"protocols":{"type":"array","items":{"type":"string","enum":["wireguard","l2tp"]},"description":"[\"wireguard\"] (default) or [\"wireguard\",\"l2tp\"]. A plan decides this itself."},"description":{"type":"string","maxLength":500,"description":"Your note."},"external_ref":{"type":"string","maxLength":128,"description":"Your own id for this peer (order id). Unique among your peers."},"customer_telegram_id":{"type":"integer","minimum":1,"maximum":4611686018427387904,"description":"Telegram id of your customer."}},"required":["name"]}}}}}},"/v1/peers/{peer_id}":{"get":{"operationId":"get_peer","summary":"One peer with its gift code and public page link","tags":["Peers"],"description":"","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"},"patch":{"operationId":"edit_peer","summary":"Change name, description or your own references","tags":["Peers"],"description":"","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"name":{"type":"string","maxLength":64,"description":"New name (also renamed on the router)."},"description":{"type":"string","maxLength":500,"description":"New note; \"\" clears it."},"external_ref":{"type":"string","maxLength":128,"description":"Your own id; \"\" clears it."},"customer_telegram_id":{"type":"integer","minimum":0,"maximum":4611686018427387904,"description":"Telegram id of your customer; 0 clears it."}}}}}}},"delete":{"operationId":"delete_peer","summary":"Delete a peer","tags":["Peers"],"description":"A limited agent gets the unused traffic back as the panel does. A peer with L2TP is deleted together with its client.","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write"}},"/v1/peers/{peer_id}/config":{"get":{"operationId":"get_config","summary":"WireGuard configuration","tags":["Peers"],"description":"","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"format","in":"query","required":false,"description":"json (default) or file.","schema":{"type":"string","maxLength":255,"enum":["json","file"]}},{"name":"use_domain","in":"query","required":false,"description":"Use the router's current domain as endpoint (default true).","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:config"}},"/v1/peers/{peer_id}/qr":{"get":{"operationId":"get_qr","summary":"QR code of the configuration (PNG)","tags":["Peers"],"description":"","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"use_domain","in":"query","required":false,"description":"Use the router's current domain as endpoint (default true).","schema":{"type":"boolean"}}],"responses":{"200":{"description":"Success","content":{"image/png":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:config"}},"/v1/peers/{peer_id}/renew":{"post":{"operationId":"renew_peer","summary":"Renew a peer with a plan or your own limits","tags":["Peers"],"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.","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"Idempotency-Key","in":"header","required":true,"description":"A new value for every new operation; the same value on a retry.","schema":{"type":"string","minLength":8,"maxLength":128}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"plan_id":{"type":"integer","minimum":1,"description":"Use a credit plan: it decides every limit."},"start_now":{"type":"boolean","description":"With a plan: start the clock now instead of at the first connection."},"traffic_bytes":{"type":"integer","minimum":1048576,"maximum":107374182400000,"examples":[32212254720],"description":"Traffic limit in bytes."},"unlimited_traffic":{"type":"boolean","description":"No traffic limit (unlimited agents only)."},"days":{"type":"integer","minimum":1,"maximum":3650,"examples":[30],"description":"Duration in days."},"unlimited_time":{"type":"boolean","description":"No expiry (unlimited agents only)."},"expires_at":{"type":"string","format":"date-time","description":"Exact new expiry."},"mode":{"type":"string","maxLength":255,"enum":["set","add"],"description":"set or add."},"reset_usage":{"type":"boolean","description":"Start counting usage from zero (set mode; say the new traffic too)."},"start_on_first_connect":{"type":"boolean","description":"Only for a peer with L2TP renewed with your own limits."}}}}}}}},"/v1/peers/{peer_id}/suspend":{"post":{"operationId":"suspend_peer","summary":"Suspend a peer","tags":["Peers"],"description":"","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write"}},"/v1/peers/{peer_id}/unsuspend":{"post":{"operationId":"unsuspend_peer","summary":"Lift a suspension","tags":["Peers"],"description":"Refused with renew_required when the traffic or time is used up.","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write"}},"/v1/clients":{"get":{"operationId":"list_clients","summary":"List your clients, newest first","tags":["L2TP clients"],"description":"","parameters":[{"name":"limit","in":"query","required":false,"description":"Items per page (default 50).","schema":{"type":"integer","minimum":1,"maximum":200}},{"name":"cursor","in":"query","required":false,"description":"next_cursor of the previous page.","schema":{"type":"integer","minimum":1}},{"name":"status","in":"query","required":false,"description":"Only this status.","schema":{"type":"string","maxLength":255,"enum":["inactive","active","limit_reached","suspended","not_started"]}},{"name":"router_id","in":"query","required":false,"description":"Only this router.","schema":{"type":"integer","minimum":1}},{"name":"name","in":"query","required":false,"description":"Name contains this text.","schema":{"type":"string","maxLength":64}},{"name":"updated_since","in":"query","required":false,"description":"Changed at or after this time.","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/clients/{client_id}":{"get":{"operationId":"get_client","summary":"One client with its accounts","tags":["L2TP clients"],"description":"","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"},"delete":{"operationId":"delete_client","summary":"Delete a client","tags":["L2TP clients"],"description":"The L2TP account is removed. The WireGuard peer stays, switched off; delete it with DELETE /peers/{id} (a limited agent is refunded then).","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write"}},"/v1/clients/{client_id}/credentials":{"get":{"operationId":"get_credentials","summary":"L2TP login of a client","tags":["L2TP clients"],"description":"","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:config"}},"/v1/clients/from-peer":{"post":{"operationId":"client_from_peer","summary":"Turn one of your peers into a client","tags":["L2TP clients"],"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.","parameters":[{"name":"Idempotency-Key","in":"header","required":true,"description":"A new value for every new operation; the same value on a retry.","schema":{"type":"string","minLength":8,"maxLength":128}}],"responses":{"201":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"peer_id":{"type":"integer","minimum":1,"description":"Your standalone peer."},"protocols":{"type":"array","items":{"type":"string","enum":["wireguard","l2tp"]},"description":"Default [\"wireguard\",\"l2tp\"]."}},"required":["peer_id"]}}}}}},"/v1/clients/{client_id}/l2tp":{"post":{"operationId":"add_l2tp","summary":"Add L2TP to a client","tags":["L2TP clients"],"description":"","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"Idempotency-Key","in":"header","required":true,"description":"A new value for every new operation; the same value on a retry.","schema":{"type":"string","minLength":8,"maxLength":128}}],"responses":{"201":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write"}},"/v1/clients/{client_id}/renew":{"post":{"operationId":"renew_client","summary":"Start a new period for a client","tags":["L2TP clients"],"description":"Give plan_id, or both traffic (or unlimited_traffic) and days (or unlimited_time). Usage restarts. Limited agents: at most 90 days.","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"Idempotency-Key","in":"header","required":true,"description":"A new value for every new operation; the same value on a retry.","schema":{"type":"string","minLength":8,"maxLength":128}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write","requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"plan_id":{"type":"integer","minimum":1,"description":"Use a credit plan: it decides every limit."},"start_now":{"type":"boolean","description":"With a plan: start the clock now instead of at the first connection."},"traffic_bytes":{"type":"integer","minimum":1048576,"maximum":107374182400000,"examples":[32212254720],"description":"Traffic limit in bytes."},"unlimited_traffic":{"type":"boolean","description":"No traffic limit (unlimited agents only)."},"days":{"type":"integer","minimum":1,"maximum":3650,"examples":[30],"description":"Duration in days."},"unlimited_time":{"type":"boolean","description":"No expiry (unlimited agents only)."},"start_on_first_connect":{"type":"boolean","description":"Count the days from the first connection."}}}}}}}},"/v1/clients/{client_id}/add-traffic":{"post":{"operationId":"add_traffic","summary":"Raise a client's traffic limit","tags":["L2TP clients"],"description":"A limited agent pays the added traffic from its wallet.","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"Idempotency-Key","in":"header","required":true,"description":"A new value for every new operation; the same value on a retry.","schema":{"type":"string","minLength":8,"maxLength":128}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"properties":{"traffic_bytes":{"type":"integer","minimum":1048576,"maximum":107374182400000,"examples":[10737418240],"description":"Bytes to add."}},"required":["traffic_bytes"]}}}}}},"/v1/clients/{client_id}/disable":{"post":{"operationId":"disable_client","summary":"Disable a client (all protocols)","tags":["L2TP clients"],"description":"","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write"}},"/v1/clients/{client_id}/enable":{"post":{"operationId":"enable_client","summary":"Enable a client","tags":["L2TP clients"],"description":"Refused with renew_required when the traffic or time is used up.","parameters":[{"name":"client_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"peers:write"}},"/v1/health":{"get":{"operationId":"health","summary":"Is the API up and can it reach its database","tags":["Service"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[]}},"/v1/openapi.json":{"get":{"operationId":"openapi_json","summary":"OpenAPI 3.1 description","tags":["Service"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[]}},"/v1/docs":{"get":{"operationId":"docs","summary":"This reference (HTML)","tags":["Service"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"text/html":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[]}},"/v1/postman.json":{"get":{"operationId":"postman_json","summary":"Postman collection of every endpoint","tags":["Service"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[]}},"/v1/examples/mikropanel.py":{"get":{"operationId":"example_python","summary":"Example client in Python","tags":["Service"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"text/plain":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[]}},"/v1/examples/mikropanel.php":{"get":{"operationId":"example_php","summary":"Example client in PHP","tags":["Service"],"description":"","parameters":[],"responses":{"200":{"description":"Success","content":{"text/plain":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"security":[]}},"/v1/peers/{peer_id}/usage":{"get":{"operationId":"peer_usage","summary":"Daily or hourly traffic of one peer","tags":["Usage"],"description":"A day range covers at most 366 days. L2TP traffic has totals only (see the client).","parameters":[{"name":"peer_id","in":"path","required":true,"schema":{"type":"integer","minimum":0}},{"name":"interval","in":"query","required":false,"description":"day (default) or hour.","schema":{"type":"string","maxLength":255,"enum":["day","hour"]}},{"name":"from","in":"query","required":false,"description":"interval=day: first day (default 29 days before \"to\").","schema":{"type":"string","format":"date"}},{"name":"to","in":"query","required":false,"description":"interval=day: last day (default today).","schema":{"type":"string","format":"date"}},{"name":"date","in":"query","required":false,"description":"interval=hour: the day (default today).","schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}},"/v1/usage":{"get":{"operationId":"account_usage","summary":"Daily or hourly traffic of all your peers","tags":["Usage"],"description":"","parameters":[{"name":"interval","in":"query","required":false,"description":"day (default) or hour.","schema":{"type":"string","maxLength":255,"enum":["day","hour"]}},{"name":"from","in":"query","required":false,"description":"interval=day: first day (default 29 days before \"to\").","schema":{"type":"string","format":"date"}},{"name":"to","in":"query","required":false,"description":"interval=day: last day (default today).","schema":{"type":"string","format":"date"}},{"name":"date","in":"query","required":false,"description":"interval=hour: the day (default today).","schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Success","content":{"application/json":{}}},"default":{"description":"Refused or failed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"x-required-scope":"read"}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"An API key starting with mp_live_"}},"schemas":{"Error":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","enum":["account_inactive","add_to_unlimited","agent_needs_wireguard","already_member","api_disabled","bad_content_type","bad_json","bad_protocols","bad_value","billing_unsupported","body_too_large","client_renew_unsupported","clients_disabled","clients_not_allowed","config_unavailable","conflicting_fields","credits_expired","daily_limit_reached","database_unavailable","duration_required","encryption_unavailable","expiry_in_past","external_ref_taken","group_not_supported","https_required","idempotency_key_required","idempotency_key_reused","in_client","in_group","insufficient_credit","insufficient_credits","insufficient_scope","internal_error","invalid_api_key","invalid_name","invalid_plan","ip_not_allowed","l2tp_failed","l2tp_not_allowed","l2tp_unavailable","member_not_found","method_not_allowed","missing_api_key","missing_field","name_taken","no_agent_profile","no_credits","no_free_ip","no_l2tp","no_router_assigned","no_server","not_agent","not_found","nothing_to_renew","operation_failed","out_of_range","outcome_unknown","peer_limit_reached","peer_locked","peer_manager_unavailable","peer_not_attachable","plan_conversion_needs_limits","plan_credit_only","plan_group_unsupported","plan_mode_disabled","plan_not_found","plan_protocols","plan_router_mismatch","protocol_present","rate_limited","renew_days_limit","renew_required","request_in_progress","router_busy","router_full","router_not_assigned","router_not_found","router_not_ready","router_peer_cap_reached","router_peer_cap_unset","router_required","router_unreachable","server_busy","speed_not_allowed","too_many_auth_failures","too_many_concurrent_writes","traffic_required","unknown_field","unlimited","unlimited_not_allowed"]},"message":{"type":"string"},"message_fa":{"type":"string"},"details":{"type":"object"},"request_id":{"type":"string"}}}}}}}}
