---
updatedAt: 2026-04-08T00:12:31.000Z
agentTools:
  projectIndex: https://docs.pelcro.com/v2.4/llms.txt
---

# Create invoice

Create a new invoice.

## Overview

Create a new invoice for a customer. Invoices can be created manually for one-time charges or custom billing scenarios outside of the normal subscription cycle.

**Example:** Create a manual invoice for a customer who requested additional services not covered by their subscription.

***

## Conditional Requirements

| Condition                                                         | Required Fields                                            |
| ----------------------------------------------------------------- | ---------------------------------------------------------- |
| Always                                                            | `customer_id` OR `customer_old_provider_id` (at least one) |
| Always                                                            | `currency`                                                 |
| No `line_items` provided                                          | `total`                                                    |
| `line_items` provided                                             | `line_items.*.unit_price`, `line_items.*.quantity`         |
| `line_items.*.tax_name` is set                                    | `line_items.*.tax_rate`                                    |
| `line_items.*.tax_rate` is set                                    | `line_items.*.tax_name`                                    |
| Both `customer_id` AND `customer_old_provider_id` are set         | Must reference the same customer                           |
| Both `subscription_id` AND `subscription_old_provider_id` are set | Must reference the same subscription                       |

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "core-api",
    "version": "1.88"
  },
  "servers": [
    {
      "url": "https://www.pelcro.com/api/v1/core"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "in": "header",
        "name": "Authorization",
        "x-bearer-format": "bearer"
      },
      "sec1": {
        "type": "apiKey",
        "in": "query",
        "name": "site_id"
      }
    }
  },
  "security": [
    {
      "sec0": [],
      "sec1": []
    }
  ],
  "paths": {
    "/invoices": {
      "post": {
        "summary": "Create invoice",
        "description": "Create a new invoice.",
        "operationId": "create-invoice",
        "parameters": [
          {
            "name": "site_id",
            "in": "query",
            "description": "The unique identifier of the site associated with your account.",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "default": "Bearer eyJ***"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "currency",
                  "line_items"
                ],
                "properties": {
                  "currency": {
                    "type": "string",
                    "description": "The currency code. Must be valid for the account and customer and is."
                  },
                  "line_items": {
                    "type": "array",
                    "description": "Encapsulates details about a good or service being invoiced, including its description, price, quantity, and optional tax information.<br /><br />Required if `total` is not provided.",
                    "items": {
                      "properties": {
                        "description": {
                          "type": "string",
                          "description": "Line item description attribute provides a brief explanation of the good or service being invoiced."
                        },
                        "unit_price": {
                          "type": "integer",
                          "description": "Line item unit price attribute specifies the price per unit for the good or service being invoiced.",
                          "format": "int32"
                        },
                        "quantity": {
                          "type": "integer",
                          "description": "Line item quantity attribute specifies the number of units of the good or service being invoiced.",
                          "format": "int32"
                        },
                        "tax_name": {
                          "type": "string",
                          "description": "The line item tax name attribute (if present) specifies the human-readable name of the tax applied to that line item."
                        },
                        "tax_rate": {
                          "type": "number",
                          "description": "Line item tax rate attribute defines the percentage (or rate) of tax applied to that specific line item.  pen_spark     tune  share   more_vert",
                          "format": "double"
                        }
                      },
                      "required": [
                        "unit_price",
                        "quantity"
                      ],
                      "type": "object"
                    }
                  },
                  "total": {
                    "type": "integer",
                    "description": "The total amount of the invoice in minor units e.g. cents.<br /><br />Required if `line_items` are not provided.",
                    "format": "int32"
                  },
                  "customer_id": {
                    "type": "integer",
                    "description": "The unique identifier of the customer.<br /><br />Required if `customer_old_provider_id` is not provided.",
                    "format": "int32"
                  },
                  "customer_old_provider_id": {
                    "type": "string",
                    "description": "The unique identifier which was add to the customer who owns this invoice.<br /><br />If provided, `customer_id` can be omitted."
                  },
                  "period_start": {
                    "type": "string",
                    "description": "Represents the start of the line item's billing period. Measured in seconds since the Unix epoch.<br /><br />If provided, must be a timestamp before or equal to `period_end`.",
                    "format": "date-time"
                  },
                  "period_end": {
                    "type": "string",
                    "description": "Represents the end of the line item's billing period. Measured in seconds since the Unix epoch. Represents the start of the line item's billing period. Measured in seconds since the Unix epoch.<br /><br />If provided, must be a timestamp after or equal to `period_start`.",
                    "format": "date-time"
                  },
                  "due_date": {
                    "type": "string",
                    "description": "Represents the date at which the invoice will be due.<br /><br />If provided, must be a timestamp after or equal to `period_start`.",
                    "format": "date-time"
                  },
                  "status": {
                    "type": "string",
                    "description": "The status of the invoice, one of: `draft`, `open`, `paid`,  `uncollectible`, or `void`",
                    "enum": [
                      "draft",
                      "open",
                      "paid",
                      "uncollectible",
                      "void"
                    ]
                  },
                  "billing_reason": {
                    "type": "string",
                    "description": "Indicates the reason why the invoice was created.<br /><br />`manual`:  For an invoice unrelated to a subscription or e-commerce order.<br />`subscription_create`: For a newly created subscription.<br />`subscription_cycle`: For a subscription which advanced into a new period.<br />`subscription_update`: For a subscription which was updated.<br />`order_create`: For an e-commerce order.",
                    "enum": [
                      "subscription_create",
                      "subscription_cycle",
                      "subscription_update",
                      "order_create",
                      "manual"
                    ]
                  },
                  "subscription_id": {
                    "type": "integer",
                    "description": "The unique identifier of the subscription to assign to this invoice.<br /><br />Can be omitted if `subscription_old_provider_id` is provided.",
                    "format": "int32"
                  },
                  "subscription_old_provider_id": {
                    "type": "string",
                    "description": "The unique identifier of a previously created subscription for which `old_provider_id` was specified.<br /><br />Can be omitted if `subscription_id` is provided."
                  },
                  "customer_address": {
                    "type": "object",
                    "description": "An address object representing the customer's billing address, which will be saved under this invoice. If omitted, the default behavior will be to use the customer's current default billing address.<br /><br />Can be omitted if `billing_address_id` is provided.",
                    "required": [
                      "line1",
                      "country"
                    ],
                    "properties": {
                      "line1": {
                        "type": "string",
                        "description": "The first line of the address, typically containing the street number and street name. Always required."
                      },
                      "country": {
                        "type": "string",
                        "description": "The two-letter country codes as specified by ISO3166 alpha-2. Learn more [here](https://www.iban.com/country-codes). Always required."
                      },
                      "line2": {
                        "type": "string",
                        "description": "The second line of the address, which can be used for apartment number, suite number, etc."
                      },
                      "city": {
                        "type": "string",
                        "description": "The name of a city, town, village, etc."
                      },
                      "state": {
                        "type": "string",
                        "description": "The two-letter code of the state, region, or province. Learn more [here](https://www.ncbi.nlm.nih.gov/books/NBK7254/)."
                      },
                      "postal_code": {
                        "type": "string",
                        "description": "Postal code or zip associated with the address."
                      }
                    }
                  },
                  "billing_address_id": {
                    "type": "integer",
                    "description": "Specifies the associated billing address for a customer or invoice.<br /><br />Can be omitted if `customer_address`is provided.",
                    "format": "int32"
                  },
                  "customer_shipping": {
                    "type": "object",
                    "description": "An address object representing the customer's shipping address, which will be saved under this invoice.<br /><br />Can be omitted if `shipping_address_id` is provided.",
                    "properties": {
                      "address": {
                        "type": "object",
                        "description": "The object representing the shipping address.",
                        "required": [
                          "line1",
                          "country"
                        ],
                        "properties": {
                          "line1": {
                            "type": "string",
                            "description": "The first line of the address, typically containing the street number and street name. Always required."
                          },
                          "country": {
                            "type": "string",
                            "description": "The two-letter country codes as specified by ISO3166 alpha-2. Learn more [here](https://www.iban.com/country-codes). Always required."
                          },
                          "line2": {
                            "type": "string",
                            "description": "The second line of the address, which can be used for apartment number, suite number, etc."
                          },
                          "city": {
                            "type": "string",
                            "description": "The name of a city, town, village, etc."
                          },
                          "state": {
                            "type": "string",
                            "description": "The two-letter code of the state, region, or province. Learn more [here](https://www.ncbi.nlm.nih.gov/books/NBK7254/)."
                          },
                          "postal_code": {
                            "type": "string",
                            "description": "Postal code or zip associated with the address."
                          }
                        }
                      },
                      "name": {
                        "type": "string",
                        "description": "The full name of the customer associated with the shipping address."
                      },
                      "phone": {
                        "type": "string",
                        "description": "The phone number associated with the shipping address."
                      }
                    }
                  },
                  "shipping_address_id": {
                    "type": "integer",
                    "description": "Specifies the associated shipping address for a customer or invoice.<br /><br />Can be omitted if `customer_shipping` is provided.",
                    "format": "int32"
                  },
                  "is_imported": {
                    "type": "boolean",
                    "description": "A flag determining whether this invoice was imported.",
                    "default": false
                  },
                  "metadata": {
                    "type": "object",
                    "properties": {
                      "metadata_key": {
                        "type": "string"
                      }
                    }
                  },
                  "footer": {
                    "type": "string",
                    "description": "An attribute that allows for adding custom text at the bottom of invoices"
                  },
                  "total_imported_shipments": {
                    "type": "integer",
                    "description": "If this field is populated, the revenue recognition calculation will use its value instead of the plan_shipments_per_interval value from the plan. This allows for custom shipment-based recognition logic on a per-subscription basis",
                    "format": "int32"
                  },
                  "purchase_order": {
                    "type": "string",
                    "description": "Specifies the purchase order value of the invoice"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n\t\"data\": {\n\t\t\"id\": 3000,\n\t\t\"amount_due\": 50,\n\t\t\"amount_paid\": 0,\n\t\t\"amount_remaining\": 50,\n\t\t\"auto_advance\": null,\n\t\t\"billing\": \"send_invoice\",\n\t\t\"billing_reason\": \"manual\",\n\t\t\"currency\": \"cad\",\n\t\t\"due_date\": null,\n\t\t\"user_id\": 417,\n\t\t\"charge_id\": null,\n\t\t\"subscription_id\": 396,\n\t\t\"plan_name\": null,\n\t\t\"product_name\": null,\n\t\t\"ending_balance\": null,\n\t\t\"hosted_invoice_url\": null,\n\t\t\"invoice_pdf\": \"https:\\/\\/pelcro-khairy.eu.ngrok.io\\/pdf\\/invoice\\/eyJpdiI6ImFkVnJ2RUExSWYrOCt6VTJmeXk1bkE9PSIsInZhbHVlIjoia0NQWTU2VStkZ3Q4ZmRPTmF3RnRpSFYyOFNHWTFnNjdIUW9NZVdvd0dCbz0iLCJtYWMiOiI5YmRhMzU0YWUxZjU1NjA4MTQ0MDY1NjkwNjI4YzFlNmRkYjc1YTk0MGVlYzBiYWMyY2QzYzI1ZjhhMGIzYTRkIiwidGFnIjoiIn0=\",\n\t\t\"is_imported\": null,\n\t\t\"number\": null,\n\t\t\"paid\": null,\n\t\t\"period_start\": 1660443270,\n\t\t\"period_end\": 1660442466,\n\t\t\"post_payment_credit_notes_amount\": null,\n\t\t\"pre_payment_credit_notes_amount\": null,\n\t\t\"starting_balance\": 0,\n\t\t\"status\": \"open\",\n\t\t\"subtotal\": 50,\n\t\t\"tax\": null,\n\t\t\"total\": 50,\n\t\t\"finalized_at\": null,\n\t\t\"marked_uncollectible_at\": null,\n\t\t\"paid_at\": null,\n\t\t\"voided_at\": null,\n\t\t\"created_at\": 1660442466,\n\t\t\"updated_at\": 1660442466,\n\t\t\"deleted_at\": null\n\t},\n\t\"status\": \"success\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "integer",
                          "example": 3000,
                          "default": 0
                        },
                        "amount_due": {
                          "type": "integer",
                          "example": 50,
                          "default": 0
                        },
                        "amount_paid": {
                          "type": "integer",
                          "example": 0,
                          "default": 0
                        },
                        "amount_remaining": {
                          "type": "integer",
                          "example": 50,
                          "default": 0
                        },
                        "auto_advance": {},
                        "billing": {
                          "type": "string",
                          "example": "send_invoice"
                        },
                        "billing_reason": {
                          "type": "string",
                          "example": "manual"
                        },
                        "currency": {
                          "type": "string",
                          "example": "cad"
                        },
                        "due_date": {},
                        "user_id": {
                          "type": "integer",
                          "example": 417,
                          "default": 0
                        },
                        "charge_id": {},
                        "subscription_id": {
                          "type": "integer",
                          "example": 396,
                          "default": 0
                        },
                        "plan_name": {},
                        "product_name": {},
                        "ending_balance": {},
                        "hosted_invoice_url": {},
                        "invoice_pdf": {
                          "type": "string",
                          "example": "https://pelcro-khairy.eu.ngrok.io/pdf/invoice/eyJpdiI6ImFkVnJ2RUExSWYrOCt6VTJmeXk1bkE9PSIsInZhbHVlIjoia0NQWTU2VStkZ3Q4ZmRPTmF3RnRpSFYyOFNHWTFnNjdIUW9NZVdvd0dCbz0iLCJtYWMiOiI5YmRhMzU0YWUxZjU1NjA4MTQ0MDY1NjkwNjI4YzFlNmRkYjc1YTk0MGVlYzBiYWMyY2QzYzI1ZjhhMGIzYTRkIiwidGFnIjoiIn0="
                        },
                        "is_imported": {},
                        "number": {},
                        "paid": {},
                        "period_start": {
                          "type": "integer",
                          "example": 1660443270,
                          "default": 0
                        },
                        "period_end": {
                          "type": "integer",
                          "example": 1660442466,
                          "default": 0
                        },
                        "post_payment_credit_notes_amount": {},
                        "pre_payment_credit_notes_amount": {},
                        "starting_balance": {
                          "type": "integer",
                          "example": 0,
                          "default": 0
                        },
                        "status": {
                          "type": "string",
                          "example": "open"
                        },
                        "subtotal": {
                          "type": "integer",
                          "example": 50,
                          "default": 0
                        },
                        "tax": {},
                        "total": {
                          "type": "integer",
                          "example": 50,
                          "default": 0
                        },
                        "finalized_at": {},
                        "marked_uncollectible_at": {},
                        "paid_at": {},
                        "voided_at": {},
                        "created_at": {
                          "type": "integer",
                          "example": 1660442466,
                          "default": 0,
                          "format": "int64"
                        },
                        "updated_at": {
                          "type": "integer",
                          "example": 1660442466,
                          "default": 0,
                          "format": "int64"
                        },
                        "deleted_at": {}
                      }
                    },
                    "status": {
                      "type": "string",
                      "example": "success"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request.",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"errors\": {\n        \"customer_id\": [\n            \"The customer id field is required.\"\n        ],\n        \"total\": [\n            \"The total field is required.\"\n        ],\n        \"currency\": [\n            \"The currency field is required.\"\n        ]\n    }\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object",
                      "properties": {
                        "customer_id": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "example": "The customer id field is required."
                          }
                        },
                        "total": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "example": "The total field is required."
                          }
                        },
                        "currency": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "example": "The currency field is required."
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated.",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": {
                      "error": "Unauthenticated."
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Server error.",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false,
        "x-readme": {
          "code-samples": [
            {
              "language": "php",
              "code": "use GuzzleHttp\\Client;\n\n$site_id = 0; // (int) your site id here\n$customer_id = 0; // (int) the customer id here\n$total = 0; // (int) the total amount here\n$currency = 0; // (string) the currency code here\n$metadata = []; // (array) the metadata here\n$api_key = '' // (string) your api key here\n  \n$uri = \"invoices\";\n\n$config = [\n  'base_uri' => 'https://www.pelcro.com/api/v1/core/'\n];\n\n$client = new Client($config);\n\n$options = [\n\t'json' => [\n\t\t'site_id' => $site_id,\n    'customer_id' => $customer_id,\n    'total' => $total,\n    'currency' => $currency,\n    'metadata' => $metadata,\n\t],\n\t'headers' => [\n\t\t'Accept' => 'application/json',\n\t\t'Authorization' => 'Bearer ' . $api_key\n\t]\n];\n\n$response = $client->request('POST', $uri, $options);"
            }
          ],
          "samples-languages": [
            "php"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true
}
```

# Sibling pages

* [List invoices](https://docs.pelcro.com/v2.4/reference/api-core-list-invoices.md)
* [Get invoice](https://docs.pelcro.com/v2.4/reference/get-invoice.md)
* [Pay invoice (offline)](https://docs.pelcro.com/v2.4/reference/api-core-pay-invoice.md)
* [Void invoice](https://docs.pelcro.com/v2.4/reference/api-core-void-invoice.md)
* [Update invoice ](https://docs.pelcro.com/v2.4/reference/update-invoice.md)
* [Mark invoice as uncollectible](https://docs.pelcro.com/v2.4/reference/api-core-mark-as-uncollectible-invoices.md)
* [Apply balance to invoice](https://docs.pelcro.com/v2.4/reference/api-core-apply-balance-to-invoice.md)