Basely

Basely API

Referencia de la API

Una clave por negocio. Lee los libros, las cuentas del banco, las transacciones, las facturas y las cuentas por pagar de un negocio, escribe en ellos con el permiso del dueño y recibe webhooks firmados cuando algo cambia.

Inicio rápido

  1. El dueño del negocio abre API en el panel de Basely y crea una clave con los scopes que tu sistema necesita.
  2. Guarda la clave en el entorno de tu servidor. Se muestra una sola vez.
  3. Llama a /v1/me para probar la conexión y después a los endpoints que necesites.
curl https://api.baselyapp.com/v1/me \
  -H "Authorization: Bearer bsk_live_..."

curl "https://api.baselyapp.com/v1/financial/summary?period=2026-09" \
  -H "Authorization: Bearer bsk_live_..."

Autenticación

Envía la clave como Authorization: Bearer bsk_live_... en cada solicitud.

  • El negocio sale de la clave. No hay id de negocio en la solicitud, y una clave nunca alcanza otro negocio.
  • Las claves de prueba (bsk_test_) leen el negocio real y validan escrituras, pero nunca guardan.
  • Solo el dueño del negocio crea, rota y revoca claves. La clave deja de funcionar cuando quien la creó ya no es el dueño.
  • Rotar mantiene la clave anterior funcionando durante el plazo que elijas, para que tu servidor cambie sin caerse.
  • El dueño recibe un correo cada vez que se crea o rota una clave nueva.

Scopes

Cada clave lleva solo los scopes que recibió. Un endpoint sin su scope responde 403 SCOPE_DENIED.

ScopeServicioAcceso
financial:readfinancialLee
accounts:readfinancialLee
transactions:readfinancialLee
transactions:writefinancialEscribe en los libros
invoices:readfinancialLee
invoices:writefinancialEscribe en los libros
bills:readfinancialLee
bills:writefinancialEscribe en los libros
contacts:readcrmLee
contacts:writecrmEscribe
crm:readcrmLee
crm:writecrmEscribe
conversations:readphoneLee
texts:sendphoneEscribe
inbox:writephoneEscribe
calls:createphoneEscribe
sessions:managephoneEscribe
otp:sendphoneEscribe
phone_contacts:writephoneEscribe
bank:refreshbankingPróximamente
email:sendemailEscribe
email:reademailLee
email_templates:writeemailEscribe
mailboxes:reademailLee
mailboxes:writeemailEscribe
sms:sendsmsEscribe
sms:readsmsLee
receptionist:readreceptionistLee
receptionist:writereceptionistEscribe
receptionist:sessionsreceptionistEscribe
social:readsocialLee
social:writesocialEscribe
funnels:readfunnelsLee
automations:readautomationsLee
courses:readcoursesLee
calendar:readcalendarPróximamente
calendar:writecalendarPróximamente
files:readfilesPróximamente

Endpoints

URL base abajo. Toda respuesta tiene el encabezado x-request-id.

Plataforma

GET/v1/meany keyThe business and the key behind this request.

Finanzas

GET/v1/financial/summaryfinancial:readCash, inflows, outflows, expenses, recurring costs, burn and runway for a period.
GET/v1/financial/cash-flowfinancial:readCash flow month by month: operating, investing and financing.
GET/v1/financial/reports/{report}financial:readA financial report: pnl, balance-sheet, expenses-by-category or trial-balance.
GET/v1/accountsaccounts:readBank accounts connected to the books, with their ledger balance.
GET/v1/transactionstransactions:readBank transactions, newest first.
GET/v1/transactions/{id}transactions:readOne bank transaction.
POST/v1/transactions/{id}/categorizetransactions:writePost a bank transaction to a category in the books.
GET/v1/invoicesinvoices:readInvoices, newest first.
POST/v1/invoicesinvoices:writeCreate an invoice.
GET/v1/invoices/{id}invoices:readOne invoice, with what is still open.
POST/v1/invoices/{id}/paymentsinvoices:writeRecord a payment received for an invoice.
GET/v1/billsbills:readBills to pay, newest first.
POST/v1/billsbills:writeCreate a bill to pay.

