Jump to content

TuCloudAPI: Difference between revisions

From Wiki 7Kas
Fix {{Note}} 1= (func=help)
TuCloudAPI reference regenerated from func=help: tenancy rule, pbx notes on every PBX-scoped function, error codes
Line 2: Line 2:


== Overview ==
== Overview ==
'''TuCloudAPI''' is the REST API to manage '''FuturePBX''' (the multi-tenant cloud PBX). '''HTTPS, GET, JSON.''' Base URL:
'''TuCloudAPI''' is the REST API to manage '''FuturePBX''' (the multi-tenant cloud PBX). '''HTTPS + JSON''', GET or POST (parameters form-urlencoded; audio uploads POST the file as the body). Base URL:
  https://tucloudapi.7kas.com:9087/tucloud?func=NAME&ukey=YOUR_KEY&pbx=PBX_NAME
  https://tucloudapi.7kas.com:9087/tucloud?func=NAME&ukey=YOUR_KEY&pbx=PBX_NAME


== Authentication & tenant ==
== Authentication & tenant ==
Every call needs an '''API key''' (<code>ukey</code>). The '''tasks''' functions also need <code>pbx</code> — the PBX '''name''' (e.g. <code>tucall</code>). The <code>(ukey, pbx)</code> pair is the tenant boundary: the server resolves the PBX name to its id and verifies the key owns it ('''SuperRoot''' any PBX; '''Operator''' its own root; '''Client''' its own account). It never trusts a numeric tenant from the caller.
Every call needs an '''API key''' (<code>ukey</code>). Every PBX-scoped function also needs <code>pbx</code> — the PBX '''name''' (e.g. <code>tucall</code>). The <code>(ukey, pbx)</code> pair is the tenant boundary: the server resolves the PBX name to its id and verifies that the key's OWN account owns it — for every role, SuperRoot included. A PBX that does not exist and one the key does not own both answer <code>forbidden</code>. It never trusts a numeric tenant from the caller.


== Response format ==
== Response format ==
'''Always HTTP 200.''' The '''tasks''' functions always return a JSON envelope: success <code>{"ok":true, ...}</code>, empty <code>{"ok":true,"rows":[]}</code>, error <code>{"ok":false,"code":...,"message":...}</code> (codes: <code>missing_pbx, unknown_pbx, forbidden, invalid_param, not_found, db_error, server_busy</code>). IDs are exposed as <code>_id</code>. Base/legacy functions return their data object directly, or <code>{}</code> on error/empty.
'''Always HTTP 200.''' Every PBX-scoped function always returns a JSON envelope: success <code>{"ok":true, ...}</code>, empty <code>{"ok":true,"rows":[]}</code>, error <code>{"ok":false,"code":...,"message":...}</code> (common codes: <code>missing_pbx, forbidden, invalid_param, not_found, conflict, in_use, db_error, server_busy</code>). IDs are exposed as <code>_id</code>. A missing or invalid <code>ukey</code> answers a bare <code>{}</code> and nothing else. The legacy account functions return their data object directly, <code>{}</code> when there is nothing.


