API fields for creating Quote/Invoice items

Hello,
I am developing an app that communicates with my self hosted InvoiceNinja instance. I am using the API documentation here: LINK.

When creating either a Quote or Invoice, the API states that I should pass line_items to describe the items of the quote/invoice. However, it doesn’t state which fields should be passed. It only displays the description field. In V4, it specified the following fields:

$invoice->invoice_items = [
    [
        'product_key' => 'Sample Product',
        'notes' => 'Sample notes',
        'qty' => 6,
        'cost' => 7000
    ]
]

Does the V5 API support the same fields or are they completely different? Thanks!

Hi,

One difference is in v5 qty was changed to quantity

1 Like

Thanks @hillel, that has worked well. I am now faced with another issue. After creating the Quote, I want to trigger an email action so that it is sent to the Client. I am using something like this (please note I am working locally using Laravel and MailTrap to test my emails):

Http::withHeaders($this->apiHeaders) // $this->apiHeaders contains Api Key
    ->get('http://ninja.test/api/v1/quotes/gl9avmeG1v/email');

When I run this, nothing seems to happen. I went on to test whether any emails get sent by using the command below in the tinker shell:

Mail::raw('Hello World!', function($msg) {
    $msg->to('test@email.com')
        ->subject('Test Email'); 
});

And I am able to see the mail in my MailTrap account. When I trigger the API endpoint, I can also see an entry in the jobs table indicating that it has been placed on the queue. I can also see my docker logs that the job is processing. However, after the job is processed, I am guessing successfully, I don’t see any email and there are no entries in the failed_jobs table.

Could I be doing anything wrong here? Thanks!

Maybe the info here will help:

https://invoiceninja.github.io/docs/self-host-troubleshooting/#email-not-sending

Hi @hillel,
I have read through the documentation and everything checks out. But the email is still not being sent to the Client. When I manually send the email from the InvoiceNinja dashboard, an email notification only goes to the Administrator user who created the email. Not sure what I am missing. Perhaps I should run a few more tests because nothing shows up in any logs.

UPDATE:
The email sends only when I disable the following from the Email Settings page:

Attach PDF
Attach Documents

Something going wrong there. Could be with my installation. WIll check.