CRM

GET/v1/contactscontacts:readContacts of the business.
POST/v1/contactscontacts:writeCreate a contact, or update the one with the same email or phone.
GET/v1/companiescrm:readCompanies of the business, newest first. Phone masked. Page with created_before.
GET/v1/dealscrm:readDeals of the business, newest first: stage, value in cents, contact and company. Filter with stage and archived=true. Page with created_before.
GET/v1/pipelinescrm:readThe business's pipelines, each with its stages in order.
GET/v1/taskscrm:readTasks of the business, newest first. status=open (default), done or all.
POST/v1/dealscrm:writeCreate a deal: name, and optionally stage, pipeline_id, category, value_cents, currency, contact_id, company_id, expected_close. Requires Idempotency-Key.
PATCH/v1/deals/{id}crm:writeUpdate a deal or move it to another stage: name, stage, category, value_cents, contact_id, company_id, expected_close, archived. Moving a stage can start an automation the owner turned on. Requires Idempotency-Key.
POST/v1/companiescrm:writeCreate a company: name, and optionally industry, phone, email, address, website, description. Requires Idempotency-Key.
POST/v1/taskscrm:writeCreate a task: text, and optionally type (follow_up, ligar, visita, enviar, outro), due_at, contact_id, deal_id. Requires Idempotency-Key.
PATCH/v1/tasks/{id}crm:writeMark a task done or open again: { done }. Requires Idempotency-Key.

Email

POST/v1/email/sendemail:sendSend one transactional email from the business's verified domain. Accepts Idempotency-Key.
POST/v1/email/send/batchemail:sendSend up to 100 transactional emails in one call, each with ONE recipient, its own variables and its own idempotency_key. Each message counts 1 in the plan's emails. The answer is per message (207 when some failed). More than 20 identical messages without variables is a campaign (422), and batches are limited to 300 messages per hour per business (429). Attachments go one per call on /v1/email/send.
GET/v1/email/messagesemail:readEmails sent by the business, newest first.
GET/v1/email/messages/{id}email:readOne email, with its status and delivery events.
GET/v1/email/sendersemail:readThe business's sender and whether it can send now.
GET/v1/email/templatesemail:readThe business's email templates.
POST/v1/email/templatesemail_templates:writeCreate a template. A slug that already exists (from the panel, the connector or the API) returns 409 SLUG_EXISTE with its origin; change it with PUT. Variables are {{name}} and are escaped on send.
GET/v1/email/templates/{slug}email:readOne template.
PUT/v1/email/templates/{slug}email_templates:writeUpdate a template, wherever it was created (panel, connector or API).
POST/v1/email/templates/batchemail_templates:writeCreate or update up to 50 templates in one call (counts as one request). Each item may set mode: upsert (default), create or update. The answer is per item (207 when some failed); the same batch repeated gives the same result.
DELETE/v1/email/templates/{slug}email_templates:writeMove a template to the trash for 30 days (restore with POST .../restore). A template used in the last 7 days returns 409 TEMPLATE_IN_USE with last_used_at; repeat with ?confirm=true.
POST/v1/email/templates/{slug}/restoreemail_templates:writeBring a template back from the trash within 30 days. 409 SLUG_EXISTE if the slug was created again meanwhile.
POST/v1/email/templates/{slug}/previewemail_templates:writeRender a saved template with example variables, as it would be sent. Does not send, does not count and fetches nothing. Lists missing_variables.
POST/v1/email/templates/previewemail_templates:writeRender a template that is not saved yet (template: subject, html, text) with example variables. Does not send, save or fetch anything.
GET/v1/mailboxesmailboxes:readThe business's mailboxes: those on a domain of the business's site, owned by the business owner.
GET/v1/mailboxes/{address}mailboxes:readOne mailbox, with usage (bytes_used, bytes_max, messages) and two_factor_enabled read live from the mail server (null when it could not be read). A mailbox of another business returns 404.
POST/v1/mailboxesmailboxes:writeCreate a mailbox on a domain of the business's site, within the plan's free mailboxes (above it, 402 with the link to pay in the panel). No password is accepted or returned: a single-use link to set it (24 hours) goes to the account's email.
POST/v1/mailboxes/{address}/password-linkmailboxes:writeSend the account owner a single-use link (24 hours) to set the mailbox password. The password never goes through the API.
GET/v1/mailboxes/{address}/forwardingmailboxes:readForwarding destinations of the mailbox and whether each one is confirmed.
PUT/v1/mailboxes/{address}/forwardingmailboxes:writeAsk to forward the mailbox to an address. Nothing is forwarded until the owner of the destination confirms by the link we send there; the API cannot confirm. The account owner is notified.
DELETE/v1/mailboxes/{address}/forwardingmailboxes:writeStop forwarding to ?destination=.
PUT/v1/mailboxes/{address}/autorespondermailboxes:writeTurn the automatic reply on or off, with an optional start and end. One reply per sender every 24 hours.
PUT/v1/mailboxes/{address}/aliasesmailboxes:writeReplace the mailbox aliases (addresses on the same domain that deliver to it). The account owner is notified.

