{"openapi":"3.1.0","info":{"title":"Nabeghe Partner API","description":"Account, API key, wallet, usage and reseller management — for any authenticated external system.","version":"1.0.0"},"servers":[{"url":"/partner"}],"paths":{"/v1/account":{"get":{"tags":["partner"],"summary":"Get my account","description":"The account that owns the management key used to authenticate this request.","operationId":"my_account_v1_account_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/wallet":{"get":{"tags":["partner"],"summary":"Get my wallet balance","operationId":"my_wallet_v1_wallet_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/usage":{"get":{"tags":["partner"],"summary":"Get my usage (month-to-date)","operationId":"my_usage_v1_usage_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/api-keys":{"get":{"tags":["partner"],"summary":"List my gateway keys","operationId":"my_keys_v1_api_keys_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"tags":["partner"],"summary":"Create a gateway key","description":"Always mints a kind=\"gateway\" key (valid on /v1/chat/completions) for the SAME account as the management key used to call this. A management key can never mint another management key.","operationId":"my_key_create_v1_api_keys_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyCreateIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/api-keys/{kid}/revoke":{"post":{"tags":["partner"],"summary":"Revoke one of my gateway keys","description":"Permanent. Cannot revoke the management key currently authenticating this request.","operationId":"my_key_revoke_v1_api_keys__kid__revoke_post","parameters":[{"name":"kid","in":"path","required":true,"schema":{"type":"integer","title":"Kid"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers":{"get":{"tags":["partner"],"summary":"List my customers (reseller only)","operationId":"customers_list_v1_customers_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}},"post":{"tags":["partner"],"summary":"Create a customer (reseller only)","description":"Requires a reseller account. Idempotent via `external_ref`: a retried call with the same external_ref returns the existing customer instead of creating a duplicate.","operationId":"customer_create_v1_customers_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}":{"get":{"tags":["partner"],"summary":"Get one customer (reseller only)","operationId":"customer_detail_v1_customers__cid__get","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["partner"],"summary":"Update a customer (reseller only)","operationId":"customer_patch_v1_customers__cid__patch","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerPatch"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}/usage":{"get":{"tags":["partner"],"summary":"Get a customer's usage (reseller only)","operationId":"customer_usage_v1_customers__cid__usage_get","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}/api-keys":{"get":{"tags":["partner"],"summary":"List a customer's gateway keys (reseller only)","operationId":"customer_keys_list_v1_customers__cid__api_keys_get","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["partner"],"summary":"Create a gateway key for a customer (reseller only)","operationId":"customer_key_create_v1_customers__cid__api_keys_post","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KeyCreateIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}/api-keys/{kid}/revoke":{"post":{"tags":["partner"],"summary":"Revoke a customer's gateway key (reseller only)","operationId":"customer_key_revoke_v1_customers__cid__api_keys__kid__revoke_post","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}},{"name":"kid","in":"path","required":true,"schema":{"type":"integer","title":"Kid"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}/wallet":{"get":{"tags":["partner"],"summary":"Get a customer's wallet balance (reseller only)","operationId":"customer_wallet_v1_customers__cid__wallet_get","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}/wallet/topup":{"post":{"tags":["partner"],"summary":"Top up a customer's wallet (reseller only)","description":"Self-service top-up is OFF (403 topup_not_enabled) until a platform admin grants this reseller a daily+monthly cap. Idempotent via `ref_id`: a retried call with the same ref_id returns the original result, never double-credits. Rejects with 429 if the rolling daily or monthly cap would be exceeded.","operationId":"customer_wallet_topup_v1_customers__cid__wallet_topup_post","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TopupIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}/wallet/charge":{"post":{"tags":["partner"],"summary":"Debit a fixed amount from a customer's wallet (reseller only)","description":"For services delivered outside the gateway. 402 insufficient_balance if the wallet can't cover it. Idempotent via `ref_id`.","operationId":"customer_wallet_charge_v1_customers__cid__wallet_charge_post","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChargeIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/customers/{cid}/wallet/refund":{"post":{"tags":["partner"],"summary":"Refund an earlier /wallet/charge in full (reseller only)","description":"Gives back exactly what that charge took. Idempotent: a second call returns the first refund.","operationId":"customer_wallet_refund_v1_customers__cid__wallet_refund_post","parameters":[{"name":"cid","in":"path","required":true,"schema":{"type":"integer","title":"Cid"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RefundIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"ChargeIn":{"properties":{"amount_rial":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount Rial","description":"Amount to debit, in Rial (IRR). Must be positive."},"ref_id":{"type":"string","maxLength":60,"minLength":1,"title":"Ref Id","description":"Your idempotency key (e.g. your order id). Reusing it never debits twice."},"note":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Note"}},"type":"object","required":["amount_rial","ref_id"],"title":"ChargeIn"},"CustomerIn":{"properties":{"name":{"type":"string","maxLength":160,"minLength":1,"title":"Name","description":"Display name for this customer's account."},"external_ref":{"anyOf":[{"type":"string","maxLength":120},{"type":"null"}],"title":"External Ref","description":"Your own id for this customer (e.g. your user id). Unique per your reseller account — reused on retry to get the same customer back instead of a duplicate."},"note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Note","description":"Free-text note, staff-visible only."},"markup_bps":{"anyOf":[{"type":"integer","maximum":100000.0,"minimum":0.0},{"type":"null"}],"title":"Markup Bps","description":"This customer's own markup in basis points (100 = 1%). Omit to inherit your reseller markup."},"owner_phone":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Owner Phone","description":"Optional — links this customer to a phone-login identity so they can also sign in to the standard customer dashboard themselves."},"type":{"type":"string","pattern":"^(individual|business)$","title":"Type","default":"business"}},"type":"object","required":["name"],"title":"CustomerIn"},"CustomerPatch":{"properties":{"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"markup_bps":{"anyOf":[{"type":"integer","maximum":100000.0,"minimum":0.0},{"type":"null"}],"title":"Markup Bps"},"clear_markup":{"type":"boolean","title":"Clear Markup","default":false},"status":{"anyOf":[{"type":"string","pattern":"^(active|suspended)$"},{"type":"null"}],"title":"Status"}},"type":"object","title":"CustomerPatch"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"KeyCreateIn":{"properties":{"name":{"type":"string","maxLength":80,"title":"Name","description":"Label shown in the key list — not shown to end users.","default":"کلید"},"rpm_limit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Rpm Limit","description":"Requests/minute cap enforced by the gateway. Omit for no cap."},"tpm_limit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Tpm Limit","description":"Tokens/minute cap enforced by the gateway. Omit for no cap."},"concurrency_limit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Concurrency Limit","description":"Max simultaneous in-flight requests on this key."},"monthly_cap_rial":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Monthly Cap Rial","description":"Hard monthly spend ceiling in Rial for this key alone."}},"type":"object","title":"KeyCreateIn"},"RefundIn":{"properties":{"ref_id":{"type":"string","maxLength":60,"minLength":1,"title":"Ref Id","description":"The ref_id of the earlier /wallet/charge to give back in full."},"note":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Note"}},"type":"object","required":["ref_id"],"title":"RefundIn"},"TopupIn":{"properties":{"amount_rial":{"type":"integer","exclusiveMinimum":0.0,"title":"Amount Rial","description":"Amount to credit, in Rial (IRR). Must be positive."},"ref_id":{"type":"string","maxLength":120,"minLength":1,"title":"Ref Id","description":"Your own idempotency key for this top-up (e.g. your payment/order id). Reusing it returns the original result instead of crediting twice."},"note":{"anyOf":[{"type":"string","maxLength":255},{"type":"null"}],"title":"Note","description":"Free-text note stored on the ledger entry, staff-visible only."}},"type":"object","required":["amount_rial","ref_id"],"title":"TopupIn"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}}}