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.

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,
            "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
            }
        }
    }
}

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",
            "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
            }
        }
    }
}