> For the complete documentation index, see [llms.txt](https://docs.kiiglobal.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kiiglobal.io/docs/kiichain-pay/api-reference/accounts.md). Agents can also search and read this documentation through its [MCP server](https://docs.kiiglobal.io/docs/~gitbook/mcp).

# Accounts

## GetAccountInfo returns the account information for the provided account id

> Only the account\_id is needed, ownership is checked against the caller.\
> Use GetUserByAccountId to resolve the owning user

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["users.accounts.read","users.accounts.read:all"]},{"BearerAuth":["users.accounts.read","users.accounts.read:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetAccountInfoResponse":{"properties":{"account":{"$ref":"#/components/schemas/v1Account"}},"required":["account"],"title":"GetAccountInfoResponse is the body response structure from the Get account info endpoints","type":"object"},"v1Account":{"properties":{"accountName":{"title":"account_name is the name of the account","type":"string"},"accountType":{"title":"account_type is the type of the account","type":"string"},"countries":{"items":{"type":"string"},"title":"countries is the list of countries associated to the account, in ISO 3166-1 alpha-3 format","type":"array"},"createdAt":{"format":"date-time","title":"created_at is the date when the account was created","type":"string"},"deletedAt":{"format":"date-time","title":"deleted_at is the date when the account was deleted","type":"string"},"id":{"title":"id is the account identifier","type":"string"},"kycInfo":{"$ref":"#/components/schemas/v1KycInfo"},"privyId":{"title":"privy_id is the identifier of the account on Privy, which is the Wallet provider used by default","type":"string"},"subscription":{"$ref":"#/components/schemas/v1Subscription"},"updatedAt":{"format":"date-time","title":"updated_at is the date when the account was updated","type":"string"},"userId":{"title":"account_name is the user-assigned name of the account","type":"string"},"wallets":{"items":{"$ref":"#/components/schemas/v1Wallet"},"title":"wallets is the information about the wallets associated to the account","type":"array"}},"required":["id","userId","accountName","accountType","wallets","kycInfo","createdAt","updatedAt","privyId"],"title":"Account contains all information with a account","type":"object"},"v1KycInfo":{"properties":{"level":{"format":"int32","title":"level is the name of the KYC level approved","type":"integer"},"provider":{"title":"provider is the KYC provider name","type":"string"},"requestedAt":{"format":"date-time","title":"requested_at is the date when the KYC was requested","type":"string"},"status":{"title":"status is the KYC status","type":"string"},"verifiedAt":{"format":"date-time","title":"verified_at is the date when the KYC was verified","type":"string"}},"required":["provider","level","status","requestedAt","verifiedAt"],"title":"KycInfo contains the KYC information per account","type":"object"},"v1Subscription":{"properties":{"code":{"title":"code is the stable identifier of the subscription plan","type":"string"},"status":{"title":"status is the subscription status. One of: trialing, active, past_due, canceled,\nunpaid, incomplete, paused","type":"string"},"tier":{"format":"int32","title":"tier ranks the plan's access level, higher grants more access","type":"integer"}},"required":["code","tier","status"],"title":"Subscription identifies the billing plan an account is (or was) subscribed to","type":"object"},"v1Wallet":{"properties":{"address":{"title":"address is the unique wallet address","type":"string"},"chainType":{"title":"chain_type is which chain is using this wallet","type":"string"},"id":{"title":"id is the wallet identifier","type":"string"}},"required":["id","address","chainType"],"title":"Wallet contains all information about a wallet","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}":{"get":{"description":"Only the account_id is needed, ownership is checked against the caller.\nUse GetUserByAccountId to resolve the owning user","operationId":"AccountsQueryService_GetAccountInfo","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetAccountInfoResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetAccountInfo returns the account information for the provided account id","tags":["AccountsQueryService"]}}}}
```

## GetAccountCountries returns the list of countries associated with an account

> Set via UpdateAccountCountries — for the full catalog of registered\
> countries use ListCountries instead

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.kyc.read","accounts.kyc.read:all"]},{"BearerAuth":["accounts.kyc.read","accounts.kyc.read:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetAccountCountriesResponse":{"properties":{"countries":{"items":{"type":"string"},"title":"countries is the list of ISO 3166-1 alpha-3 country codes associated with the account","type":"array"}},"required":["countries"],"title":"GetAccountCountriesResponse is the response for the get-account-countries endpoint","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/countries":{"get":{"description":"Set via UpdateAccountCountries — for the full catalog of registered\ncountries use ListCountries instead","operationId":"AccountsQueryService_GetAccountCountries","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetAccountCountriesResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetAccountCountries returns the list of countries associated with an account","tags":["AccountsQueryService"]}}}}
```

## GetAccountLimits returns the limits information for the provided account id

> Merges the level's default limits with any active per-account overrides,\
> and includes current usage

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["users.accounts.read","users.accounts.read:all"]},{"BearerAuth":["users.accounts.read","users.accounts.read:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetAccountLimitsResponse":{"properties":{"limits":{"items":{"$ref":"#/components/schemas/v1AccountLimitWithUsage"},"title":"limits contains the account limits information","type":"array"}},"required":["limits"],"title":"GetAccountLimitsResponse is the body response structure from the Get account limits endpoint","type":"object"},"v1AccountLimitWithUsage":{"properties":{"amountUsd":{"title":"amount_usd defines the amount of the limit in USD","type":"string"},"id":{"title":"id represents the limit identifier","type":"string"},"level":{"format":"int32","title":"level defines the level of the account","type":"integer"},"limitAction":{"title":"limit_action defines the action (withdrawal | deposit | swap)","type":"string"},"name":{"title":"name defines the name of the level","type":"string"},"periodDays":{"format":"int32","title":"period_days defines the period of the limit in days","type":"integer"},"usedAmountUsd":{"title":"used_amount_usd defines the used amount of the limit in USD","type":"string"}},"required":["id","level","name","limitAction","amountUsd","usedAmountUsd","periodDays"],"title":"AccountLimitWithUsage defines the type of account limit with usage information","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/limits":{"get":{"description":"Merges the level's default limits with any active per-account overrides,\nand includes current usage","operationId":"AccountsQueryService_GetAccountLimits","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetAccountLimitsResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetAccountLimits returns the limits information for the provided account id","tags":["AccountsQueryService"]}}}}
```

## ListSubaccounts returns the subaccounts of a company account

> Newest first, paginated. external\_ref filters to an exact match

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.subaccounts.read","accounts.subaccounts.read:all"]},{"BearerAuth":["accounts.subaccounts.read","accounts.subaccounts.read:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1ListSubaccountsResponse":{"properties":{"pagination":{"$ref":"#/components/schemas/v1Pagination"},"subaccounts":{"items":{"$ref":"#/components/schemas/v1Subaccount"},"title":"subaccounts is the page of subaccounts, newest first","type":"array"}},"required":["subaccounts","pagination"],"title":"ListSubaccountsResponse is the response of the ListSubaccounts endpoint","type":"object"},"v1Pagination":{"properties":{"currentPage":{"format":"int32","title":"current_page is the current page number","type":"integer"},"limit":{"format":"int32","title":"limit contains the limit used to calculate the page","type":"integer"},"totalItems":{"format":"int32","title":"total_items is the total number of items","type":"integer"},"totalPages":{"format":"int32","title":"total_pages is the total number of pages","type":"integer"}},"required":["currentPage","totalItems","totalPages","limit"],"title":"Pagination contains the keys to move between pages\nusing the cursor-based pagination","type":"object"},"v1Subaccount":{"properties":{"account":{"$ref":"#/components/schemas/v1Account"},"externalRef":{"title":"external_ref is the company's own identifier for the subaccount, such as its customer id","type":"string"},"parentAccountId":{"title":"parent_account_id is the company account the subaccount belongs to","type":"string"}},"required":["account","parentAccountId"],"title":"Subaccount is an account a company operates on behalf of one of its customers","type":"object"},"v1Account":{"properties":{"accountName":{"title":"account_name is the name of the account","type":"string"},"accountType":{"title":"account_type is the type of the account","type":"string"},"countries":{"items":{"type":"string"},"title":"countries is the list of countries associated to the account, in ISO 3166-1 alpha-3 format","type":"array"},"createdAt":{"format":"date-time","title":"created_at is the date when the account was created","type":"string"},"deletedAt":{"format":"date-time","title":"deleted_at is the date when the account was deleted","type":"string"},"id":{"title":"id is the account identifier","type":"string"},"kycInfo":{"$ref":"#/components/schemas/v1KycInfo"},"privyId":{"title":"privy_id is the identifier of the account on Privy, which is the Wallet provider used by default","type":"string"},"subscription":{"$ref":"#/components/schemas/v1Subscription"},"updatedAt":{"format":"date-time","title":"updated_at is the date when the account was updated","type":"string"},"userId":{"title":"account_name is the user-assigned name of the account","type":"string"},"wallets":{"items":{"$ref":"#/components/schemas/v1Wallet"},"title":"wallets is the information about the wallets associated to the account","type":"array"}},"required":["id","userId","accountName","accountType","wallets","kycInfo","createdAt","updatedAt","privyId"],"title":"Account contains all information with a account","type":"object"},"v1KycInfo":{"properties":{"level":{"format":"int32","title":"level is the name of the KYC level approved","type":"integer"},"provider":{"title":"provider is the KYC provider name","type":"string"},"requestedAt":{"format":"date-time","title":"requested_at is the date when the KYC was requested","type":"string"},"status":{"title":"status is the KYC status","type":"string"},"verifiedAt":{"format":"date-time","title":"verified_at is the date when the KYC was verified","type":"string"}},"required":["provider","level","status","requestedAt","verifiedAt"],"title":"KycInfo contains the KYC information per account","type":"object"},"v1Subscription":{"properties":{"code":{"title":"code is the stable identifier of the subscription plan","type":"string"},"status":{"title":"status is the subscription status. One of: trialing, active, past_due, canceled,\nunpaid, incomplete, paused","type":"string"},"tier":{"format":"int32","title":"tier ranks the plan's access level, higher grants more access","type":"integer"}},"required":["code","tier","status"],"title":"Subscription identifies the billing plan an account is (or was) subscribed to","type":"object"},"v1Wallet":{"properties":{"address":{"title":"address is the unique wallet address","type":"string"},"chainType":{"title":"chain_type is which chain is using this wallet","type":"string"},"id":{"title":"id is the wallet identifier","type":"string"}},"required":["id","address","chainType"],"title":"Wallet contains all information about a wallet","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/subaccounts":{"get":{"description":"Newest first, paginated. external_ref filters to an exact match","operationId":"AccountsQueryService_ListSubaccounts","parameters":[{"description":"account_id is the parent company account","in":"path","name":"accountId","required":true,"schema":{"type":"string"}},{"description":"page is an optional query parameter to set the page","in":"query","name":"page","required":false,"schema":{"format":"int32","type":"integer"}},{"description":"limit is an optional query parameter to set the max number of results","in":"query","name":"limit","required":false,"schema":{"format":"int32","type":"integer"}},{"description":"external_ref is an optional exact-match filter on the company's identifier","in":"query","name":"externalRef","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1ListSubaccountsResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"ListSubaccounts returns the subaccounts of a company account","tags":["AccountsQueryService"]}}}}
```

## CreateSubaccount creates a subaccount under a company account

> The parent must be a KYC verified, top-level company account. The subaccount\
> is an individual account with no login of its own, the company operates it.\
> Calling again with the same external\_ref returns the existing subaccount

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Commands (write operations)","name":"AccountsMsgService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.subaccounts.write","accounts.subaccounts.write:all"]},{"BearerAuth":["accounts.subaccounts.write","accounts.subaccounts.write:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"AccountsMsgServiceCreateSubaccountBody":{"properties":{"country":{"title":"country is the subaccount's country in ISO 3166-1 alpha-3 format","type":"string"},"externalRef":{"title":"external_ref is the company's own identifier for the subaccount, unique within the company","type":"string"},"name":{"title":"name is the subaccount name, usually the customer's name","type":"string"}},"required":["name","country"],"title":"CreateSubaccountRequest is the request of the CreateSubaccount endpoint","type":"object"},"v1CreateSubaccountResponse":{"properties":{"subaccount":{"$ref":"#/components/schemas/v1Subaccount"}},"required":["subaccount"],"title":"CreateSubaccountResponse is the response of the CreateSubaccount endpoint","type":"object"},"v1Subaccount":{"properties":{"account":{"$ref":"#/components/schemas/v1Account"},"externalRef":{"title":"external_ref is the company's own identifier for the subaccount, such as its customer id","type":"string"},"parentAccountId":{"title":"parent_account_id is the company account the subaccount belongs to","type":"string"}},"required":["account","parentAccountId"],"title":"Subaccount is an account a company operates on behalf of one of its customers","type":"object"},"v1Account":{"properties":{"accountName":{"title":"account_name is the name of the account","type":"string"},"accountType":{"title":"account_type is the type of the account","type":"string"},"countries":{"items":{"type":"string"},"title":"countries is the list of countries associated to the account, in ISO 3166-1 alpha-3 format","type":"array"},"createdAt":{"format":"date-time","title":"created_at is the date when the account was created","type":"string"},"deletedAt":{"format":"date-time","title":"deleted_at is the date when the account was deleted","type":"string"},"id":{"title":"id is the account identifier","type":"string"},"kycInfo":{"$ref":"#/components/schemas/v1KycInfo"},"privyId":{"title":"privy_id is the identifier of the account on Privy, which is the Wallet provider used by default","type":"string"},"subscription":{"$ref":"#/components/schemas/v1Subscription"},"updatedAt":{"format":"date-time","title":"updated_at is the date when the account was updated","type":"string"},"userId":{"title":"account_name is the user-assigned name of the account","type":"string"},"wallets":{"items":{"$ref":"#/components/schemas/v1Wallet"},"title":"wallets is the information about the wallets associated to the account","type":"array"}},"required":["id","userId","accountName","accountType","wallets","kycInfo","createdAt","updatedAt","privyId"],"title":"Account contains all information with a account","type":"object"},"v1KycInfo":{"properties":{"level":{"format":"int32","title":"level is the name of the KYC level approved","type":"integer"},"provider":{"title":"provider is the KYC provider name","type":"string"},"requestedAt":{"format":"date-time","title":"requested_at is the date when the KYC was requested","type":"string"},"status":{"title":"status is the KYC status","type":"string"},"verifiedAt":{"format":"date-time","title":"verified_at is the date when the KYC was verified","type":"string"}},"required":["provider","level","status","requestedAt","verifiedAt"],"title":"KycInfo contains the KYC information per account","type":"object"},"v1Subscription":{"properties":{"code":{"title":"code is the stable identifier of the subscription plan","type":"string"},"status":{"title":"status is the subscription status. One of: trialing, active, past_due, canceled,\nunpaid, incomplete, paused","type":"string"},"tier":{"format":"int32","title":"tier ranks the plan's access level, higher grants more access","type":"integer"}},"required":["code","tier","status"],"title":"Subscription identifies the billing plan an account is (or was) subscribed to","type":"object"},"v1Wallet":{"properties":{"address":{"title":"address is the unique wallet address","type":"string"},"chainType":{"title":"chain_type is which chain is using this wallet","type":"string"},"id":{"title":"id is the wallet identifier","type":"string"}},"required":["id","address","chainType"],"title":"Wallet contains all information about a wallet","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/subaccounts":{"post":{"description":"The parent must be a KYC verified, top-level company account. The subaccount\nis an individual account with no login of its own, the company operates it.\nCalling again with the same external_ref returns the existing subaccount","operationId":"AccountsMsgService_CreateSubaccount","parameters":[{"description":"account_id is the parent company account","in":"path","name":"accountId","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountsMsgServiceCreateSubaccountBody"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1CreateSubaccountResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"CreateSubaccount creates a subaccount under a company account","tags":["AccountsMsgService"]}}}}
```

## GetSubaccount returns one subaccount of a company account

> A subaccount of another company is reported as not found

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.subaccounts.read","accounts.subaccounts.read:all"]},{"BearerAuth":["accounts.subaccounts.read","accounts.subaccounts.read:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetSubaccountResponse":{"properties":{"subaccount":{"$ref":"#/components/schemas/v1Subaccount"}},"required":["subaccount"],"title":"GetSubaccountResponse is the response of the GetSubaccount endpoint","type":"object"},"v1Subaccount":{"properties":{"account":{"$ref":"#/components/schemas/v1Account"},"externalRef":{"title":"external_ref is the company's own identifier for the subaccount, such as its customer id","type":"string"},"parentAccountId":{"title":"parent_account_id is the company account the subaccount belongs to","type":"string"}},"required":["account","parentAccountId"],"title":"Subaccount is an account a company operates on behalf of one of its customers","type":"object"},"v1Account":{"properties":{"accountName":{"title":"account_name is the name of the account","type":"string"},"accountType":{"title":"account_type is the type of the account","type":"string"},"countries":{"items":{"type":"string"},"title":"countries is the list of countries associated to the account, in ISO 3166-1 alpha-3 format","type":"array"},"createdAt":{"format":"date-time","title":"created_at is the date when the account was created","type":"string"},"deletedAt":{"format":"date-time","title":"deleted_at is the date when the account was deleted","type":"string"},"id":{"title":"id is the account identifier","type":"string"},"kycInfo":{"$ref":"#/components/schemas/v1KycInfo"},"privyId":{"title":"privy_id is the identifier of the account on Privy, which is the Wallet provider used by default","type":"string"},"subscription":{"$ref":"#/components/schemas/v1Subscription"},"updatedAt":{"format":"date-time","title":"updated_at is the date when the account was updated","type":"string"},"userId":{"title":"account_name is the user-assigned name of the account","type":"string"},"wallets":{"items":{"$ref":"#/components/schemas/v1Wallet"},"title":"wallets is the information about the wallets associated to the account","type":"array"}},"required":["id","userId","accountName","accountType","wallets","kycInfo","createdAt","updatedAt","privyId"],"title":"Account contains all information with a account","type":"object"},"v1KycInfo":{"properties":{"level":{"format":"int32","title":"level is the name of the KYC level approved","type":"integer"},"provider":{"title":"provider is the KYC provider name","type":"string"},"requestedAt":{"format":"date-time","title":"requested_at is the date when the KYC was requested","type":"string"},"status":{"title":"status is the KYC status","type":"string"},"verifiedAt":{"format":"date-time","title":"verified_at is the date when the KYC was verified","type":"string"}},"required":["provider","level","status","requestedAt","verifiedAt"],"title":"KycInfo contains the KYC information per account","type":"object"},"v1Subscription":{"properties":{"code":{"title":"code is the stable identifier of the subscription plan","type":"string"},"status":{"title":"status is the subscription status. One of: trialing, active, past_due, canceled,\nunpaid, incomplete, paused","type":"string"},"tier":{"format":"int32","title":"tier ranks the plan's access level, higher grants more access","type":"integer"}},"required":["code","tier","status"],"title":"Subscription identifies the billing plan an account is (or was) subscribed to","type":"object"},"v1Wallet":{"properties":{"address":{"title":"address is the unique wallet address","type":"string"},"chainType":{"title":"chain_type is which chain is using this wallet","type":"string"},"id":{"title":"id is the wallet identifier","type":"string"}},"required":["id","address","chainType"],"title":"Wallet contains all information about a wallet","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/subaccounts/{subaccountId}":{"get":{"description":"A subaccount of another company is reported as not found","operationId":"AccountsQueryService_GetSubaccount","parameters":[{"description":"account_id is the parent company account","in":"path","name":"accountId","required":true,"schema":{"type":"string"}},{"description":"subaccount_id is the subaccount to get","in":"path","name":"subaccountId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetSubaccountResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetSubaccount returns one subaccount of a company account","tags":["AccountsQueryService"]}}}}
```

## GetUserByAccountId returns the user information for the provided account id

> Resolves account\_id to its owning user

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["users.accounts.read","users.accounts.read:all"]},{"BearerAuth":["users.accounts.read","users.accounts.read:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetUserByAccountIdResponse":{"properties":{"accounts":{"items":{"type":"string"},"title":"accounts contains the list of account IDs the user belongs to","type":"array"},"user":{"$ref":"#/components/schemas/v1User"}},"required":["user","accounts"],"title":"GetUserByAccountIdResponse is the body response structure from the Get user by account id endpoint","type":"object"},"v1User":{"properties":{"admin":{"title":"admin is the boolean flag to know if the user is an admin (has access to the admin panel)","type":"boolean"},"createdAt":{"format":"date-time","title":"created_at is the date when the user was created","type":"string"},"deletedAt":{"format":"date-time","title":"deleted_at is the date when the user was deleted","type":"string"},"displayName":{"title":"display_name is the user display name","type":"string"},"email":{"title":"email is the user email","type":"string"},"emailVerified":{"title":"email_verified indicates whether the user's email has been verified","type":"boolean"},"id":{"title":"id is the user identifier","type":"string"},"isMfaEnabled":{"title":"isMfaEnabled is the boolean flag to enable/disable MFA","type":"boolean"},"language":{"title":"language contains the current user language which will be used on notifications","type":"string"},"lockReason":{"title":"lock_reason is the reason when the user is locked","type":"string"},"locked":{"title":"locked is the boolean flag to lock/unlock the user","type":"boolean"},"passwordChangedAt":{"format":"date-time","title":"password_changed_at is the date when the password was changed","type":"string"},"superAdmin":{"title":"super_admin is the boolean flag to enable/disable super admin permissions","type":"boolean"},"updatedAt":{"format":"date-time","title":"updated_at is the date when the user was updated","type":"string"}},"required":["id","email","displayName","isMfaEnabled","locked","superAdmin","language","createdAt","updatedAt","admin","emailVerified"],"title":"User contains all information with a user","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/user":{"get":{"description":"Resolves account_id to its owning user","operationId":"AccountsQueryService_GetUserByAccountId","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetUserByAccountIdResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetUserByAccountId returns the user information for the provided account id","tags":["AccountsQueryService"]}}}}
```

## GetAccountWithdrawalDestinations handle the request to get all withdrawal destinations for an account

> Includes destinations in every status (pending and confirmed). Filter\
> client-side if only confirmed ones are needed. Name optionally does a\
> case-insensitive partial match

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.withdrawal_destination.read"]},{"BearerAuth":["accounts.withdrawal_destination.read"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetAccountWithdrawalDestinationsResponse":{"properties":{"destinations":{"items":{"$ref":"#/components/schemas/v1WithdrawalDestination"},"title":"destinations represents the withdrawal destinations","type":"array"}},"required":["destinations"],"title":"GetWithdrawalDestinationsResponse is the body response structure from the GetWithdrawalDestinations endpoint","type":"object"},"v1WithdrawalDestination":{"properties":{"accountId":{"title":"account_id represents the account associated to the withdrawal destination","type":"string"},"country":{"title":"country returns the country associated to the destination","type":"string"},"createdAt":{"format":"date-time","title":"created_at is the date when the withdrawal destination was created","type":"string"},"id":{"title":"id represents the withdrawal destination identifier on our database","type":"string"},"identifier":{"title":"identifier represents a value that identifier the destination from others\n(e.g on bank transfer is the account number)","type":"string"},"logo":{"title":"logo is the destination logo URL, resolved by the rail from the payload (bank or wallet\nnetwork) or the rail itself (e.g. Pix). Unset when there's no logo","type":"string"},"name":{"title":"name is the user-defined label for this destination","type":"string"},"payload":{"title":"Rail-specific payload (dynamic schema)","type":"object"},"railCode":{"title":"rail_code represents the rail code","type":"string"},"railVersion":{"format":"int32","title":"rail_version represents the rail version","type":"integer"},"scope":{"title":"scope is who receives the money: self (the account owner) or external (a third party,\nwhose beneficiary fields travel in the payload)","type":"string"},"status":{"title":"status represents the withdrawal destination status (if has been verified or not)","type":"string"},"type":{"title":"type contains the destination type (wallet | bank)","type":"string"},"updatedAt":{"format":"date-time","title":"updated_at is the date when the withdrawal destination was updated","type":"string"}},"required":["id","accountId","railCode","railVersion","payload","country","type","status","identifier","createdAt","name","scope"],"title":"WithdrawalDestination represents a withdrawal destination","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/withdrawal_destinations":{"get":{"description":"Includes destinations in every status (pending and confirmed). Filter\nclient-side if only confirmed ones are needed. Name optionally does a\ncase-insensitive partial match","operationId":"AccountsQueryService_GetAccountWithdrawalDestinations","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}},{"description":"name optionally filters destinations by name\nIt ignores case and matches any destination that contains the provided name","in":"query","name":"name","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetAccountWithdrawalDestinationsResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetAccountWithdrawalDestinations handle the request to get all withdrawal destinations for an account","tags":["AccountsQueryService"]}}}}
```

## RegisterWithdrawalDestination handle the request to register a withdrawal destination

> payload's shape depends on rail\_code/rail\_version — check\
> GetAllRailSchemas to know what fields to send. A third party destination\
> (scope external) also carries the rail's beneficiary\_schema fields in the payload.\
> The destination isn't usable until ConfirmWithdrawalDestination completes verification

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Commands (write operations)","name":"AccountsMsgService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.withdrawal_destination.write"]},{"BearerAuth":["accounts.withdrawal_destination.write"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"AccountsMsgServiceRegisterWithdrawalDestinationBody":{"properties":{"name":{"title":"name represents the name of the withdrawal destination","type":"string"},"payload":{"title":"Rail-specific payload (dynamic schema)","type":"object"},"railCode":{"title":"rail_code represents the rail code","type":"string"},"railVersion":{"format":"int32","title":"rail_version represents the rail version","type":"integer"},"scope":{"title":"scope is who receives the money: self (the account owner) or external (a third party).\nDefaults to self. An external destination needs a rail with a beneficiary_schema and its\nfields in the payload","type":"string"}},"required":["railCode","railVersion","payload","name"],"title":"RegisterWithdrawalDestinationRequest is the body request structure from the RegisterWithdrawalDestination endpoint","type":"object"},"v1RegisterWithdrawalDestinationResponse":{"title":"RegisterWithdrawalDestinationResponse is the body response structure from the RegisterWithdrawalDestination endpoint","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/withdrawal_destinations":{"post":{"description":"payload's shape depends on rail_code/rail_version — check\nGetAllRailSchemas to know what fields to send. A third party destination\n(scope external) also carries the rail's beneficiary_schema fields in the payload.\nThe destination isn't usable until ConfirmWithdrawalDestination completes verification","operationId":"AccountsMsgService_RegisterWithdrawalDestination","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountsMsgServiceRegisterWithdrawalDestinationBody"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1RegisterWithdrawalDestinationResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"RegisterWithdrawalDestination handle the request to register a withdrawal destination","tags":["AccountsMsgService"]}}}}
```

## DeleteWithdrawalDestination handle the request to delete a withdrawal destination

> Removes the destination whether it's pending or already confirmed

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Commands (write operations)","name":"AccountsMsgService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.withdrawal_destination.write"]},{"BearerAuth":["accounts.withdrawal_destination.write"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1DeleteWithdrawalDestinationResponse":{"title":"DeleteWithdrawalDestinationResponse is the body response structure from the DeleteWithdrawalDestination endpoint","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/withdrawal_destinations/{destinationId}":{"delete":{"description":"Removes the destination whether it's pending or already confirmed","operationId":"AccountsMsgService_DeleteWithdrawalDestination","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}},{"description":"destination_id represents the withdrawal destination identifier","in":"path","name":"destinationId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1DeleteWithdrawalDestinationResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"DeleteWithdrawalDestination handle the request to delete a withdrawal destination","tags":["AccountsMsgService"]}}}}
```

## UpdateWithdrawalDestination handle the request to update a withdrawal destination

> Only renames the destination. The rail payload itself can't be changed,\
> register a new destination instead if those details need to change

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Commands (write operations)","name":"AccountsMsgService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.withdrawal_destination.write"]},{"BearerAuth":["accounts.withdrawal_destination.write"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"AccountsMsgServiceUpdateWithdrawalDestinationBody":{"properties":{"name":{"title":"name is the new label for this destination","type":"string"}},"required":["name"],"title":"UpdateWithdrawalDestinationRequest is the body request structure from the UpdateWithdrawalDestination endpoint","type":"object"},"v1UpdateWithdrawalDestinationResponse":{"title":"UpdateWithdrawalDestinationResponse is the body response structure from the UpdateWithdrawalDestination endpoint","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/withdrawal_destinations/{destinationId}":{"patch":{"description":"Only renames the destination. The rail payload itself can't be changed,\nregister a new destination instead if those details need to change","operationId":"AccountsMsgService_UpdateWithdrawalDestination","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}},{"description":"destination_id represents the withdrawal destination identifier","in":"path","name":"destinationId","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountsMsgServiceUpdateWithdrawalDestinationBody"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1UpdateWithdrawalDestinationResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"UpdateWithdrawalDestination handle the request to update a withdrawal destination","tags":["AccountsMsgService"]}}}}
```

## ConfirmWithdrawalDestination handle the request to confirm a withdrawal destination

> verify\_code is the one-time code sent out after RegisterWithdrawalDestination\
> — moves the destination from pending to confirmed

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Commands (write operations)","name":"AccountsMsgService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.withdrawal_destination.write"]},{"BearerAuth":["accounts.withdrawal_destination.write"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1AccountsMsgServiceConfirmWithdrawalDestinationBody":{"properties":{"verifyCode":{"title":"verify_code represents the one time code to verify the destination created","type":"string"}},"required":["verifyCode"],"title":"ConfirmWithdrawalDestinationRequest is the body request structure from the ConfirmWithdrawalDestination endpoint","type":"object"},"v1ConfirmWithdrawalDestinationResponse":{"title":"ConfirmWithdrawalDestinationResponse is the body response structure from the ConfirmWithdrawalDestination endpoint","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/accounts/{accountId}/withdrawal_destinations/{destinationId}:confirm":{"post":{"description":"verify_code is the one-time code sent out after RegisterWithdrawalDestination\n— moves the destination from pending to confirmed","operationId":"AccountsMsgService_ConfirmWithdrawalDestination","parameters":[{"description":"account_id represents the account identifier","in":"path","name":"accountId","required":true,"schema":{"type":"string"}},{"description":"destination_id represents the withdrawal destination identifier","in":"path","name":"destinationId","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1AccountsMsgServiceConfirmWithdrawalDestinationBody"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1ConfirmWithdrawalDestinationResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"ConfirmWithdrawalDestination handle the request to confirm a withdrawal destination","tags":["AccountsMsgService"]}}}}
```

## ListCountries returns all countries registered in the platform

> The full reference for countries, not scoped to any\
> account — see GetAccountCountries for a specific account's countries

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.kyc.read"]},{"BearerAuth":["accounts.kyc.read"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1ListCountriesResponse":{"properties":{"countries":{"items":{"$ref":"#/components/schemas/v1Country"},"title":"countries is the list of all registered countries","type":"array"}},"required":["countries"],"title":"ListCountriesResponse is the response for the list-countries endpoint","type":"object"},"v1Country":{"properties":{"code":{"title":"code is the ISO 3166-1 alpha-3 country code","type":"string"},"name":{"title":"name is the human-readable country name","type":"string"}},"required":["code","name"],"title":"Country represents a country registered in the platform","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/countries":{"get":{"description":"The full reference for countries, not scoped to any\naccount — see GetAccountCountries for a specific account's countries","operationId":"AccountsQueryService_ListCountries","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1ListCountriesResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"ListCountries returns all countries registered in the platform","tags":["AccountsQueryService"]}}}}
```

## ListAccountLevels returns the existing levels for accounts

> Supports optional filtering by account\_type and level

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["users.accounts.read"]},{"BearerAuth":["users.accounts.read"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1ListAccountLevelsResponse":{"properties":{"levels":{"items":{"$ref":"#/components/schemas/v1AccountLevel"},"title":"levels contains the array of account levels","type":"array"}},"required":["levels"],"title":"ListAccountLevelsResponse is the body response structure from the List account levels endpoint","type":"object"},"v1AccountLevel":{"properties":{"accountType":{"title":"account_type defines if the level is for individual or company accounts","type":"string"},"description":{"title":"description defines the description of the level","type":"string"},"id":{"title":"id represents the account level identifier","type":"string"},"level":{"format":"int32","title":"level defines the level of the account","type":"integer"},"name":{"title":"name defines the name of the level","type":"string"}},"required":["id","accountType","level","name","description"],"title":"AccountLevel defines the type of account level","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/levels":{"get":{"description":"Supports optional filtering by account_type and level","operationId":"AccountsQueryService_ListAccountLevels","parameters":[{"description":"account_type is an optional query parameter to filter leves by account type","in":"query","name":"accountType","required":false,"schema":{"type":"string"}},{"description":"level is an optional query parameter to filter leves by level","in":"query","name":"level","required":false,"schema":{"format":"int32","type":"integer"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1ListAccountLevelsResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"ListAccountLevels returns the existing levels for accounts","tags":["AccountsQueryService"]}}}}
```

## ListAccountLimits returns the existing limits for accounts

> The configured defaults per level/action, not a specific account's\
> effective limits — use GetAccountLimits for that

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["users.accounts.read"]},{"BearerAuth":["users.accounts.read"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1ListAccountLimitsResponse":{"properties":{"limits":{"items":{"$ref":"#/components/schemas/v1AccountLimit"},"title":"limits contains the account limits information","type":"array"}},"required":["limits"],"title":"ListAccountLimitsResponse is the body response structure from the List account limits endpoint","type":"object"},"v1AccountLimit":{"properties":{"accountType":{"title":"account_type defines if the limits are for individual or company accounts","type":"string"},"active":{"title":"active defines if the override is active or not","type":"boolean"},"amountUsd":{"title":"amount_usd defines the amount of the limit in USD","type":"string"},"description":{"title":"description defines the description of the level","type":"string"},"id":{"title":"id represents the limit identifier","type":"string"},"level":{"format":"int32","title":"level defines the level of the account","type":"integer"},"limitAction":{"title":"limit_action defines the action (withdrawal | deposit | swap)","type":"string"},"name":{"title":"name defines the name of the level","type":"string"},"periodDays":{"format":"int32","title":"period_days defines the period of the limit in days","type":"integer"}},"required":["id","accountType","level","name","limitAction","amountUsd","periodDays","active"],"title":"AccountLimit defines the type of account limits","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/limits":{"get":{"description":"The configured defaults per level/action, not a specific account's\neffective limits — use GetAccountLimits for that","operationId":"AccountsQueryService_ListAccountLimits","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1ListAccountLimitsResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"ListAccountLimits returns the existing limits for accounts","tags":["AccountsQueryService"]}}}}
```

## ListAccountLimitOverrides returns all the overrides information for the provided account id

> List of overrides, not scoped to a single account. Includes each override's reason and active status

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["users.accounts.read"]},{"BearerAuth":["users.accounts.read"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1ListAccountLimitOverridesResponse":{"properties":{"overrides":{"items":{"$ref":"#/components/schemas/v1AccountLimitOverride"},"title":"overrides contains the account limit overrides information","type":"array"}},"required":["overrides"],"title":"ListAccountLimitOverridesResponse is the body response structure from the Get account limit overrides endpoint","type":"object"},"v1AccountLimitOverride":{"properties":{"accountId":{"title":"account_id represents the account identifier","type":"string"},"active":{"title":"active defines if the override is active or not","type":"boolean"},"amountUsd":{"title":"amount_usd defines the amount of the limit in USD","type":"string"},"id":{"title":"id represents the override identifier","type":"string"},"limitAction":{"title":"limit_action defines the action (withdrawal | deposit | swap)","type":"string"},"periodDays":{"format":"int32","title":"period_days defines the period of the limit in days","type":"integer"},"reason":{"title":"reason defines the reason for the override","type":"string"}},"required":["id","accountId","limitAction","amountUsd","reason","periodDays","active"],"title":"AccountLimitOverride defines the type of account limit override","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/limits/overrides":{"get":{"description":"List of overrides, not scoped to a single account. Includes each override's reason and active status","operationId":"AccountsQueryService_ListAccountLimitOverrides","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1ListAccountLimitOverridesResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"ListAccountLimitOverrides returns all the overrides information for the provided account id","tags":["AccountsQueryService"]}}}}
```

## GetAllRailSchemas handle the request to get all rail schemas

> Each schema describes the payload shape a rail\_code/rail\_version expects\
> Use this to build the payload for RegisterWithdrawalDestination.\
> Country optionally filters to rails available in that country

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["accounts.withdrawal_destination.read"]},{"BearerAuth":["accounts.withdrawal_destination.read"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetAllRailSchemasResponse":{"properties":{"schemas":{"items":{"$ref":"#/components/schemas/v1RailSchema"},"title":"schemas represents the rail schemas","type":"array"}},"required":["schemas"],"title":"GetAllRailSchemasResponse is the body response structure from the GetAllRailSchemas endpoint","type":"object"},"v1RailSchema":{"properties":{"beneficiarySchema":{"$ref":"#/components/schemas/typesV1Schema"},"country":{"title":"country represents the country associated to the rail schema","type":"string"},"railCode":{"title":"rail_code represents the rail code","type":"string"},"railVersion":{"format":"int32","title":"rail_version represents the rail version","type":"integer"},"schema":{"$ref":"#/components/schemas/typesV1Schema"},"type":{"title":"type represents the rail type (bank | wallet)","type":"string"}},"required":["railCode","railVersion","country","type","schema"],"title":"RailSchema is the structure of a rail schema","type":"object"},"typesV1Schema":{"properties":{"fields":{"items":{"$ref":"#/components/schemas/v1FieldSchema"},"title":"fields are the fields that the schema contains","type":"array"},"title":{"title":"title is the name of the schema","type":"string"}},"required":["title","fields"],"title":"Schema defines the Schema type used to returns schemas on Rails and providers","type":"object"},"v1FieldSchema":{"properties":{"name":{"title":"name is the name of the field required by the backend","type":"string"},"optionLogos":{"additionalProperties":{"type":"string"},"title":"option_logos maps an option to its logo URL (e.g. bank logos on a bank selector),\nonly set for options that have a logo","type":"object"},"optional":{"title":"optional contains the flag that determines if the field is optional or not","type":"boolean"},"options":{"items":{"type":"string"},"title":"options contains the available options if type is an enum","type":"array"},"pattern":{"title":"pattern contains the regex expresion to evaluate the field","type":"string"},"type":{"title":"type contains the type of the field","type":"string"},"visibleWhen":{"items":{"$ref":"#/components/schemas/v1FieldCondition"},"title":"visible_when lists the conditions to show and validate the field\nEmpty means the field is always shown","type":"array"}},"required":["name","type","optional"],"title":"FieldSchema describe the field on the schema and its properties","type":"object"},"v1FieldCondition":{"properties":{"field":{"title":"field is the name of the field the condition looks at","type":"string"},"values":{"items":{"type":"string"},"title":"values are the values of the field that make the condition hold","type":"array"}},"required":["field","values"],"title":"FieldCondition holds when another field of the schema has one of the values","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/rails/schemas":{"get":{"description":"Each schema describes the payload shape a rail_code/rail_version expects\nUse this to build the payload for RegisterWithdrawalDestination.\nCountry optionally filters to rails available in that country","operationId":"AccountsQueryService_GetAllRailSchemas","parameters":[{"description":"country represents the country associated to the rail schemas","in":"query","name":"country","required":false,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetAllRailSchemasResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetAllRailSchemas handle the request to get all rail schemas","tags":["AccountsQueryService"]}}}}
```

## GetUserAccounts returns all accounts associated to the provided user\_id

> Full account objects (KYC, wallets) for every account the user holds\
> for a single account use GetAccountInfo instead

```json
{"openapi":"3.0.0","info":{"title":"KiiChain Pay Backend","version":"v1"},"tags":[{"description":"Queries (read operations)","name":"AccountsQueryService"}],"servers":[{"description":"Production","url":"https://backend.pay.kiichain.io"},{"description":"Staging","url":"https://backend.pay.staging.kiichain.io"}],"security":[{"ApiKeyAuth":["users.accounts.read","users.accounts.read:all"]},{"BearerAuth":["users.accounts.read","users.accounts.read:all"]}],"components":{"securitySchemes":{"ApiKeyAuth":{"description":"Send 'Authorization: APIKey <api-key>' to authenticate with a API key.","in":"header","name":"Authorization","type":"apiKey"},"BearerAuth":{"flows":{"password":{"scopes":{},"tokenUrl":"https://backend.pay.kiichain.io/users/v1/auth/login"}},"type":"oauth2"}},"schemas":{"v1GetUserAccountsResponse":{"properties":{"accounts":{"items":{"$ref":"#/components/schemas/v1Account"},"title":"accounts contains the array of accounts associated to the user","type":"array"}},"required":["accounts"],"title":"GetUserAccountsResponse is the body response structure from the Get user accounts endpoint","type":"object"},"v1Account":{"properties":{"accountName":{"title":"account_name is the name of the account","type":"string"},"accountType":{"title":"account_type is the type of the account","type":"string"},"countries":{"items":{"type":"string"},"title":"countries is the list of countries associated to the account, in ISO 3166-1 alpha-3 format","type":"array"},"createdAt":{"format":"date-time","title":"created_at is the date when the account was created","type":"string"},"deletedAt":{"format":"date-time","title":"deleted_at is the date when the account was deleted","type":"string"},"id":{"title":"id is the account identifier","type":"string"},"kycInfo":{"$ref":"#/components/schemas/v1KycInfo"},"privyId":{"title":"privy_id is the identifier of the account on Privy, which is the Wallet provider used by default","type":"string"},"subscription":{"$ref":"#/components/schemas/v1Subscription"},"updatedAt":{"format":"date-time","title":"updated_at is the date when the account was updated","type":"string"},"userId":{"title":"account_name is the user-assigned name of the account","type":"string"},"wallets":{"items":{"$ref":"#/components/schemas/v1Wallet"},"title":"wallets is the information about the wallets associated to the account","type":"array"}},"required":["id","userId","accountName","accountType","wallets","kycInfo","createdAt","updatedAt","privyId"],"title":"Account contains all information with a account","type":"object"},"v1KycInfo":{"properties":{"level":{"format":"int32","title":"level is the name of the KYC level approved","type":"integer"},"provider":{"title":"provider is the KYC provider name","type":"string"},"requestedAt":{"format":"date-time","title":"requested_at is the date when the KYC was requested","type":"string"},"status":{"title":"status is the KYC status","type":"string"},"verifiedAt":{"format":"date-time","title":"verified_at is the date when the KYC was verified","type":"string"}},"required":["provider","level","status","requestedAt","verifiedAt"],"title":"KycInfo contains the KYC information per account","type":"object"},"v1Subscription":{"properties":{"code":{"title":"code is the stable identifier of the subscription plan","type":"string"},"status":{"title":"status is the subscription status. One of: trialing, active, past_due, canceled,\nunpaid, incomplete, paused","type":"string"},"tier":{"format":"int32","title":"tier ranks the plan's access level, higher grants more access","type":"integer"}},"required":["code","tier","status"],"title":"Subscription identifies the billing plan an account is (or was) subscribed to","type":"object"},"v1Wallet":{"properties":{"address":{"title":"address is the unique wallet address","type":"string"},"chainType":{"title":"chain_type is which chain is using this wallet","type":"string"},"id":{"title":"id is the wallet identifier","type":"string"}},"required":["id","address","chainType"],"title":"Wallet contains all information about a wallet","type":"object"},"AppErrorStatus":{"description":"The error envelope this API returns for every non-2xx response. `details` always contains exactly one AppError.","properties":{"code":{"description":"gRPC status code","format":"int32","type":"integer"},"details":{"description":"Always contains exactly one AppError","items":{"$ref":"#/components/schemas/AppError"},"type":"array"},"message":{"description":"Human-readable error message","type":"string"}},"type":"object"},"AppError":{"description":"Structured error detail responded by any non-2xx response.","properties":{"@type":{"description":"Protobuf Any type URL, always \"type.googleapis.com/pay.common.error.v1.AppError\" for this API","type":"string"},"internalCode":{"description":"Internal error code, unique within the module","format":"int32","type":"integer"},"message":{"description":"Human-readable error message","type":"string"},"meta":{"additionalProperties":{"type":"string"},"description":"Additional structured context for the error, if any","type":"object"},"module":{"description":"Module name where the error occurred (e.g. \"accounts\", \"market\")","type":"string"}},"type":"object"}},"responses":{"AppError":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AppErrorStatus"}}},"description":"An unexpected error response. `details[0]` is always an AppError, see #/components/schemas/AppError"}}},"paths":{"/accounts/v1/users/{userId}/accounts":{"get":{"description":"Full account objects (KYC, wallets) for every account the user holds\nfor a single account use GetAccountInfo instead","operationId":"AccountsQueryService_GetUserAccounts","parameters":[{"description":"user_id represents the user identifier","in":"path","name":"userId","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/v1GetUserAccountsResponse"}}},"description":"A successful response."},"default":{"$ref":"#/components/responses/AppError"}},"summary":"GetUserAccounts returns all accounts associated to the provided user_id","tags":["AccountsQueryService"]}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kiiglobal.io/docs/kiichain-pay/api-reference/accounts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