SMS

POST/v1/sms/sendsms:sendSend one transactional text from a business number. Accepts Idempotency-Key.
GET/v1/sms/messagessms:readTexts sent by the business, newest first. Recipients are masked.
GET/v1/sms/messages/{id}sms:readOne text, with its delivery status and segments.
GET/v1/sms/senderssms:readThe business numbers, with the US A2P registration status and whether each can send now.

AI Receptionist

GET/v1/receptionist/agentsreceptionist:readThe business's AI receptionist agents (one in v1), with greeting, hours, languages and powers.
GET/v1/receptionist/agents/{id}receptionist:readOne agent.
PATCH/v1/receptionist/agents/{id}receptionist:writeChange the agent: name, greeting, voice, timezone, languages, hours, powers, instructions and knowledge.
PUT/v1/receptionist/agents/{id}/toolsreceptionist:writeReplace the set of Basely tools the agent may use.
GET/v1/receptionist/toolsreceptionist:readThe Basely tools (enabled or not) and the app tools registered for the agent.
GET/v1/receptionist/app-toolsreceptionist:readTools of your own system that the receptionist can call.
POST/v1/receptionist/app-toolsreceptionist:writeRegister (or update by name) a tool of your system. The signing secret is returned once, on creation.
DELETE/v1/receptionist/app-tools/{name}receptionist:writeRemove a registered app tool.
GET/v1/receptionist/numbersreceptionist:readThe numbers the receptionist answers, with channels and the US SMS registration.
GET/v1/receptionist/sessionsreceptionist:readCalls and text conversations the receptionist handled, newest first.
POST/v1/receptionist/sessionsreceptionist:sessionsTalk to the receptionist from your site or app chat (channel web): send the visitor's message, get the reply.
POST/v1/receptionist/sessions/{id}/handoffreceptionist:sessionsHand a conversation to the team: the receptionist stops answering this contact for 24 hours and the owner is notified.
GET/v1/receptionist/sessions/{id}receptionist:readOne session, with transcript, summary, outcome and measured cost.
GET/v1/receptionist/usagereceptionist:readUsage this month: the receptionist's own cost by part, and the texts and emails it started.

Redes sociales

GET/v1/social/accountssocial:readThe social accounts connected to the business (Instagram, Facebook...).
GET/v1/social/automationssocial:readThe automations the owner set up in Social > Plugs, with the photo slots and variables of each template.
POST/v1/social/mediasocial:writeStore a photo in the business library, from an https URL or the raw image body. Returns a media id.
POST/v1/social/postssocial:writePost through an automation: send the photos and variables; the template and caption the owner accepted go out on their own. Accepts Idempotency-Key.
GET/v1/social/postssocial:readPosts requested through the API, newest first, rejections included.
GET/v1/social/posts/{id}social:readOne post, with its status and the links once it is published.

Embudos

GET/v1/funnelsfunnels:readThe business's funnels: status, number of steps and when they were published.
GET/v1/funnels/submissionsfunnels:readForm submissions from the funnels, newest first: the answers, consent, and the contact and deal they created. Filter with funnel_id or form_id. Personal data: the visitor's IP is never returned.

