Customers

Crear Customer, Subscription e Invoice

Changed on

Para cargar Invoices en Toku normalmente se crean primero un Customer, luego una Subscription y, si aplica, una Invoice, en llamadas separadas. Este endpoint consolida ese flujo: crea las tres entidades en una sola petición y de forma atómica (si algún paso falla, se revierte toda la operación).

  • El Customer es obligatorio; la Invoice es opcional.
  • La Subscription se asocia automáticamente al Customer recién creado, y la Invoice a ambos.

Devuelve los identificadores públicos de todas las entidades creadas. Es idempotente por los identificadores de cada entidad: si alguna ya existía, se actualiza y la respuesta es 200 en lugar de 201.

Límite de tasa: 20 solicitudes por segundo. Al superarlo, la API responde 429. Ver Límites de tasa.

post/entities

Request

  • Base URL
    https://api.trytoku.com
  • URL
    https://api.trytoku.com/entities
  • Auth
    API key in header x-api-key

Headers

x-account-keystring

Llave de API de una Account, para operar sobre esa Account en lugar de la principal.

x-api-versionstring date

Versión del API para esta petición, como cualquier fecha YYYY-MM-DD. Fija el contrato de la respuesta; si se omite, se deriva de la fecha de creación de la organización.

Example:2026-10-08

Request body

Example request

{
  "customer": {
    "external_id": "18579878K",
    "government_id": "18579878K",
    "mail": "jon@snow.got",
    "name": "Jon Snow",
    "phone_number": "+56987654321"
  },
  "invoice": {
    "amount": 19990,
    "due_date": "2025-03-10",
    "expiration_date": "2025-03-10 00:00:00",
    "invoice_external_id": "F-2025-000123",
    "link_payment": "https://portal.pagos.com/tu-empresa",
    "metadata": {
      "sucursal": "Providencia"
    },
    "product_id": "plan-oro-marzo-2025"
  },
  "subscription": {
    "amount": 19990,
    "due_day": 5,
    "interval": 1,
    "is_recurring": true,
    "product_id": "plan-oro-2025"
  }
}

Response

Alguna entidad ya existía y fue actualizada.

id_customerstring required

Identificador público del Customer creado (cus_...).

id_invoicestring

Identificador público de la Invoice creada (in_...). Presente solo si se envió una Invoice en la petición.

id_subscriptionstring required

Identificador público de la Subscription creada (sub_...).

Example response

{
  "id_customer": "cus_ejC08yLqOWoFhVx4Fx42E3IR9X50tNx2",
  "id_invoice": "in_9K0bTq3xR7yA2sVpLmZ4wE1nHdJf6UcQ",
  "id_subscription": "sub_Y_EgOXMloD5-IJn6d9S2IxkNvp9p0iiP"
}

Changes

    • breaking

      request body became required

    • breaking

      for the header request parameter x-account-key, default value was added

    • breaking

      added to the / request property allOf list

    • breaking

      added to the / request property allOf list

    • breaking

      added to the / request property allOf list

    • breaking

      added to the / request property allOf list

    • breaking

      the / request property's minLength was increased from 0 to 1

    • breaking

      added the pattern ^((https://)|(http://))[a-zA-Z0-9.\-_~+#,%&=*;:@!/()?_{}\[\]|~]+$ to the request property invoice/link_payment

    • breaking

      added the pattern ^(?:[^ \n](?:[^\n]*[^ \n])?)?$ to the request property /

    • breaking

      added the pattern ^\S+$ to the request property /

    • breaking

      the / request property type changed from string to no type

    • breaking

      the / request property type changed from string to no type

    • breaking

      the / request property type changed from string to number

    • breaking

      the / request property type changed from string to no type

    • breaking

      the / request property type changed from string to integer

    • breaking

      the / request property type changed from string to no type

    • breaking

      the / request property type changed from string to integer

    • breaking

      the / request property type changed from string to boolean

    • warning

      deleted the header request parameter x-api-key

    • warning

      the / request property's exclusiveMaximum was set to 1000000000000000.00

    • warning

      the / request property's exclusiveMaximum was set to 1000000000000000.00

    • warning

      the / request property's maxLength was set to 128

    • warning

      the / request property's maxLength was set to 64

    • warning

      the / request property's maxLength was set to 128

    • warning

      the / request property's maxLength was set to 16

    • warning

      the / request property's maxLength was set to 256

    • warning

      the / request property's maxLength was set to 256

    • warning

      the / request property's maxLength was set to 256

    • warning

      the / request property's maxLength was set to 8

    • warning

      the / request property's max was set to 31.00

    • warning

      the / request property's max was set to 52.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 1.00

    • warning

      the / request property's min was set to 1.00

    • info

      api operation id post_entities removed and replaced with create_unified_entities

    • info

      api tag Customers added

    • info

      endpoint deprecated

    • info

      added the new optional header request parameter x-api-version

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      added the new optional request property /

    • info

      the request property / became optional

    • info

      the request property / became optional

    • info

      the request property default value false was added

    • info

      the request property default value false was added

    • info

      the request property default value {} was added

    • info

      added the media type application/json for the response with the status

    • info

      added the media type application/json for the response with the status

    • info

      added the media type application/json for the response with the status

    • info

      added the media type application/json for the response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      removed the non-success response with the status