UNITH

UNITH API — Quickstart

Aprende a llamar a UNITH Platform API con ejemplos listos para copiar (curl y fetch) y una consola embebida para hacer pruebas rápidas con tu propio Bearer token.

Estado de sesión

Ya has iniciado sesión en UNITH Platform desde login.html. Tu Bearer token se ha guardado en la sesión del navegador y se puede reutilizar desde esta página.

Usa el botón "Cargar Bearer de sesión" en la consola de la derecha para inyectar el token actual en las peticiones, o copia y pega un Bearer manualmente si quieres probar otro usuario.

Nota: en producción nunca expongas el Secret Key en el frontend. Utiliza siempre Bearers de corta duración o llama a la API desde tu backend.

1) Obtener un Bearer token

POST /auth/token

Intercambia tu email y Secret Key por un Bearer token con la API de plataforma. Este paso ya lo hace internamente login.html, pero aquí tienes los ejemplos completos para aprender a usar el endpoint.

Estos valores se insertan en el body JSON y en la consola cuando pulsas Usar en consola.

curl

curl -X POST 'https://platform-api.unith.ai/auth/token' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "YOUR_EMAIL",
  "secretKey": "YOUR_UNITH_SECRET_KEY"
}'

fetch (JavaScript)

const res = await fetch('https://platform-api.unith.ai/auth/token', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    email: 'YOUR_EMAIL',
    secretKey: 'YOUR_UNITH_SECRET_KEY'
  })
});
const json = await res.json();
const bearer = json?.data?.bearer;
console.log('Bearer:', bearer);

2) Listar head visuals

GET /head_visual/face/all

Recupera el catálogo de head visuals (avatares) disponibles en tu cuenta. Esto se utiliza en los formularios de creación para que el usuario pueda elegir el humano digital.

curl

curl -X GET 'https://platform-api.unith.ai/head_visual/face/all?order=ASC&page=1&take=10' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer YOUR_BEARER_TOKEN'

fetch (JavaScript)

const res = await fetch('https://platform-api.unith.ai/head_visual/face/all?order=ASC&page=1&take=10', {
  method: 'GET',
  headers: {
    'accept': 'application/json',
    'Authorization': 'Bearer YOUR_BEARER_TOKEN'
  }
});
const json = await res.json();
console.log('Visuals:', json?.data || json);

3) Crear un Digital Human (Head)

POST /head/create

Crea un nuevo Head combinando un headVisualId, un nombre visible y un system_prompt que define el comportamiento del humano digital.

Estos campos se usan para construir el body JSON y la petición en la consola cuando pulsas Usar en consola.

curl

curl -X POST 'https://platform-api.unith.ai/head/create' \
  -H 'Authorization: Bearer YOUR_BEARER_TOKEN' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
    "headVisualId": "HEAD_VISUAL_ID",
    "name": "Demo Head",
    "alias": "Demo Head alias",
    "languageSpeechRecognition": "en-US",
    "language": "en-US",
    "operationMode": "oc",
    "promptConfig": {
      "system_prompt": "You are a helpful digital human for product demos."
    },
    "ttsProvider": "elevenlabs",
    "ocProvider": "playground",
    "ttsVoice": "your-voice-id",
    "greetings": "Hi there!"
  }'

fetch (JavaScript)

const payload = {
  headVisualId: 'HEAD_VISUAL_ID',
  name: 'Demo Head',
  alias: 'Demo Head alias',
  languageSpeechRecognition: 'en-US',
  language: 'en-US',
  operationMode: 'oc',
  promptConfig: {
    system_prompt: 'You are a helpful digital human for product demos.'
  },
  ttsProvider: 'elevenlabs',
  ocProvider: 'playground',
  ttsVoice: 'your-voice-id',
  greetings: 'Hi there!'
};

const res = await fetch('https://platform-api.unith.ai/head/create', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_BEARER_TOKEN'
  },
  body: JSON.stringify(payload)
});
const json = await res.json();
console.log('Created head:', json?.data || json);

4) Listar Heads existentes

GET /head/all

Recupera los Heads ya creados en tu cuenta para reutilizarlos o mostrarlos como histórico.

curl

curl -X GET 'https://platform-api.unith.ai/head/all?order=DESC&page=1&take=10' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer YOUR_BEARER_TOKEN'

fetch (JavaScript)

const res = await fetch('https://platform-api.unith.ai/head/all?order=DESC&page=1&take=10', {
  method: 'GET',
  headers: {
    'accept': 'application/json',
    'Authorization': 'Bearer YOUR_BEARER_TOKEN'
  }
});
const json = await res.json();
console.log('Heads:', json?.data || json);