== Functions ==
== Functions ==
Line 21: Line 21:
* [[TuCloudAPI updateextension]] — Edit an extension.
* [[TuCloudAPI updateextension]] — Edit an extension.
* [[TuCloudAPI deleteextension]] — Delete an extension after a tenant + dependency check.
* [[TuCloudAPI deleteextension]] — Delete an extension after a tenant + dependency check.
* [[TuCloudAPI setextpassword]] — Rotate ONE extension's SIP password.
* [[TuCloudAPI getextpassword]] — Plaintext SIP password for ONE extension (the portal's «Clave SIP» eye toggle).
* [[TuCloudAPI getextqr]] — SIP provisioning QR for one extension, rendered server-side to a PNG (base64).
* [[TuCloudAPI getextqr]] — SIP provisioning QR for one extension, rendered server-side to a PNG (base64).
=== CLIs / DIDs (Numeracion) ===
=== CLIs / DIDs (Numeracion) ===
Line 71: Line 73:
* [[TuCloudAPI updatelocution]] — Edit a locution (name, waitext, digit routes).
* [[TuCloudAPI updatelocution]] — Edit a locution (name, waitext, digit routes).
* [[TuCloudAPI deletelocution]] — Delete a locution.
* [[TuCloudAPI deletelocution]] — Delete a locution.
* [[TuCloudAPI getlocutionvoices]] — Catalogo para el selector de texto a voz: voces disponibles e idiomas admitidos.
* [[TuCloudAPI synthlocution]] — Genera el audio de una locucion a partir de un texto y lo deja PENDIENTE DE ACEPTAR: NO sustituye la locucion.
* [[TuCloudAPI uploadlocution]] — Sube un fichero de audio y lo deja COMO el audio de una locucion.
* [[TuCloudAPI commitlocution]] — Acepta el audio pendiente (el generado por synthlocution o subido por uploadlocution) y lo convierte en la locucion.
* [[TuCloudAPI discardlocution]] — Tira el audio pendiente sin tocar la locucion.
=== Music on hold (MOH) ===
=== Music on hold (MOH) ===
* [[TuCloudAPI getmusics]] — List the PBX music-on-hold classes with has_audio (whether the track exists) and audio_url (the getaudio player URL).
* [[TuCloudAPI getmusics]] — List the PBX music-on-hold classes with has_audio (whether the track exists) and audio_url (the getaudio player URL).
* [[TuCloudAPI getmusic]] — Get one MOH class (+ has_audio, audio_url).
* [[TuCloudAPI getmusic]] — Get one MOH class (+ has_audio, audio_url).
* [[TuCloudAPI addmusic]] — Create a MOH class.
* [[TuCloudAPI addmusic]] — Create a MOH class.
* [[TuCloudAPI uploadmusic]] — Sube un fichero de audio para una clase de musica y lo deja PENDIENTE DE ACEPTAR: NO sustituye la que suena.
* [[TuCloudAPI commitmusic]] — Acepta el audio pendiente y lo convierte en la musica que suena.
* [[TuCloudAPI discardmusic]] — Tira el audio pendiente sin tocar la musica.
* [[TuCloudAPI deletemusic]] — Delete a MOH class.
* [[TuCloudAPI deletemusic]] — Delete a MOH class.
=== Schedules (Horarios) ===
=== Schedules (Horarios) ===
Line 182: Line 192:
* [[TuCloudAPI addaccountcode]] — Creates a new account (client) under the caller.
* [[TuCloudAPI addaccountcode]] — Creates a new account (client) under the caller.
* [[TuCloudAPI getcredit]] — Returns credit and status (credit, credit_limit, creditalarm, email, blocked).
* [[TuCloudAPI getcredit]] — Returns credit and status (credit, credit_limit, creditalarm, email, blocked).
=== auth ===
* [[TuCloudAPI authrequest]] — Ask for a magic-link e-mail.
* [[TuCloudAPI authpoll]] — Has the magic link been clicked? PUBLIC, like authrequest.
* [[TuCloudAPI authwhoami]] — The current session context, and it refreshes the idle timer.
* [[TuCloudAPI authlogout]] — Destroy the session and clear the cookie.


== Related ==
== Related ==

Revision as of 21:17, 8 October 2026

ℹ New here? Start with the self-discovery endpoint. This reference is generated from func=help, so it never drifts.

Overview

TuCloudAPI is the REST API to manage FuturePBX (the multi-tenant cloud PBX). HTTPS + JSON, GET or POST (parameters form-urlencoded; audio uploads POST the file as the body). Base URL:

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

Authentication & tenant

Every call needs an API key (ukey). Every PBX-scoped function also needs pbx — the PBX name (e.g. tucall). The (ukey, pbx) pair is the tenant boundary: the server resolves the PBX name to its id and verifies that the key's OWN account owns it — for every role, SuperRoot included. A PBX that does not exist and one the key does not own both answer forbidden. It never trusts a numeric tenant from the caller.

Response format

Always HTTP 200. Every PBX-scoped function always returns a JSON envelope: success {"ok":true, ...}, empty {"ok":true,"rows":[]}, error {"ok":false,"code":...,"message":...} (common codes: missing_pbx, forbidden, invalid_param, not_found, conflict, in_use, db_error, server_busy). IDs are exposed as _id. A missing or invalid ukey answers a bare {} and nothing else. The legacy account functions return their data object directly, {} when there is nothing.

Functions

Dashboard (landing counts)

Extensions (Extensiones)

CLIs / DIDs (Numeracion)

Routes (Rutas)

Blacklist (inbound intercept)

Contacts (Agenda)

Calendar (date overrides)

Ring groups (Grupos)

Locutions / IVR (Locuciones)

Music on hold (MOH)

Schedules (Horarios)

Outbound routing (Rutas de salida)

Phonebooks (Agendas)

Call queues / ACD (Colas)

Agents / queue members (Agentes)

Portal admin users (Usuarios)

PBX settings (Configuracion)

Security profiles / ACL (Perfiles)

Call detail records (CDR)

  • TuCloudAPI getcdr — List a period of this PBX's call detail records (Registro de llamadas), newest first.
  • TuCloudAPI getcdrlookups — CDR form pickers: the selectable years + the result (disposition) label set.

Reports / statistics (Informes)

  • TuCloudAPI getreports — Call-volume statistics (Informes / Estadisticas de Llamadas) for a month — VOLUME ONLY, no prices.

AI assistant (Asistente IA)

Scheduled tasks (Tareas programadas)

Call simulator

  • TuCloudAPI simulatecall — Simulate how a call routes (inbound DID / outbound / internal) WITHOUT placing a real call, returning the ordered decision trace (flujo).

Audio files

  • TuCloudAPI getaudio — General-purpose audio file server (not only for the simulator): serve a locution or music-on-hold audio file base64-encoded (audio/wav) — for hover-preview, players, downloads, etc.

FuturePBX

Meta / discovery

  • TuCloudAPI help — Lists the API functions available to the role of the calling ukey, with each function's description, parameters (meaning, optional/default), an example call and the response format.

Diagnostics

Administration

Account management (inherited)

auth

Related

Full technical reference (architecture, auth model, side effects): see the project repo doc/TUCLOUDAPI_REFERENCE.md. Scheduled-tasks engine: the 6 tucloud_pbx_tasks* tables + the .231 crontab trigger.