Jump to content

TuCloudAPI addadminuser: Difference between revisions

From Wiki 7Kas
API docs (generated from func=help) — #48 rescoped to per-PBX
TuCloudAPI reference: portal users email + magic link (generated from func=help)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
''TuCloudAPI function to manage tucloud (PBX) services. Available to: '''SuperRoot, Operator, Client'''.''
''TuCloudAPI function to manage FuturePBX (the cloud PBX). Available to: '''SuperRoot, Operator, Client'''.''
 
{{Note|1=Requires the <code>pbx</code> parameter (the PBX '''name''', e.g. <code>tucall</code>). The server verifies that your <code>ukey</code>'s own account owns that PBX, whatever its role; otherwise, and also for a PBX that does not exist, it returns <code>{"ok":false,"code":"forbidden"}</code>.}}


== Description ==
== Description ==
Create a portal admin user in THIS PBX. login is the PK (conflict on duplicate — login is globally unique). password is required and stored as md5(plaintext). email is required (max 64, valid format). active/priv_admin are 0/1. tucloudpbx_id and root are set server-side (this PBX + its root) — they are NOT accepted from the client. Requires a non-readonly ukey.
Invite a new portal user to THIS PBX. No login and no password: the server generates the login (_id) and the user logs in only with their email, by magic link. The user is created INVITED, with no confirmed email, and a link valid 24 hours is mailed to the address; when it is opened (completed by the server) the address becomes the user's email and the user can log in. The address is normalized (trim + lower-case); refusals carry field email and reason required | format | too_long | taken (another user's or a PBX's email) | rate_limited (3 per user and 20 per PBX per hour), and then nothing is created. A non-empty login or password is refused (field login|password, reason not_allowed); an empty one is ignored. tucloudpbx_id and root are set server-side. Follow the invitation with getadminuseremailchange. Requires a non-readonly ukey.


== Call ==
== Call ==
GET https://tucloudapi.7kas.com:9087/tucloud?func=addadminuser&ukey=YOUR_KEY
  https://tucloudapi.7kas.com:9087/tucloud?func=addadminuser&ukey=YOUR_KEY&pbx=PBX_NAME
Requires the <code>ukey</code> parameter.
GET, or POST with the parameters form-urlencoded in the body. Requires the <code>ukey</code> parameter. Always HTTP 200; the response is a JSON envelope.


== Parameters ==
== Parameters ==
Line 12: Line 14:
! Parameter !! Type !! Required !! Default !! Meaning
! Parameter !! Type !! Required !! Default !! Meaning
|-
|-
| <code>pbx</code> || string || Yes || — || TuCloud PBX NAME (e.g. tucall). The (ukey, pbx) pair is the tenant boundary; the server verifies the ukey owns this PBX and scopes every admin user to it.
| <code>pbx</code> || string || Yes || — || FuturePBX NAME (e.g. tucall). The (ukey, pbx) pair is the tenant boundary; the server verifies the ukey owns this PBX and scopes every admin user to it.
|-
| <code>login</code> || string || Yes || — || Admin login (PK, email-style, max 255).
|-
| <code>password</code> || string || Yes || — || Plaintext password (stored as unsalted MD5).
|-
|-
| <code>email</code> || string || Yes || — || Email (required, max 64, valid format).
| <code>email</code> || string || Yes || — || The user's email (max 128): where the invitation goes, and their login.
|-
|-
| <code>name</code> || string || No || — || Display name.
| <code>name</code> || string || No || — || Display name.
Line 31: Line 29:
|}
|}
== Example ==
== Example ==
  <nowiki>https://tucloudapi.7kas.com:9087/tucloud?func=addadminuser&ukey=KEY&pbx=tucall&login=a@x.com&password=secret&email=a@x.com</nowiki>
  <nowiki>https://tucloudapi.7kas.com:9087/tucloud?func=addadminuser&ukey=KEY&pbx=tucall&email=ana@example.com&name=Ana</nowiki>


== Response ==
== Response ==
{ok, user:{...}} or {ok:false,code:conflict|invalid_param}.
{ok, user:{...}, status:"invited", email_pending, expires_in} | {ok:false, code, field, reason, message}.
 
== Errors ==
Always HTTP 200. On failure the body is <code>{"ok":false,"code":"...","message":"..."}</code>. Common codes: <code>missing_pbx</code>, <code>forbidden</code>, <code>invalid_param</code>, <code>not_found</code>, <code>conflict</code>, <code>in_use</code>, <code>db_error</code>, <code>server_busy</code>; the Response section above lists any specific to this function.


----
----
Back to [[TuCloudAPI]]
Back to [[TuCloudAPI]]
[[Category:TuCloudAPI SuperRoot]][[Category:TuCloudAPI Operator]][[Category:TuCloudAPI Client]][[Category:TuCloudAPI]]
[[Category:TuCloudAPI SuperRoot]][[Category:TuCloudAPI Operator]][[Category:TuCloudAPI Client]][[Category:TuCloudAPI]]

Latest revision as of 23:50, 3 November 2026

TuCloudAPI function to manage FuturePBX (the cloud PBX). Available to: SuperRoot, Operator, Client.

ℹ Requires the pbx parameter (the PBX name, e.g. tucall). The server verifies that your ukey's own account owns that PBX, whatever its role; otherwise, and also for a PBX that does not exist, it returns {"ok":false,"code":"forbidden"}.

Description

Invite a new portal user to THIS PBX. No login and no password: the server generates the login (_id) and the user logs in only with their email, by magic link. The user is created INVITED, with no confirmed email, and a link valid 24 hours is mailed to the address; when it is opened (completed by the server) the address becomes the user's email and the user can log in. The address is normalized (trim + lower-case); refusals carry field email and reason required | format | too_long | taken (another user's or a PBX's email) | rate_limited (3 per user and 20 per PBX per hour), and then nothing is created. A non-empty login or password is refused (field login|password, reason not_allowed); an empty one is ignored. tucloudpbx_id and root are set server-side. Follow the invitation with getadminuseremailchange. Requires a non-readonly ukey.

Call

https://tucloudapi.7kas.com:9087/tucloud?func=addadminuser&ukey=YOUR_KEY&pbx=PBX_NAME

GET, or POST with the parameters form-urlencoded in the body. Requires the ukey parameter. Always HTTP 200; the response is a JSON envelope.

Parameters

Parameter Type Required Default Meaning
pbx string Yes — FuturePBX NAME (e.g. tucall). The (ukey, pbx) pair is the tenant boundary; the server verifies the ukey owns this PBX and scopes every admin user to it.
email string Yes — The user's email (max 128): where the invitation goes, and their login.
name string No — Display name.
active integer No 1 1 = active, 0 = disabled.
priv_admin integer No 0 1 = super-admin flag.
role string No — Free-text role label.
phone string No — Phone.

Example

https://tucloudapi.7kas.com:9087/tucloud?func=addadminuser&ukey=KEY&pbx=tucall&email=ana@example.com&name=Ana

Response

{ok, user:{...}, status:"invited", email_pending, expires_in} | {ok:false, code, field, reason, message}.

Errors

Always HTTP 200. On failure the body is {"ok":false,"code":"...","message":"..."}. Common codes: missing_pbx, forbidden, invalid_param, not_found, conflict, in_use, db_error, server_busy; the Response section above lists any specific to this function.


Back to TuCloudAPI