Autenticacion 6 metodos Base de conocimiento 3 metodos Inventario 6 metodos Ventas 10 metodos Compras 4 metodos Contabilidad 5 metodos Reporteria 5 metodos

Autenticacion

Acceso por usuario cliente (Bearer) y por empresa (API Key), incluyendo contexto multiempresa.

Base URL: https://troyansys.com/api/v1

POST

Login API

Genera token Bearer para consumir la API con usuario cliente.

Endpoint Bearer
https://troyansys.com/api/v1/auth/login

Body JSON

Campo Tipo Req. Descripcion
email string(email) Si Correo del usuario cliente.
password string Si Contrasena del usuario cliente.
device_name string No Nombre del dispositivo cliente.

Ejemplos de uso

Publico
cURL
curl -X POST "https://troyansys.com/api/v1/auth/login" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "demo@empresa.ec",
    "password": "Demo12345",
    "device_name": "mobile-app"
}'
PHP (Guzzle)
<?php

$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://troyansys.com/api/v1/auth/login', [
    'headers' => [
        'Accept' => 'application/json',
        'Content-Type' => 'application/json'
    ],
    'json' => array (
  'email' => 'demo@empresa.ec',
  'password' => 'Demo12345',
  'device_name' => 'mobile-app',
),
]);

$data = json_decode((string) $response->getBody(), true);
print_r($data);
.NET (HttpClient)
using System.Net.Http.Headers;
using System.Text;

var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://troyansys.com/api/v1/auth/login");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var json = "{\"email\":\"demo@empresa.ec\",\"password\":\"Demo12345\",\"device_name\":\"mobile-app\"}";
request.Content = new StringContent(json, Encoding.UTF8, "application/json");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

Respuesta esperada

{
    "token": "{token}",
    "token_type": "Bearer",
    "expires_at": "2026-02-28T18:15:00-05:00",
    "user": {
        "id": 5,
        "name": "Usuario Cliente Demo",
        "email": "demo@empresa.ec",
        "active_company_id": 1,
        "active_modules": [
            {
                "id": 1,
                "code": "inventory",
                "name": "Inventario"
            },
            {
                "id": 2,
                "code": "sales",
                "name": "Ventas"
            },
            {
                "id": 3,
                "code": "purchases",
                "name": "Compras"
            },
            {
                "id": 4,
                "code": "accounting",
                "name": "Contabilidad"
            },
            {
                "id": 5,
                "code": "reports",
                "name": "Reporteria"
            }
        ]
    }
}
POST

Webhook Payphone suscripciones

Webhook publico para notificaciones de pago exitoso/fallido de Payphone en suscripciones.

Endpoint Bearer
https://troyansys.com/api/v1/payphone/subscription/webhook

Body JSON

Campo Tipo Req. Descripcion
transactionStatus string No Estado de la transaccion enviado por Payphone.
reference string No Referencia del intento de cobro o suscripcion.
amount numeric No Monto reportado por Payphone.

Ejemplos de uso

Publico
cURL
curl -X POST "https://troyansys.com/api/v1/payphone/subscription/webhook" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "transactionStatus": "Approved",
    "reference": "SUB-PLAN-PREMIUM-20260317-001",
    "amount": 99.9
}'
PHP (Guzzle)
<?php

$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://troyansys.com/api/v1/payphone/subscription/webhook', [
    'headers' => [
        'Accept' => 'application/json',
        'Content-Type' => 'application/json'
    ],
    'json' => array (
  'transactionStatus' => 'Approved',
  'reference' => 'SUB-PLAN-PREMIUM-20260317-001',
  'amount' => 99.9,
),
]);

$data = json_decode((string) $response->getBody(), true);
print_r($data);
.NET (HttpClient)
using System.Net.Http.Headers;
using System.Text;

var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://troyansys.com/api/v1/payphone/subscription/webhook");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var json = "{\"transactionStatus\":\"Approved\",\"reference\":\"SUB-PLAN-PREMIUM-20260317-001\",\"amount\":99.9}";
request.Content = new StringContent(json, Encoding.UTF8, "application/json");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

Respuesta esperada

{
    "message": "Webhook procesado"
}
GET

Perfil API actual

Devuelve usuario autenticado, empresas y modulos activos.

Endpoint Bearer
https://troyansys.com/api/v1/auth/me

Ejemplos de uso

Bearer
cURL
curl -X GET "https://troyansys.com/api/v1/auth/me" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer {token}" \
  -H "X-Company-Id: 1"
PHP (Guzzle)
<?php

$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://troyansys.com/api/v1/auth/me', [
    'headers' => [
        'Accept' => 'application/json',
        'Authorization' => 'Bearer {token}',
        'X-Company-Id' => '1'
    ],
]);

$data = json_decode((string) $response->getBody(), true);
print_r($data);
.NET (HttpClient)
using System.Net.Http.Headers;
using System.Text;

