Skip to main content
API to create or update a text2pay invoice
POST https://services.leadconnectorhq.com/invoices/text2pay

Autorización

Authorization
string
required
Bearer token generado desde el portal Leadway. Ver Autenticación.
Version
string
default:"2021-07-28"
required
Versión de la API.

Body

altId
string
default:"6578278e879ad2646715ba9c"
required
account Id / company Id based on altType
altType
string
default:"account"
required
Alt Type Posibles valores: ‘account’
name
string
default:"New Invoice"
required
Invoice Name
currency
string
default:"USD"
required
Currency code
items
object[]
required
An array of items for the invoice.
termsNotes
string
default:"<p>This is a default terms.</p>"
Terms notes, Also supports HTML markups
title
string
default:"INVOICE"
Title for the invoice
contactDetails
object
required
Contact information to send the invoice to
invoiceNumber
string
default:"1001"
Invoice Number
issueDate
string
default:"2023-01-01"
required
Issue date in YYYY-MM-DD format
dueDate
string
default:"2023-01-14"
Due date in YYYY-MM-DD format
sentTo
object
required
liveMode
boolean
required
automaticTaxesEnabled
boolean
default:"True"
Automatic taxes enabled for the Invoice
paymentSchedule
object
split invoice into payment schedule summing up to full invoice amount
lateFeesConfiguration
object
late fees configuration
tipsConfiguration
object
tips configuration for the invoice
invoiceNumberPrefix
string
default:"INV-"
prefix for invoice number
paymentMethods
object
Payment Methods for Invoices
attachments
object[]
attachments for the invoice
miscellaneousCharges
object
miscellaneous charges for the invoice
id
string
id of invoice to update. If skipped, a new invoice will be created
includeTermsNote
boolean
default:"True"
include terms & notes with receipts
action
string
default:"draft"
required
create invoice in draft mode or send mode Posibles valores: ‘draft’, ‘send’
userId
string
required
id of user generating invoice
discount
object
businessDetails
object

Respuestas

