Vai al contenuto
Menu

Cerca nel sito

Scrivi per cercare tra guide, blog, API e prodotto.

↑ ↓ per spostarti · Invio per aprire · Esc per chiudere

Riferimento dell'API

API

Contatti

Consulta e aggiorna le informazioni dei contatti

Vedi come Markdown

I contatti rappresentano le persone che interagiscono con il tuo agente attraverso canali come WhatsApp, Instagram ed email. Ogni contatto ha un profilo con nome, identificatori di canale e metadati opzionali.

MetodoPercorsoDescrizione
GET/v1/contactsElenca i contatti
GET/v1/contacts/:idVisualizza il dettaglio di un contatto
POST/v1/contactsCrea un contatto
PATCH/v1/contacts/:idAggiorna un contatto
PUT/v1/contactsCrea o aggiorna per telefono o email (upsert)
GET/v1/contacts?phone=|email=Cerca contatti per telefono o email
PATCH/v1/contacts/:id/attributesSalva gli attributi del contatto
PUT/v1/contacts/:id/stageMetti il contatto in una fase di un funnel
POST/v1/contacts/:id/eventsAggiungi un evento alla sua timeline

L'endpoint di elenco supporta i seguenti parametri di query:

ParametroTipoDescrizione
limitnumberRisultati per pagina (predefinito: 20, massimo: 100)
offsetnumberNumero di risultati da saltare (predefinito: 0)

Elenca Contatti

GET/v1/contacts
curl "https://rest-api.tbit.app/v1/contacts?limit=20&offset=0" \
  -H "X-API-Key: $TBIT_API_KEY"
