Create invoice
POST https://api.ecurring.com/invoices
Create an invoice for a subscription.
Any new invoice that is created will start out in the draft
state. When in draft, invoices can be edited or deleted and Invoice Lines can be added.
Once the invoice is finalised, which can be done manually through the Finalise Invoice endpoint, or after the set invoice_date
has been reached, edits are no longer allowed.
The invoice will automatically be sent to your customer, if he subscription plan for the product has this feature enabled.
Request attributes
subscription_id
integer |
The identifier of the subscription. The identifer can be retrieved through the Get subscriptions endpoint. |
invoice_date
datetime |
Optional - The date of the invoice. This date must always be on or before today, and the transaction_date . The invoice will automatically be finalised on this date.
If left empty, the invoice will not automatically be finalised and if a transaction_date is provided, the invoice_date will automatically be set to the value of the transaction_date .
In ISO 8601 format. |
transaction_date
datetime |
Optional - The date of the transaction. Once the invoice is finalised, the transaction for this invoice will be scheduled on this date.
This date must always be on or after the invoice_date .
If left empty, and a invoice_date is provided, this value will automatically be set to the value of the invoice_date .
In ISO 8601 format. |
original_invoice_id
integer |
Optional - The identifier of the original invoice. The identifier can be retrieved through the Get invoices endpoint. |
send_email
boolean |
Optional - Determines whether the invoice should be sent to customer upon finalising. Defaults to `send_invoice` value of the connected subscription plan. |
Examples
Creating an invoice
This will create a draft invoice for the given subscription. Since no invoice_date
or transaction_date
is provided, the invoice will not automatically be finalised.
Finalising the invoice can be done manually through the Finalise invoice endpoint, or by Updating the invoice and supplying an invoice_date
.
Request
POST /invoices HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "invoice",
"attributes": {
"subscription_id": "739578262"
}
}
}
Response
{
"links": {
"self": "https://api.ecurring.test/invoices/795664806"
},
"data": {
"type": "invoice",
"id": "795664806",
"links": {
"self": "https://api.ecurring.test/invoices/795664806"
},
"attributes": {
"status": "draft",
"reference": "DRAFT",
"amount_excl": "0.00",
"amount_incl": "0.00",
"tax_amount": "0.00",
"invoice_date": null,
"transaction_date": null,
"hosted_invoice_url": "https://billing.ecurring.com/invoice/323a241a61ab4339c416fadf8f816e57?lang=nl",
"send_email": true,
"created_at": "2019-10-01T15:57:59+02:00",
"updated_at": "2019-10-01T15:57:59+02:00"
},
"relationships": {
"subscription": {
"links": {
"related": "https://api.ecurring.test/invoices/795664806/subscription"
},
"data": {
"type": "subscription",
"id": "739578262"
}
},
"customer": {
"links": {
"related": "https://api.ecurring.test/invoices/795664806/customer"
},
"data": {
"type": "customer",
"id": "1541610705"
}
},
"invoice-lines": {
"links": {
"related": "https://api.ecurring.test/invoices/795664806/lines"
},
"data": []
},
"transaction": {
"data": null
},
"original-invoice": {
"data": null
}
}
}
}
Creating an invoice with invoice date
This will create a draft invoice for the given subscription that will automatically be finalised on the invoice_date
.
Finalising the invoice can still be done manually (before the invoice_date
) through the Finalise invoice endpoint.
Note that, since no transaction_date
was provided, the transaction_date
will automatically be set to the same value as the invoice_date
.
Request
POST /invoices HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "invoice",
"attributes": {
"subscription_id": "739578262",
"invoice_date": "2019-11-01T00:00:00+00:00"
}
}
}
Response
{
"links": {
"self": "https://api.ecurring.test/invoices/795664806"
},
"data": {
"type": "invoice",
"id": "795664806",
"links": {
"self": "https://api.ecurring.test/invoices/795664806"
},
"attributes": {
"status": "draft",
"reference": "DRAFT",
"amount_excl": "0.00",
"amount_incl": "0.00",
"tax_amount": "0.00",
"invoice_date": "2019-11-01T00:00:00+00:00",
"transaction_date": "2019-11-01T00:00:00+00:00",
"hosted_invoice_url": "https://billing.ecurring.com/invoice/323a241a61ab4339c416fadf8f816e57?lang=nl",
"created_at": "2019-10-01T15:57:59+02:00",
"updated_at": "2019-10-01T15:57:59+02:00"
},
"relationships": {
"subscription": {
"links": {
"related": "https://api.ecurring.test/invoices/795664806/subscription"
},
"data": {
"type": "subscription",
"id": "739578262"
}
},
"customer": {
"links": {
"related": "https://api.ecurring.test/invoices/795664806/customer"
},
"data": {
"type": "customer",
"id": "1541610705"
}
},
"invoice-lines": {
"links": {
"related": "https://api.ecurring.test/invoices/795664806/lines"
},
"data": []
},
"transaction": {
"data": null
},
"original-invoice": {
"data": null
}
}
}
}
Creating a credit invoice
This will create a draft invoice for the given subscription with a relation to the original invoice; the debit invoice.
Note that, since all the amounts
are still 0.00, the result of this request is not a credit invoice yet.
You'll have to add an invoice line or two with a cumulative amount
of less than 0.00 for this to be a credit invoice.
Request
POST /invoices HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json
{
"data": {
"type": "invoice",
"attributes": {
"subscription_id": "739578262",
"original_invoice_id": "1301330771"
}
}
}
Response
{
"links": {
"self": "https://api.ecurring.test/invoices/575886752"
},
"data": {
"type": "invoice",
"id": "575886752",
"links": {
"self": "https://api.ecurring.test/invoices/575886752"
},
"attributes": {
"status": "draft",
"reference": "DRAFT",
"amount_excl": "0.00",
"amount_incl": "0.00",
"tax_rates": [],
"tax_amount": "0.00",
"invoice_date": null,
"transaction_date": null,
"created_at": "2020-04-21T01:40:08+02:00",
"updated_at": "2020-04-21T01:40:08+02:00"
},
"relationships": {
"subscription": {
"links": {
"related": "https://api.ecurring.test/invoices/575886752/subscription"
},
"data": {
"type": "subscription",
"id": "739578262"
}
},
"customer": {
"links": {
"related": "https://api.ecurring.test/invoices/575886752/customer"
},
"data": {
"type": "customer",
"id": "1654862695"
}
},
"invoice-lines": {
"links": {
"related": "https://api.ecurring.test/invoices/575886752/lines"
},
"data": []
},
"transaction": {
"data": null
},
"original-invoice": {
"data": {
"type": "invoice",
"id": "1301330771"
}
}
}
}
}