var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://troyansys.com/api/v1/auth/me");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "{token}");
request.Headers.Add("X-Company-Id", "1");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

Respuesta esperada

{
    "id": 5,
    "name": "Usuario Cliente Demo",
    "email": "demo@empresa.ec",
    "company": {
        "id": 1,
        "name": "Empresa Demo EC"
    },
    "active_company_id": 1
}
POST

Cerrar sesion API

Invalida token Bearer actual.

Endpoint Bearer
https://troyansys.com/api/v1/auth/logout

Ejemplos de uso

Bearer
cURL
curl -X POST "https://troyansys.com/api/v1/auth/logout" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer {token}" \
  -H "X-Company-Id: 1"
PHP (Guzzle)
<?php

$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://troyansys.com/api/v1/auth/logout', [
    'headers' => [
        'Accept' => 'application/json',
        'Authorization' => 'Bearer {token}',
        'X-Company-Id' => '1'
    ],
]);

$data = json_decode((string) $response->getBody(), true);
print_r($data);
.NET (HttpClient)
using System.Net.Http.Headers;
using System.Text;

var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://troyansys.com/api/v1/auth/logout");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "{token}");
request.Headers.Add("X-Company-Id", "1");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

Respuesta esperada

{
    "message": "Sesion API cerrada."
}
GET

Perfil empresa por API key

Devuelve datos de empresa y modulos activos usando API key.

Endpoint API Key
https://troyansys.com/api/v1/company/me

Ejemplos de uso

API Key
cURL
curl -X GET "https://troyansys.com/api/v1/company/me" \
  -H "Accept: application/json" \
  -H "X-API-Key: {api_key_empresa}"
PHP (Guzzle)
<?php

$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://troyansys.com/api/v1/company/me', [
    'headers' => [
        'Accept' => 'application/json',
        'X-API-Key' => '{api_key_empresa}'
    ],
]);

$data = json_decode((string) $response->getBody(), true);
print_r($data);
.NET (HttpClient)
using System.Net.Http.Headers;
using System.Text;

var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://troyansys.com/api/v1/company/me");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Add("X-API-Key", "{api_key_empresa}");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

Respuesta esperada

{
    "company": {
        "id": 1,
        "name": "Empresa Demo EC",
        "trade_name": "Empresa Demo",
        "ruc": "0999999999001"
    },
    "active_modules": [
        {
            "id": 1,
            "code": "inventory",
            "name": "Inventario"
        },
        {
            "id": 2,
            "code": "sales",
            "name": "Ventas"
        }
    ]
}
GET

Listar planes de suscripcion

Obtiene planes activos, modulos incluidos y plan actual de la empresa activa.

Endpoint Bearer
https://troyansys.com/api/v1/subscription/plans
Endpoint API Key
https://troyansys.com/api/v1/company/subscription/plans

Ejemplos de uso

Bearer
cURL
curl -X GET "https://troyansys.com/api/v1/subscription/plans" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer {token}" \
  -H "X-Company-Id: 1"
PHP (Guzzle)
<?php

$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://troyansys.com/api/v1/subscription/plans', [
    'headers' => [
        'Accept' => 'application/json',
        'Authorization' => 'Bearer {token}',
        'X-Company-Id' => '1'
    ],
]);

$data = json_decode((string) $response->getBody(), true);
print_r($data);
.NET (HttpClient)
using System.Net.Http.Headers;
using System.Text;

var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://troyansys.com/api/v1/subscription/plans");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "{token}");
request.Headers.Add("X-Company-Id", "1");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
API Key
cURL
curl -X GET "https://troyansys.com/api/v1/company/subscription/plans" \
  -H "Accept: application/json" \
  -H "X-API-Key: {api_key_empresa}"
PHP (Guzzle)
<?php

$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://troyansys.com/api/v1/company/subscription/plans', [
    'headers' => [
        'Accept' => 'application/json',
        'X-API-Key' => '{api_key_empresa}'
    ],
]);

$data = json_decode((string) $response->getBody(), true);
print_r($data);
.NET (HttpClient)
using System.Net.Http.Headers;
using System.Text;

var httpClient = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Get, "https://troyansys.com/api/v1/company/subscription/plans");
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
request.Headers.Add("X-API-Key", "{api_key_empresa}");

var response = await httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);

Respuesta esperada

{
    "data": [
        {
            "id": 1,
            "name": "Plan Basico",
            "code": "plan-basico",
            "billing_frequency": "monthly",
            "amount": 39.9,
            "currency_code": "USD",
            "module_codes": [
                "sales",
                "inventory"
            ],
            "feature_flags": {
                "inventory_advanced": false
            }
        }
    ],
    "meta": {
        "current_plan_id": 1,
        "current_plan_code": "plan-basico"
    }
}