invoice
object
required
invoiceUrl
string
required
preview url of generated invoice
{
  "invoice": {
    "_id": "6578278e879ad2646715ba9c",
    "status": "draft",
    "liveMode": false,
    "amountPaid": 0,
    "altId": "6578278e879ad2646715ba9c",
    "altType": "account",
    "name": "New Invoice",
    "businessDetails": {
      "name": "Alex",
      "address": {
        "addressLine1": "9931 Beechwood",
        "city": "St. Houston",
        "state": "TX",
        "countryCode": "USA",
        "postalCode": "559-6993"
      },
      "phoneNo": "+1-214-559-6993",
      "website": "www.example.com"
    },
    "invoiceNumber": "19",
    "currency": "USD",
    "contactDetails": {
      "id": "c6tZZU0rJBf30ZXx9Gli",
      "phoneNo": "+1-214-559-6993",
      "email": "alex@example.com",
      "customFields": [],
      "name": "Alex",
      "address": {
        "countryCode": "US"
      }
    },
    "issueDate": "2023-01-01",
    "dueDate": "2023-01-01",
    "discount": {
      "type": "percentage",
      "value": 0
    },
  // truncado: 23 lineas mas
}
{}
{}
{}

Ejemplo

curl -X POST 'https://services.leadconnectorhq.com/invoices/text2pay' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Version: 2021-07-28' \
  -H 'Content-Type: application/json' \
  -d '{
  "altId": "6578278e879ad2646715ba9c",
  "altType": "account",
  "name": "New Invoice",
  "currency": "USD",
  "items": [
    {
      "name": "ABC Product",
      "description": "ABC Corp.",
      "productId": "6578278e879ad2646715ba9c",
      "priceId": "6578278e879ad2646715ba9c",
      "currency": "USD",
      "amount": 999,
      "qty": 1,
      "taxes": [
        {}
      ],
      "automaticTaxCategoryId": "6578278e879ad2646715ba9c",
      "isSetupFeeItem": true,
      "type": "one_time",
      "taxInclusive": true
    }
  ],
  "termsNotes": "<p>This is a default terms.</p>",
  "title": "INVOICE",
  "invoiceNumber": "1001",
  "issueDate": "2023-01-01",
  "dueDate": "2023-01-14",
  "sentTo": {
    "email": [
      "alex@example.com"
    ],
    "emailCc": [
      "alex@example.com"
    ],
    "emailBcc": [
      "alex@example.com"
    ],
    "phoneNo": [
      "+1-214-559-6993"
    ]
  },
  "liveMode": true,
  "automaticTaxesEnabled": true,
  "invoiceNumberPrefix": "INV-",
  "attachments": [
    {
      "id": "6241712be68f7a98102ba272",
      "name": "Electronics.pdf",
      "url": "https://example.com/digital-delivery",
      "type": "string",
      "size": 10000
    }
  ],
  "id": "string",
  "includeTermsNote": true,
  "action": "draft",
  "userId": "string",
  "discount": {
    "value": 10,
    "type": "percentage",
    "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"
  },
  "businessDetails": {
    "logoUrl": "https://example.com/logo.png",
    "name": "ABC Corp.",
    "phoneNo": "+1-214-559-6993",
    "address": "9931 Beechwood, TX",
    "website": "wwww.example.com",
    "customValues": [
      "string"
    ]
  }
}'
const response = await fetch('https://services.leadconnectorhq.com/invoices/text2pay', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
    Version: '2021-07-28',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"altId": "6578278e879ad2646715ba9c", "altType": "account", "name": "New Invoice", "currency": "USD", "items": [{"name": "ABC Product", "description": "ABC Corp.", "productId": "6578278e879ad2646715ba9c", "priceId": "6578278e879ad2646715ba9c", "currency": "USD", "amount": 999, "qty": 1, "taxes": [{}], "automaticTaxCategoryId": "6578278e879ad2646715ba9c", "isSetupFeeItem": true, "type": "one_time", "taxInclusive": true}], "termsNotes": "<p>This is a default terms.</p>", "title": "INVOICE", "invoiceNumber": "1001", "issueDate": "2023-01-01", "dueDate": "2023-01-14", "sentTo": {"email": ["alex@example.com"], "emailCc": ["alex@example.com"], "emailBcc": ["alex@example.com"], "phoneNo": ["+1-214-559-6993"]}, "liveMode": true, "automaticTaxesEnabled": true, "invoiceNumberPrefix": "INV-", "attachments": [{"id": "6241712be68f7a98102ba272", "name": "Electronics.pdf", "url": "https://example.com/digital-delivery", "type": "string", "size": 10000}], "id": "string", "includeTermsNote": true, "action": "draft", "userId": "string", "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "businessDetails": {"logoUrl": "https://example.com/logo.png", "name": "ABC Corp.", "phoneNo": "+1-214-559-6993", "address": "9931 Beechwood, TX", "website": "wwww.example.com", "customValues": ["string"]}}),
});
const data = await response.json();
import os, requests
response = requests.request(
    'POST',
    'https://services.leadconnectorhq.com/invoices/text2pay',
    headers={
        'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
        'Version': '2021-07-28',
        'Content-Type': 'application/json',
    },
    json={"altId": "6578278e879ad2646715ba9c", "altType": "account", "name": "New Invoice", "currency": "USD", "items": [{"name": "ABC Product", "description": "ABC Corp.", "productId": "6578278e879ad2646715ba9c", "priceId": "6578278e879ad2646715ba9c", "currency": "USD", "amount": 999, "qty": 1, "taxes": [{}], "automaticTaxCategoryId": "6578278e879ad2646715ba9c", "isSetupFeeItem": true, "type": "one_time", "taxInclusive": true}], "termsNotes": "<p>This is a default terms.</p>", "title": "INVOICE", "invoiceNumber": "1001", "issueDate": "2023-01-01", "dueDate": "2023-01-14", "sentTo": {"email": ["alex@example.com"], "emailCc": ["alex@example.com"], "emailBcc": ["alex@example.com"], "phoneNo": ["+1-214-559-6993"]}, "liveMode": true, "automaticTaxesEnabled": true, "invoiceNumberPrefix": "INV-", "attachments": [{"id": "6241712be68f7a98102ba272", "name": "Electronics.pdf", "url": "https://example.com/digital-delivery", "type": "string", "size": 10000}], "id": "string", "includeTermsNote": true, "action": "draft", "userId": "string", "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "businessDetails": {"logoUrl": "https://example.com/logo.png", "name": "ABC Corp.", "phoneNo": "+1-214-559-6993", "address": "9931 Beechwood, TX", "website": "wwww.example.com", "customValues": ["string"]}},
)
data = response.json()
<?php
$ch = curl_init('https://services.leadconnectorhq.com/invoices/text2pay');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
        'Version: 2021-07-28',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode({'altId': '6578278e879ad2646715ba9c', 'altType': 'account', 'name': 'New Invoice', 'currency': 'USD', 'items': [{'name': 'ABC Product', 'description': 'ABC Corp.', 'productId': '6578278e879ad2646715ba9c', 'priceId': '6578278e879ad2646715ba9c', 'currency': 'USD', 'amount': 999, 'qty': 1, 'taxes': [{}], 'automaticTaxCategoryId': '6578278e879ad2646715ba9c', 'isSetupFeeItem': true, 'type': 'one_time', 'taxInclusive': true}], 'termsNotes': '<p>This is a default terms.</p>', 'title': 'INVOICE', 'invoiceNumber': '1001', 'issueDate': '2023-01-01', 'dueDate': '2023-01-14', 'sentTo': {'email': ['alex@example.com'], 'emailCc': ['alex@example.com'], 'emailBcc': ['alex@example.com'], 'phoneNo': ['+1-214-559-6993']}, 'liveMode': true, 'automaticTaxesEnabled': true, 'invoiceNumberPrefix': 'INV-', 'attachments': [{'id': '6241712be68f7a98102ba272', 'name': 'Electronics.pdf', 'url': 'https://example.com/digital-delivery', 'type': 'string', 'size': 10000}], 'id': 'string', 'includeTermsNote': true, 'action': 'draft', 'userId': 'string', 'discount': {'value': 10, 'type': 'percentage', 'validOnProductIds': '[ '6579751d56f60276e5bd4154' ]'}, 'businessDetails': {'logoUrl': 'https://example.com/logo.png', 'name': 'ABC Corp.', 'phoneNo': '+1-214-559-6993', 'address': '9931 Beechwood, TX', 'website': 'wwww.example.com', 'customValues': ['string']}}),
]);
$data = json_decode(curl_exec($ch), true);