const response = await fetch('https://rest-api.tbit.app/v1/contacts?limit=20&offset=0', {
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
  },
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.get(
  'https://rest-api.tbit.app/v1/contacts?limit=20&offset=0',
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.get(
    'https://rest-api.tbit.app/v1/contacts?limit=20&offset=0',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts?limit=20&offset=0');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
GET/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1
curl "https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1" \
  -H "X-API-Key: $TBIT_API_KEY"
const response = await fetch('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1', {
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
  },
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.get(
  'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1',
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.get(
    'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);

Aggiorna Contatto

PATCH/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1
curl -X PATCH "https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "profile_name": "Jane Doe",
    "email": "[email protected]",
    "notes": "Preferred language: English"
  }'
const response = await fetch('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1', {
  method: 'PATCH',
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    profile_name: 'Jane Doe',
    email: '[email protected]',
    notes: 'Preferred language: English',
  }),
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.patch(
  'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1',
  {
    profile_name: 'Jane Doe',
    email: '[email protected]',
    notes: 'Preferred language: English',
  },
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.patch(
    'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
    json={
        'profile_name': 'Jane Doe',
        'email': '[email protected]',
        'notes': 'Preferred language: English',
    },
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'profile_name' => 'Jane Doe',
        'email' => '[email protected]',
        'notes' => 'Preferred language: English',
    ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);

Crea Contatto

I custom_attributes vengono validati con le stesse regole di «Salva attributi» prima di scrivere qualsiasi cosa. Se un valore non va bene risponde 400 VALIDATION_ERROR con il motivo di ogni chiave (Invalid custom_attributes: «chiave»: «motivo») e non viene salvato né il contatto né i suoi attributi. Un attributo che non esiste viene creato con il tipo dedotto dal valore.

POST/v1/contacts
curl -X POST "https://rest-api.tbit.app/v1/contacts" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "channel_id": "573009876543",
    "channel_type": "whatsapp",
    "profile_name": "Jane Doe",
    "custom_attributes": {
      "city": "Bogota",
      "plan": "premium"
    }
  }'
const response = await fetch('https://rest-api.tbit.app/v1/contacts', {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    channel_id: '573009876543',
    channel_type: 'whatsapp',
    profile_name: 'Jane Doe',
    custom_attributes: {
      city: 'Bogota',
      plan: 'premium',
    },
  }),
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.post(
  'https://rest-api.tbit.app/v1/contacts',
  {
    channel_id: '573009876543',
    channel_type: 'whatsapp',
    profile_name: 'Jane Doe',
    custom_attributes: {
      city: 'Bogota',
      plan: 'premium',
    },
  },
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.post(
    'https://rest-api.tbit.app/v1/contacts',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
    json={
        'channel_id': '573009876543',
        'channel_type': 'whatsapp',
        'profile_name': 'Jane Doe',
        'custom_attributes': {
            'city': 'Bogota',
            'plan': 'premium',
        },
    },
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'channel_id' => '573009876543',
        'channel_type' => 'whatsapp',
        'profile_name' => 'Jane Doe',
        'custom_attributes' => [
            'city' => 'Bogota',
            'plan' => 'premium',
        ],
    ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);

Cerca il contatto del tuo agente tramite il suo WhatsApp (E.164, con o senza «+») e, se non compare, tramite la sua email. Se non esiste, lo crea; se esiste, gli aggiunge il canale che gli manca. Non sovrascrive mai un nome che il contatto ha già. Risponde 201 quando lo crea e 200 quando lo trova.

Se il telefono e l'email appartengono a due contatti diversi risponde 409 CONTACT_CONFLICT con i due id e non scrive nulla. Gli attributi che invii vengono validati prima di toccare il contatto (vedi «Salva attributi»).

PUT/v1/contacts
curl -X PUT "https://rest-api.tbit.app/v1/contacts" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+573001234567",
    "email": "[email protected]",
    "first_name": "Ana",
    "last_name": "Pérez",
    "attributes": {
      "plan": "premium"
    }
  }'
const response = await fetch('https://rest-api.tbit.app/v1/contacts', {
  method: 'PUT',
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    phone: '+573001234567',
    email: '[email protected]',
    first_name: 'Ana',
    last_name: 'Pérez',
    attributes: {
      plan: 'premium',
    },
  }),
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.put(
  'https://rest-api.tbit.app/v1/contacts',
  {
    phone: '+573001234567',
    email: '[email protected]',
    first_name: 'Ana',
    last_name: 'Pérez',
    attributes: {
      plan: 'premium',
    },
  },
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.put(
    'https://rest-api.tbit.app/v1/contacts',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
    json={
        'phone': '+573001234567',
        'email': '[email protected]',
        'first_name': 'Ana',
        'last_name': 'Pérez',
        'attributes': {
            'plan': 'premium',
        },
    },
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'phone' => '+573001234567',
        'email' => '[email protected]',
        'first_name' => 'Ana',
        'last_name' => 'Pérez',
        'attributes' => [
            'plan' => 'premium',
        ],
    ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Risposta
{
  "data": {
    "created": true,
    "matched_by": null,
    "contact": {
      "id": "64f1a2b3c4d5e6f7a8b9c0d1",
      "first_name": "Ana",
      "last_name": "Pérez",
      "profile_name": "Ana Pérez",
      "phone": "573001234567",
      "email": "[email protected]",
      "channels": [
        {
          "channel_type": "whatsapp",
          "channel_id": "573001234567"
        },
        {
          "channel_type": "email",
          "channel_id": "[email protected]"
        }
      ],
      "attributes": {
        "plan": "premium",
        "ciudad": "Bogotá"
      },
      "stages": [
        {
          "funnel_id": "64f1a2b3c4d5e6f7a8b9c0aa",
          "funnel_name": "Clientes",
          "stage": "prueba",
          "stage_name": "En prueba"
        }
      ],
      "created_at": "2026-10-01T12:00:00.000Z",
      "updated_at": "2026-10-08T15:00:00.000Z"
    }
  }
}

Restituisce fino a 10 contatti del tuo agente che hanno quel WhatsApp (in qualsiasi sua grafia) o quella email, con i loro attributi e le fasi di funnel in cui si trovano. Senza phone né email, l'endpoint resta l'elenco paginato di sempre.

GET/v1/contacts
curl "https://rest-api.tbit.app/v1/contacts?email=ana%40example.com" \
  -H "X-API-Key: $TBIT_API_KEY"
const response = await fetch('https://rest-api.tbit.app/v1/contacts?email=ana%40example.com', {
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
  },
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.get(
  'https://rest-api.tbit.app/v1/contacts?email=ana%40example.com',
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.get(
    'https://rest-api.tbit.app/v1/contacts?email=ana%40example.com',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts?email=ana%40example.com');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Risposta
{
  "data": [
    {
      "id": "64f1a2b3c4d5e6f7a8b9c0d1",
      "first_name": "Ana",
      "last_name": "Pérez",
      "profile_name": "Ana Pérez",
      "phone": "573001234567",
      "email": "[email protected]",
      "channels": [
        {
          "channel_type": "whatsapp",
          "channel_id": "573001234567"
        },
        {
          "channel_type": "email",
          "channel_id": "[email protected]"
        }
      ],
      "attributes": {
        "plan": "premium",
        "ciudad": "Bogotá"
      },
      "stages": [
        {
          "funnel_id": "64f1a2b3c4d5e6f7a8b9c0aa",
          "funnel_name": "Clientes",
          "stage": "prueba",
          "stage_name": "En prueba"
        }
      ],
      "created_at": "2026-10-01T12:00:00.000Z",
      "updated_at": "2026-10-08T15:00:00.000Z"
    }
  ]
}

Salva attributi

Le chiavi sono il NOME dell'attributo, così come appare in «Dati del contatto» (senza distinzione tra maiuscole e minuscole né accenti). Tutto o niente: se una chiave non esiste risponde 422 UNKNOWN_ATTRIBUTES con la lista in details.missing, e se un valore non rientra nel suo tipo (un'opzione che non è nella lista, un numero che non è un numero, una data che non si riesce a leggere) risponde 422 INVALID_VALUE; in entrambi i casi non viene salvato nessuno.

Date: sono accettate quattro forme: data completa (2026-11-14), anno e mese (2026-11), giorno e mese senza anno (--11-14) o solo il mese (--11). Una data con ora (2026-11-14T15:00:00Z) viene salvata come il suo giorno, e l'API la restituisce sempre senza ora (2026-11-14). Liste di oggetti, come «Date speciali»: ogni elemento viene validato rispetto al suo schema. I campi data usano quelle quattro forme, quelli obbligatori non possono essere vuoti e quelli con opzioni devono essere una della lista (senza distinzione tra maiuscole e minuscole né accenti; viene salvata scritta come l'opzione).

Con create_missing: true vengono creati quelli mancanti (il tipo si deduce dal valore). null cancella il valore. Ogni nuovo valore conta come «attributo compilato»: un funnel con una regola per quell'attributo sposta la scheda come quando la compila l'IA.

PATCH/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/attributes
curl -X PATCH "https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/attributes" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "attributes": {
      "plan": "premium",
      "ciudad": "Bogotá"
    },
    "create_missing": false
  }'
const response = await fetch('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/attributes', {
  method: 'PATCH',
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    attributes: {
      plan: 'premium',
      ciudad: 'Bogotá',
    },
    create_missing: false,
  }),
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.patch(
  'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/attributes',
  {
    attributes: {
      plan: 'premium',
      ciudad: 'Bogotá',
    },
    create_missing: false,
  },
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.patch(
    'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/attributes',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
    json={
        'attributes': {
            'plan': 'premium',
            'ciudad': 'Bogotá',
        },
        'create_missing': False,
    },
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/attributes');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'attributes' => [
            'plan' => 'premium',
            'ciudad' => 'Bogotá',
        ],
        'create_missing' => false,
    ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Risposta
{
  "data": {
    "id": "64f1a2b3c4d5e6f7a8b9c0d1",
    "attributes": {
      "plan": "premium",
      "ciudad": "Bogotá"
    },
    "updated": [
      "plan",
      "ciudad"
    ],
    "created_attributes": []
  }
}

Indica il funnel tramite funnel_id o tramite il suo nome (funnel) e la fase tramite il suo slug. Se il contatto non è in quel funnel lo aggiunge; se è in un'altra fase lo sposta; se è già lì non fa nulla (changed: false). Vengono eseguite le azioni di ingresso della fase e resta nello storico del contatto.

Per impostazione predefinita non suona la campanella del team: invia notify: true se vuoi l'avviso. Errori: 404 FUNNEL_NOT_FOUND e 422 UNKNOWN_STAGE (con la lista delle fasi).

PUT/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/stage
curl -X PUT "https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/stage" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "funnel": "Clientes",
    "stage": "prueba"
  }'
const response = await fetch('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/stage', {
  method: 'PUT',
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    funnel: 'Clientes',
    stage: 'prueba',
  }),
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.put(
  'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/stage',
  {
    funnel: 'Clientes',
    stage: 'prueba',
  },
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.put(
    'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/stage',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
    json={
        'funnel': 'Clientes',
        'stage': 'prueba',
    },
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/stage');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'funnel' => 'Clientes',
        'stage' => 'prueba',
    ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Risposta
{
  "data": {
    "id": "64f1a2b3c4d5e6f7a8b9c0d1",
    "funnel_id": "64f1a2b3c4d5e6f7a8b9c0aa",
    "stage": "prueba",
    "previous_stage": "registrado",
    "changed": true
  }
}

Lascia una tappa nella scheda del contatto, con la sua data (occurred_at, per impostazione predefinita adesso; non può essere futura). Con idempotency_key lo stesso evento non viene duplicato: ripetere la chiamata risponde 200 con duplicate: true e l'evento originale. data accetta fino a 20 chiavi con testo, numero o booleano.

I contatti di un altro agente rispondono 404, come uno che non esiste.

POST/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/events
curl -X POST "https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/events" \
  -H "X-API-Key: $TBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Empezó la prueba gratis",
    "description": "Termina el 15 de octubre",
    "occurred_at": "2026-10-08T15:00:00Z",
    "idempotency_key": "trial:64f1a2b3c4d5e6f7a8b9c0d1:2026-10-08",
    "data": {
      "plan": "monthly"
    }
  }'
const response = await fetch('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/events', {
  method: 'POST',
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Empezó la prueba gratis',
    description: 'Termina el 15 de octubre',
    occurred_at: '2026-10-08T15:00:00Z',
    idempotency_key: 'trial:64f1a2b3c4d5e6f7a8b9c0d1:2026-10-08',
    data: {
      plan: 'monthly',
    },
  }),
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.post(
  'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/events',
  {
    name: 'Empezó la prueba gratis',
    description: 'Termina el 15 de octubre',
    occurred_at: '2026-10-08T15:00:00Z',
    idempotency_key: 'trial:64f1a2b3c4d5e6f7a8b9c0d1:2026-10-08',
    data: {
      plan: 'monthly',
    },
  },
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.post(
    'https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/events',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
    json={
        'name': 'Empezó la prueba gratis',
        'description': 'Termina el 15 de octubre',
        'occurred_at': '2026-10-08T15:00:00Z',
        'idempotency_key': 'trial:64f1a2b3c4d5e6f7a8b9c0d1:2026-10-08',
        'data': {
            'plan': 'monthly',
        },
    },
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/contacts/64f1a2b3c4d5e6f7a8b9c0d1/events');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'name' => 'Empezó la prueba gratis',
        'description' => 'Termina el 15 de octubre',
        'occurred_at' => '2026-10-08T15:00:00Z',
        'idempotency_key' => 'trial:64f1a2b3c4d5e6f7a8b9c0d1:2026-10-08',
        'data' => [
            'plan' => 'monthly',
        ],
    ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Risposta
{
  "data": {
    "id": "6ac85d7e32e0335e1dcac4fd",
    "contact_id": "64f1a2b3c4d5e6f7a8b9c0d1",
    "name": "Empezó la prueba gratis",
    "occurred_at": "2026-10-08T15:00:00.000Z",
    "duplicate": false
  }
}

Gli endpoint di elenco restituiscono risultati paginati:

json
{
  "data": [
    {
      "id": "64f1a2b3c4d5e6f7a8b9c0d1",
      "profile_name": "Jane Doe",
      "email": "[email protected]",
      "notes": "Preferred language: English",
      "channels": [
        {
          "channel_id": "573001234567",
          "channel_type": "whatsapp"
        }
      ],
      "custom_attributes": {
        "city": "Bogota",
        "plan": "premium"
      },
      "created_at": "2024-09-01T12:00:00Z",
      "updated_at": "2024-09-01T14:30:00Z"
    }
  ],
  "pagination": {
    "total": 50,
    "limit": 20,
    "offset": 0,
    "has_more": true
  }
}