Registrar el uso de un turno del Asistente
curl --request POST \
--url https://api.ugps.io/api/auth/assistant-session/usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model": "claude-sonnet-5-5",
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheWriteTokens": 123,
"costUsd": 0.0068,
"credits": 2,
"toolCalls": 123,
"conversationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.ugps.io/api/auth/assistant-session/usage"
payload = {
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model": "claude-sonnet-5-5",
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheWriteTokens": 123,
"costUsd": 0.0068,
"credits": 2,
"toolCalls": 123,
"conversationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
requestId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
model: 'claude-sonnet-5-5',
inputTokens: 123,
outputTokens: 123,
cacheReadTokens: 123,
cacheWriteTokens: 123,
costUsd: 0.0068,
credits: 2,
toolCalls: 123,
conversationId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api.ugps.io/api/auth/assistant-session/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ugps.io/api/auth/assistant-session/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'requestId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'model' => 'claude-sonnet-5-5',
'inputTokens' => 123,
'outputTokens' => 123,
'cacheReadTokens' => 123,
'cacheWriteTokens' => 123,
'costUsd' => 0.0068,
'credits' => 2,
'toolCalls' => 123,
'conversationId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ugps.io/api/auth/assistant-session/usage"
payload := strings.NewReader("{\n \"requestId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model\": \"claude-sonnet-5-5\",\n \"inputTokens\": 123,\n \"outputTokens\": 123,\n \"cacheReadTokens\": 123,\n \"cacheWriteTokens\": 123,\n \"costUsd\": 0.0068,\n \"credits\": 2,\n \"toolCalls\": 123,\n \"conversationId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ugps.io/api/auth/assistant-session/usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requestId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model\": \"claude-sonnet-5-5\",\n \"inputTokens\": 123,\n \"outputTokens\": 123,\n \"cacheReadTokens\": 123,\n \"cacheWriteTokens\": 123,\n \"costUsd\": 0.0068,\n \"credits\": 2,\n \"toolCalls\": 123,\n \"conversationId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/auth/assistant-session/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"requestId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model\": \"claude-sonnet-5-5\",\n \"inputTokens\": 123,\n \"outputTokens\": 123,\n \"cacheReadTokens\": 123,\n \"cacheWriteTokens\": 123,\n \"costUsd\": 0.0068,\n \"credits\": 2,\n \"toolCalls\": 123,\n \"conversationId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}{
"error": "No tiene permisos para realizar esta acción"
}{
"message": "Error interno del servidor"
}Auth - Autenticación
Registrar el uso de un turno del Asistente
Lo llama el servidor del Asistente al cerrar el stream de cada turno, con los tokens, el
costo real en USD y los créditos que calculó con la tarifa del modelo (ADR-020). Va al
ledger assistant_usage y al contador del mes de la empresa. Idempotente por requestId:
un reintento responde 204 sin cobrar dos veces. Un turno cortado o fallido se registra
igual con lo que consumió.
POST
/
api
/
auth
/
assistant-session
/
usage
Registrar el uso de un turno del Asistente
curl --request POST \
--url https://api.ugps.io/api/auth/assistant-session/usage \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model": "claude-sonnet-5-5",
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheWriteTokens": 123,
"costUsd": 0.0068,
"credits": 2,
"toolCalls": 123,
"conversationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'import requests
url = "https://api.ugps.io/api/auth/assistant-session/usage"
payload = {
"requestId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"model": "claude-sonnet-5-5",
"inputTokens": 123,
"outputTokens": 123,
"cacheReadTokens": 123,
"cacheWriteTokens": 123,
"costUsd": 0.0068,
"credits": 2,
"toolCalls": 123,
"conversationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
requestId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
model: 'claude-sonnet-5-5',
inputTokens: 123,
outputTokens: 123,
cacheReadTokens: 123,
cacheWriteTokens: 123,
costUsd: 0.0068,
credits: 2,
toolCalls: 123,
conversationId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
})
};
fetch('https://api.ugps.io/api/auth/assistant-session/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ugps.io/api/auth/assistant-session/usage",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'requestId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'model' => 'claude-sonnet-5-5',
'inputTokens' => 123,
'outputTokens' => 123,
'cacheReadTokens' => 123,
'cacheWriteTokens' => 123,
'costUsd' => 0.0068,
'credits' => 2,
'toolCalls' => 123,
'conversationId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.ugps.io/api/auth/assistant-session/usage"
payload := strings.NewReader("{\n \"requestId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model\": \"claude-sonnet-5-5\",\n \"inputTokens\": 123,\n \"outputTokens\": 123,\n \"cacheReadTokens\": 123,\n \"cacheWriteTokens\": 123,\n \"costUsd\": 0.0068,\n \"credits\": 2,\n \"toolCalls\": 123,\n \"conversationId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.ugps.io/api/auth/assistant-session/usage")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"requestId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model\": \"claude-sonnet-5-5\",\n \"inputTokens\": 123,\n \"outputTokens\": 123,\n \"cacheReadTokens\": 123,\n \"cacheWriteTokens\": 123,\n \"costUsd\": 0.0068,\n \"credits\": 2,\n \"toolCalls\": 123,\n \"conversationId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ugps.io/api/auth/assistant-session/usage")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"requestId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"model\": \"claude-sonnet-5-5\",\n \"inputTokens\": 123,\n \"outputTokens\": 123,\n \"cacheReadTokens\": 123,\n \"cacheWriteTokens\": 123,\n \"costUsd\": 0.0068,\n \"credits\": 2,\n \"toolCalls\": 123,\n \"conversationId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}"
response = http.request(request)
puts response.read_body{
"error": "El email es requerido"
}{
"error": "Token inválido o expirado"
}{
"error": "No tiene permisos para realizar esta acción"
}{
"message": "Error interno del servidor"
}Authorizations
Token de sesión Better Auth o API token (atk_...) en el header Authorization: Bearer <token>. Los JWT legacy ya no son válidos.
Body
application/json
Example:
"claude-sonnet-5-5"
Total de entrada (sin caché + lectura + escritura de caché).
Example:
0.0068
ceil(costUsd / 0,01), mínimo 1.
Required range:
x >= 1Available options:
completed, aborted, failed Response
Uso registrado (o ya registrado)