Automatizaciones

GET/v1/automationsautomations:readThe business's automations: enabled, published, trigger type, number of steps and how many contacts are in them.
GET/v1/automations/{id}/runsautomations:readRuns of one automation, newest first, each with its steps and results. status=active, done, failed, waiting_approval or left.

Cursos

GET/v1/coursescourses:readThe business's courses with their status and number of students.
GET/v1/courses/{id}/studentscourses:readStudents of one course with their progress and certificate.

Teléfono y textos

GET/v1/businesses/{negocioId}/conversationsconversations:readMessages and calls, masked.
POST/v1/businesses/{negocioId}/textstexts:sendSend a text from the business number.
POST/v1/businesses/{negocioId}/emailsinbox:writeHand a received email to the inbox.
POST/v1/businesses/{negocioId}/callscalls:createRing a team member.
POST/v1/businesses/{negocioId}/contactsphone_contacts:writeDeclare a customer or a team member.
POST/v1/businesses/{negocioId}/sessionssessions:manageOpen a masked line.
DELETE/v1/businesses/{negocioId}/sessions/{sessionId}sessions:manageClose a masked line.
POST/v1/businesses/{negocioId}/otpotp:sendSend a one-time code by text.
POST/v1/businesses/{negocioId}/otp/verifyotp:sendVerify a one-time code.

Convenciones

  • El dinero va en centavos enteros con la moneda. Las fechas en ISO 8601.
  • Las listas devuelven object: list, data, has_more. Usa limit (hasta 100) y from/to para filtrar.
  • Los saldos vienen de los libros, que el banco mantiene al día solo. Leer nunca le pregunta al banco directo.
  • Actualizar ahora en el banco (Fresh) es una acción aparte, con su propia cuota mensual. Leer la API nunca gasta Fresh.
  • Límite por clave por minuto: 120 lecturas, 30 escrituras, 20 reportes. Al pasarlo: 429 con retry-after.
  • Además del límite por clave, el negocio entero tiene un tope sumando sus claves: 300 lecturas y 60 escrituras por minuto (BUSINESS_RATE_LIMITED).
  • Toda escritura acepta la cabecera Idempotency-Key. Repetirla con la misma solicitud devuelve la respuesta guardada, con Idempotent-Replayed: true, durante 24 horas; con otra solicitud, 409 IDEMPOTENCY_KEY_REUSED.
  • La API lee y escribe dentro del negocio. Lo que envía en su nombre (correo, SMS, código, una publicación por automatización) solo pasa con el scope que marcó el dueño. Cobrar, reembolsar, cambiar precios y comprar nunca pasan por la API.

Errores

El error tiene un código estable, un mensaje para personas y el id de la solicitud. Los errores de escritura agregan reason y field.

