> ## 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.

# Update invoice

> API to update invoice by invoice id

API to update invoice by invoice id

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

## 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>

## Path parameters

<ParamField path="invoiceId" type="string" required default="6578278e879ad2646715ba9c">
  Invoice Id
</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">
  Name to be updated
</ParamField>

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

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

<ParamField body="description" type="string" default="ABC Corp payments">
  Description
</ParamField>

<ParamField body="businessDetails" type="object">
  Business details which need to be updated
</ParamField>

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

<ParamField body="contactId" type="string" default="6578278e879ad2646715ba9c">
  Id of the contact which you need to send the invoice
</ParamField>

<ParamField body="contactDetails" type="object">
  <Expandable title="propiedades">
    <ParamField body="id" type="string" required default="6578278e879ad2646715ba9c">
      Contact ID
    </ParamField>

    <ParamField body="name" type="string" required default="Alex">
      Contact Name
    </ParamField>

    <ParamField body="phoneNo" type="string" required default="+1234567890">
      Contact Phone Number
    </ParamField>

    <ParamField body="email" type="string" required default="alex@example.com">
      Contact Email
    </ParamField>

    <ParamField body="additionalEmails" type="object[]">
      Secondary email addresses for the contact to be saved

      <Expandable title="cada item">
        <ParamField body="email" type="string" required default="alex@example.com" />
      </Expandable>
    </ParamField>

    <ParamField body="companyName" type="string" default="ABC Corp.">
      Contact Company Name
    </ParamField>

    <ParamField body="address" type="object">
      <Expandable title="propiedades">
        <ParamField body="addressLine1" type="string" default="9931 Beechwood">
          Address Line 1
        </ParamField>

        <ParamField body="addressLine2" type="string" default="Beechwood">
          Address Line 2
        </ParamField>

        <ParamField body="city" type="string" default="St. Houston">
          City
        </ParamField>

        <ParamField body="state" type="string" default="TX">
          State
        </ParamField>

        <ParamField body="countryCode" type="string" default="US">
          Country Code
        </ParamField>

        <ParamField body="postalCode" type="string" default="559-6993">
          Postal Code
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField body="customFields" type="string[]">
      Custom Values
    </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="discount" type="object">
  <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="invoiceItems" type="object[]" required>
  <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="automaticTaxesEnabled" type="boolean" default="True">
  Automatic taxes enabled for the Invoice
</ParamField>

<ParamField body="liveMode" type="boolean">
  Payment mode
</ParamField>

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

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

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

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

<ParamField body="xeroDetails" type="object" />

<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 PUT 'https://services.leadconnectorhq.com/invoices/YOUR_invoiceId' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "altId": "6578278e879ad2646715ba9c",
    "altType": "account",
    "name": "New Invoice",
    "title": "INVOICE",
    "currency": "USD",
    "description": "ABC Corp payments",
    "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": "1001",
    "contactId": "6578278e879ad2646715ba9c",
    "contactDetails": {
      "id": "6578278e879ad2646715ba9c",
      "name": "Alex",
      "phoneNo": "+1234567890",
      "email": "alex@example.com",
      "additionalEmails": [
        {
          "email": "alex@example.com"
        }
      ],
      "companyName": "ABC Corp.",
      "address": {
        "addressLine1": "9931 Beechwood",
        "addressLine2": "Beechwood",
        "city": "St. Houston",
        "state": "TX",
        "countryCode": "US",
        "postalCode": "559-6993"
      },
      "customFields": [
        "string"
      ]
    },
    "termsNotes": "<p>This is a default terms.</p>",
    "discount": {
      "value": 10,
      "type": "percentage",
      "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"
    },
    "invoiceItems": [
      {
        "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
      }
    ],
    "automaticTaxesEnabled": true,
    "liveMode": true,
    "issueDate": "2023-01-01",
    "dueDate": "2023-01-14",
    "xeroDetails": {},
    "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/YOUR_invoiceId', {
    method: 'PUT',
    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", "title": "INVOICE", "currency": "USD", "description": "ABC Corp payments", "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": "1001", "contactId": "6578278e879ad2646715ba9c", "contactDetails": {"id": "6578278e879ad2646715ba9c", "name": "Alex", "phoneNo": "+1234567890", "email": "alex@example.com", "additionalEmails": [{"email": "alex@example.com"}], "companyName": "ABC Corp.", "address": {"addressLine1": "9931 Beechwood", "addressLine2": "Beechwood", "city": "St. Houston", "state": "TX", "countryCode": "US", "postalCode": "559-6993"}, "customFields": ["string"]}, "termsNotes": "<p>This is a default terms.</p>", "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "invoiceItems": [{"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}], "automaticTaxesEnabled": true, "liveMode": true, "issueDate": "2023-01-01", "dueDate": "2023-01-14", "xeroDetails": {}, "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(
      'PUT',
      'https://services.leadconnectorhq.com/invoices/YOUR_invoiceId',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"altId": "6578278e879ad2646715ba9c", "altType": "account", "name": "New Invoice", "title": "INVOICE", "currency": "USD", "description": "ABC Corp payments", "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": "1001", "contactId": "6578278e879ad2646715ba9c", "contactDetails": {"id": "6578278e879ad2646715ba9c", "name": "Alex", "phoneNo": "+1234567890", "email": "alex@example.com", "additionalEmails": [{"email": "alex@example.com"}], "companyName": "ABC Corp.", "address": {"addressLine1": "9931 Beechwood", "addressLine2": "Beechwood", "city": "St. Houston", "state": "TX", "countryCode": "US", "postalCode": "559-6993"}, "customFields": ["string"]}, "termsNotes": "<p>This is a default terms.</p>", "discount": {"value": 10, "type": "percentage", "validOnProductIds": "[ '6579751d56f60276e5bd4154' ]"}, "invoiceItems": [{"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}], "automaticTaxesEnabled": true, "liveMode": true, "issueDate": "2023-01-01", "dueDate": "2023-01-14", "xeroDetails": {}, "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/YOUR_invoiceId');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'PUT',
      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', 'title': 'INVOICE', 'currency': 'USD', 'description': 'ABC Corp payments', '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': '1001', 'contactId': '6578278e879ad2646715ba9c', 'contactDetails': {'id': '6578278e879ad2646715ba9c', 'name': 'Alex', 'phoneNo': '+1234567890', 'email': 'alex@example.com', 'additionalEmails': [{'email': 'alex@example.com'}], 'companyName': 'ABC Corp.', 'address': {'addressLine1': '9931 Beechwood', 'addressLine2': 'Beechwood', 'city': 'St. Houston', 'state': 'TX', 'countryCode': 'US', 'postalCode': '559-6993'}, 'customFields': ['string']}, 'termsNotes': '<p>This is a default terms.</p>', 'discount': {'value': 10, 'type': 'percentage', 'validOnProductIds': '[ '6579751d56f60276e5bd4154' ]'}, 'invoiceItems': [{'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}], 'automaticTaxesEnabled': true, 'liveMode': true, 'issueDate': '2023-01-01', 'dueDate': '2023-01-14', 'xeroDetails': {}, '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>
