> ## Documentation Index
> Fetch the complete documentation index at: https://developers.leadwaycrm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Invoice

> API to create an invoice

API to create an invoice

```http theme={null}
POST https://services.leadconnectorhq.com/invoices/
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Body

<ParamField body="altId" type="string" required default="6578278e879ad2646715ba9c">
  account Id / company Id based on altType
</ParamField>

<ParamField body="altType" type="string" required default="account">
  Alt Type Posibles valores: 'account'
</ParamField>

<ParamField body="name" type="string" required default="New Invoice">
  Invoice Name
</ParamField>

<ParamField body="businessDetails" type="object" required>
  <Expandable title="propiedades">
    <ParamField body="logoUrl" type="string" default="https://example.com/logo.png">
      Business Logo URL
    </ParamField>

    <ParamField body="name" type="string" default="ABC Corp.">
      Business Name
    </ParamField>

    <ParamField body="phoneNo" type="string" default="+1-214-559-6993">
      Business Phone Number
    </ParamField>

    <ParamField body="address" type="object" default="9931 Beechwood, TX">
      Business Address
    </ParamField>

    <ParamField body="website" type="string" default="wwww.example.com">
      Business Website Link
    </ParamField>

    <ParamField body="customValues" type="string[]">
      Custom Values
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="currency" type="string" required default="USD">
  Currency code
</ParamField>

<ParamField body="items" type="object[]" required>
  An array of items for the invoice.

  <Expandable title="cada item">
    <ParamField body="name" type="string" required default="ABC Product">
      Invoice Item Name
    </ParamField>

    <ParamField body="description" type="string" default="ABC Corp.">
      Invoice descriptions
    </ParamField>

    <ParamField body="productId" type="string" default="6578278e879ad2646715ba9c">
      Product Id
    </ParamField>

    <ParamField body="priceId" type="string" default="6578278e879ad2646715ba9c">
      Price Id
    </ParamField>

    <ParamField body="currency" type="string" required default="USD">
      Currency
    </ParamField>

    <ParamField body="amount" type="number" required default="999">
      Product amount
    </ParamField>

    <ParamField body="qty" type="number" required default="1">
      Product Quantity
    </ParamField>

    <ParamField body="taxes" type="object[]">
      Tax

      <Expandable title="cada item">
        <ParamField body="_id" type="string" required />

        <ParamField body="name" type="string" required />

        <ParamField body="rate" type="number" required />

        <ParamField body="calculation" type="string">
          Posibles valores: 'exclusive'
        </ParamField>

        <ParamField body="description" type="string" />

        <ParamField body="taxId" type="string" />
      </Expandable>
    </ParamField>

    <ParamField body="automaticTaxCategoryId" type="string" default="6578278e879ad2646715ba9c">
      Tax category id for calculating automatic tax
    </ParamField>

    <ParamField body="isSetupFeeItem" type="boolean">
      Setupfee item, only created when 1st invoice of recurring schedule is generated
    </ParamField>

    <ParamField body="type" type="string" default="one_time">
      Price type of the item Posibles valores: 'one\_time', 'recurring'
    </ParamField>

    <ParamField body="taxInclusive" type="boolean" default="True">
      true if item amount is tax inclusive
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="discount" type="object" required>
  <Expandable title="propiedades">
    <ParamField body="value" type="number" default="10">
      Discount Value
    </ParamField>

    <ParamField body="type" type="string" required default="percentage">
      Discount type Posibles valores: 'percentage', 'fixed'
    </ParamField>

    <ParamField body="validOnProductIds" type="string[]" default="[ '6579751d56f60276e5bd4154' ]">
      Product Ids on which discount is applicable
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="termsNotes" type="string" default="<p>This is a default terms.</p>">
  Terms notes, Also supports HTML markups
</ParamField>

<ParamField body="title" type="string" default="INVOICE">
  Title for the invoice
</ParamField>

<ParamField body="contactDetails" type="object" required>
  Contact information to send the invoice to
</ParamField>

<ParamField body="invoiceNumber" type="string" default="1001">
  Invoice Number
</ParamField>

<ParamField body="issueDate" type="string" required default="2023-01-01">
  Issue date in YYYY-MM-DD format
</ParamField>

<ParamField body="dueDate" type="string" default="2023-01-14">
  Due date in YYYY-MM-DD format
</ParamField>

<ParamField body="sentTo" type="object" required>
  <Expandable title="propiedades">
    <ParamField body="email" type="string[]" required>
      Email Address
    </ParamField>

    <ParamField body="emailCc" type="string[]">
      cc to be kept in any sent out emails
    </ParamField>

    <ParamField body="emailBcc" type="string[]">
      bcc to be kept in any sent out emails
    </ParamField>

    <ParamField body="phoneNo" type="string[]">
      Contact Phone Number
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="liveMode" type="boolean" required />

<ParamField body="automaticTaxesEnabled" type="boolean" default="True">
  Automatic taxes enabled for the Invoice
</ParamField>

<ParamField body="paymentSchedule" type="object">
  split invoice into payment schedule summing up to full invoice amount
</ParamField>

<ParamField body="lateFeesConfiguration" type="object">
  late fees configuration
</ParamField>

<ParamField body="tipsConfiguration" type="object">
  tips configuration for the invoice
</ParamField>

<ParamField body="invoiceNumberPrefix" type="string" default="INV-">
  prefix for invoice number
</ParamField>

<ParamField body="paymentMethods" type="object">
  Payment Methods for Invoices
</ParamField>

<ParamField body="attachments" type="object[]">
  attachments for the invoice

  <Expandable title="cada item">
    <ParamField body="id" type="string" required default="6241712be68f7a98102ba272">
      Id of the file selected
    </ParamField>

    <ParamField body="name" type="string" required default="Electronics.pdf">
      Name of the file
    </ParamField>

    <ParamField body="url" type="string" required default="https://example.com/digital-delivery">
      URL of the file
    </ParamField>

    <ParamField body="type" type="string" required>
      Type of the file
    </ParamField>

    <ParamField body="size" type="number" required default="10000">
      Size of the file
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="miscellaneousCharges" type="object">
  miscellaneous charges for the invoice
</ParamField>

## Respuestas

<Accordion title="200 - Successful response">
  <ResponseField name="_id" type="string" required default="6578278e879ad2646715ba9c">
    Invoice Id
  </ResponseField>

  <ResponseField name="status" type="string" required default="draft">
    Invoice Status Posibles valores: 'draft', 'sent', 'payment\_processing', 'paid', 'void', 'partially\_paid'
  </ResponseField>

  <ResponseField name="liveMode" type="boolean" required default="False">
    Live Mode
  </ResponseField>

  <ResponseField name="amountPaid" type="number" required default="0">
    Amount Paid
  </ResponseField>

  <ResponseField name="altId" type="string" required default="6578278e879ad2646715ba9c">
    Account Id or Agency Id
  </ResponseField>

  <ResponseField name="altType" type="string" required>
    Posibles valores: 'account'
  </ResponseField>

  <ResponseField name="name" type="string" required default="New Invoice">
    Name of the invoice
  </ResponseField>

  <ResponseField name="businessDetails" type="object" required>
    Business Details
  </ResponseField>

  <ResponseField name="invoiceNumber" type="number" required default="19">
    Invoice Number
  </ResponseField>

  <ResponseField name="currency" type="string" required default="USD">
    Currency
  </ResponseField>

  <ResponseField name="contactDetails" type="object" required>
    Contact Details
  </ResponseField>

  <ResponseField name="issueDate" type="string" required default="2023-01-01">
    Issue date in YYYY-MM-DD format
  </ResponseField>

  <ResponseField name="dueDate" type="string" required default="2023-01-01">
    Due date in YYYY-MM-DD format
  </ResponseField>

  <ResponseField name="discount" type="object">
    Discount
  </ResponseField>

  <ResponseField name="invoiceItems" type="string[]" required>
    Invoice Items
  </ResponseField>

  <ResponseField name="total" type="number" required default="999">
    Total Amount
  </ResponseField>

  <ResponseField name="title" type="string" required default="INVOICE">
    Title
  </ResponseField>

  <ResponseField name="amountDue" type="number" required default="999">
    Total Amount Due
  </ResponseField>

  <ResponseField name="createdAt" type="string" required default="2023-12-12T09:27:42.355Z">
    created at
  </ResponseField>

  <ResponseField name="updatedAt" type="string" required default="2023-12-12T09:27:42.355Z">
    updated at
  </ResponseField>

  <ResponseField name="automaticTaxesEnabled" type="boolean" default="True">
    Automatic taxes enabled for the Invoice
  </ResponseField>

  <ResponseField name="automaticTaxesCalculated" type="boolean" default="True">
    Is Automatic taxes calculated for the Invoice items
  </ResponseField>

  <ResponseField name="paymentSchedule" type="object">
    split invoice into payment schedule summing up to full invoice amount
  </ResponseField>

  ```json theme={null}
  {
    "_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
    },
    "invoiceItems": [
    // truncado: 20 lineas mas
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://services.leadconnectorhq.com/invoices/' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "altId": "6578278e879ad2646715ba9c",
    "altType": "account",
    "name": "New Invoice",
    "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"
      ]
    },
    "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
      }
    ],
    "discount": {
      "value": 10,
      "type": "percentage",
      "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"
    },
    "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
      }
    ]
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/invoices/', {
    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", "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"]}, "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}], "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "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}]}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'POST',
      'https://services.leadconnectorhq.com/invoices/',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"altId": "6578278e879ad2646715ba9c", "altType": "account", "name": "New Invoice", "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"]}, "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}], "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "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}]},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/invoices/');
  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', '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']}, '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}], 'discount': {'value': 10, 'type': 'percentage', 'validOnProductIds': '[ '6579751d56f60276e5bd4154' ]'}, '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}]}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