{ "error": { "code": "SCOPE_DENIED", "message": "...", "scope": "invoices:write", "request_id": "req_..." } }
LEVEL_NOT_ALLOWEDThis action is not available through the API. Do it in the dashboard.
BUSINESS_RATE_LIMITEDToo many requests for this business across all its keys. Retry after the time in Retry-After.
IDEMPOTENCY_KEY_INVALIDIdempotency-Key must be 1 to 255 printable ASCII characters.
IDEMPOTENCY_KEY_REQUIREDThis write needs an Idempotency-Key header. Send a new one per action and repeat it on retries.
MISSING_KEYSend your API key as Authorization: Bearer <key>.
INVALID_KEYThis API key is not valid.
KEY_REVOKEDThis API key was revoked or replaced. Use the current key of this business.
KEY_EXPIREDThis API key expired. Ask the owner of the business for a new one.
NOT_FOUNDNot found.
BUSINESS_FROZENThis business is frozen. Calls resume when it is active again.
BUSINESS_CLOSEDThis business is closed.
SCOPE_DENIEDThis key does not have the scope this endpoint needs.
AFFILIATE_ONLY_ACCOUNTThis key belongs to an affiliate-only account, which cannot use the API.
MODULE_NOT_ENABLEDFinance is not enabled for this business.
BOOKS_NOT_SET_UPThe books of this business are not set up yet.
RATE_LIMITEDToo many requests for this key. Wait and try again.
INVALID_REQUESTThe request is not valid.
INVALID_JSONThe body must be a JSON object.
TEST_MODETest keys validate writes but never save them.
CONFLICTThe books do not allow this change right now. See reason.
FORBIDDENThe owner of this key can no longer do this in the business.
NO_SENDERThis business has no sender for this channel yet.
SENDER_NOT_REGISTEREDThis number is not registered with the carriers for business texting yet (A2P 10DLC). Finish the registration in Phone > Number.
SENDER_NOT_VERIFIEDThe sender domain of this business is not verified yet.
SENDER_PAUSEDSending is paused for this business. See the reason in the panel.
SYSTEM_SENDER_ONLY_FOR_SYSTEMThe system sender only sends system messages.
RECIPIENT_OPTED_OUTThis recipient opted out of texts from this business.
RECIPIENT_SUPPRESSEDThis address bounced or complained before; sending is blocked.
RECIPIENT_REJECTEDThe provider rejected this recipient.
RECIPIENT_NOT_FOUNDNo contact with this id or external id in this business.
TETO_GLOBAL_DE_SMSTexting is paused for the whole platform right now (daily limit). Try again later.
DESTINO_FORA_DA_ZONAThis number is outside the dialing zone of the business number. Texts and calls stay within the same country (US and Canada for +1).
INVALID_RECIPIENTThe recipient is not a valid phone number in E.164 format.
EMPTY_BODYThe message body is empty.
QUOTA_EXCEEDEDThe quota of this business for this service is used up.
PROVIDER_UNAVAILABLEThe delivery provider is unavailable. Try again later with the same Idempotency-Key.
IDEMPOTENCY_KEY_REUSEDThis Idempotency-Key was already used with a different request.
IDEMPOTENCY_IN_PROGRESSA request with this Idempotency-Key is still being processed.
BULK_NOT_ALLOWEDOne recipient per request. Lists are campaigns.
CATEGORY_NOT_ALLOWEDThis category is not allowed for this service yet.
CHANNEL_NOT_AVAILABLEThis channel is not offered. See the hint.
RECEPTIONIST_OFFThe receptionist is turned off for this business.
PLAN_REQUIREDThe business needs an active Phone plan for the receptionist to answer.
BUDGET_REACHEDThe receptionist reached this month's spending cap. A person will follow up.
TEMPLATE_NOT_FOUNDNo template with this slug in this business.
TEMPLATE_IN_USEThis template was used in the last 7 days. Repeat with ?confirm=true to move it to the trash anyway (restorable for 30 days).
ATTACHMENT_URL_NOT_ALLOWEDAttachments are not fetched from URLs. Send the content in base64 or a storage_id from POST /v1/social/media.
ATTACHMENT_NOT_FOUNDNo file with this storage_id in this business.
ATTACHMENT_TYPE_NOT_ALLOWEDOnly PNG, JPEG, GIF, WebP, PDF and .ics files can be attached. The type is read from the content.
ATTACHMENT_PDF_ACTIVE_CONTENTThis PDF has JavaScript, a launch action or an embedded file, and cannot be attached.
ATTACHMENT_NAME_INVALIDThe file name must be up to 120 characters, without line breaks.
ATTACHMENT_NAME_MISMATCHThe file name extension does not match its content.
ATTACHMENT_TOO_LARGEEach attachment can have at most 5 MB.
ATTACHMENTS_TOO_LARGEThe attachments of one email can have at most 10 MB together.
TOO_MANY_ATTACHMENTSAt most 5 attachments per email.
TOO_MANY_ITEMSAt most 50 templates per batch.
PAYLOAD_TOO_LARGEThe request body is too large (5 MB at most).
DUPLICATE_IN_BATCHThe same slug appears twice in this batch.
SLUG_EXISTEA template with this slug already exists in this business (see origin: panel, connector or API). Use PUT /v1/email/templates/{slug} to change it.
SEND_FAILEDThe message was not accepted for delivery. Do not retry it unchanged.
AUTOMATION_NOT_FOUNDNo automation with this name in this business. See GET /v1/social/automations.
AUTOMATION_OFFThis automation is off. The owner turns it on in Social > Plugs; a change to its template or caption turns it off until accepted again.
SOCIAL_PLAN_REQUIREDThe business needs an active Social plan to publish.
CONSENT_REQUIREDSend consent.photo: true and consent.collected_at: the customer must have authorized the photo before it is posted.
DAILY_LIMIT_REACHEDThis automation reached its daily limit. The owner sets it in Social > Plugs.
MISSING_PHOTOA photo slot of the template has no photo. See field.
UNKNOWN_SLOTThis photo slot does not exist in the template. See field.
INVALID_PHOTOThe photo must be an https URL or a media id from POST /v1/social/media.
PHOTO_UNAVAILABLEWe could not download this photo as a PNG, JPG or WEBP image. See field.
PHOTO_TOO_LARGEPhotos go up to 15 MB.
MEDIA_NOT_FOUNDNo image with this media id in this business.
MISSING_VARIABLEA text variable of the template is missing. See field.
UNKNOWN_VARIABLEThis variable does not exist in the template. See field.
INVALID_VARIABLEVariables are up to 30 characters, one line, with no link, @ or #.
RENDER_UNAVAILABLEThe artwork could not be rendered right now. Try again later with the same reference.
PUBLISH_FAILEDThe post was not accepted by the publishing engine. See the post status.
PASSWORD_NOT_ACCEPTEDThe API never receives a mailbox password. A single-use link to set it goes to the account's email.
DOMAIN_NOT_IN_BUSINESSThis domain is not a domain of the business's site.
MAILBOX_REQUIRES_PAYMENTThis mailbox is beyond the plan's free mailboxes. Add it in the panel (see cta).
PLAN_LOCKEDCreating mailboxes unlocks after the account's first payment (see cta).
MAILBOX_EXISTSA mailbox with this address already exists.
MAILBOX_IS_GROUPThis address is a group: it forwards to its members and has no password or login.
CONTA_SEM_EMAILThe account that owns this mailbox has no email to receive the link.
SERVICE_UNAVAILABLEThe mail service is not configured right now. Try again later.
PROVIDER_FAILEDThe mail server did not accept the change. Try again; if it keeps failing, send us the request_id.
TOO_MANY_MESSAGESAt most 100 messages per batch.
ATTACHMENTS_NOT_IN_BATCHEmails with attachments are sent one per call on POST /v1/email/send.
DUPLICATE_IDEMPOTENCY_KEYThe same idempotency_key appears twice in this batch.
BATCH_LOOKS_LIKE_CAMPAIGNMore than 20 messages in this batch have the same content and no variables. That is a campaign: send it from Email marketing, with unsubscribe.
BATCH_HOURLY_LIMITThis business reached the batch limit for the last hour (see limit and used). Try again later or send one per call.
INTERNALSomething failed on our side. Try again; if it keeps failing, send us the request_id.

Webhooks

El dueño registra la dirección de tu sistema y elige los eventos. La entrega reintenta durante 24 horas.

transaction.createdtransaction.categorizedinvoice.createdinvoice.paidbill.createdbill.paidbank_connection.disconnectedsms.sentsms.deliveredsms.failedsms.opted_outemail.sentemail.deliveredemail.bouncedemail.complainedemail.failedemail.sender.verifiedemail.sender.failedreceptionist.session.startedreceptionist.session.endedreceptionist.handoff_requestedreceptionist.tool_calledsocial.post.publishedsocial.post.failed

Cada entrega va firmada con el secreto de la dirección en basely-signature y trae basely-event-id para descartar repeticiones. Verifícalo así:

import { createHmac, timingSafeEqual } from "node:crypto";

// header: basely-signature: t=<unix seconds>,v1=<hex>
export function isFromBasely(rawBody: string, header: string, secret: string): boolean {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=") as [string, string]));
  const expected = createHmac("sha256", secret).update(`${parts.t}.${rawBody}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
  return fresh && timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1 ?? ""));
}