Trigger invoice email sending via API

I’m trying to trigger the sending of an invoice via API.
According to the swagger API docs I tried this GET request:

/api/v1/invoices//email/

but was responded with: “You are not authorized to view or perform this action”
Doing the same via web UI works and looking at the API used by the web UI doesn’t seem to call the same GET request but instead a POST request to /api/v1/emails

so I’m not sure how it’s supposed to work.

Hi,

I believe you need to add the invoice id between invoices/ and /email, ie. invoices/111/email

ah sorry I didn’t notice the forum filtered my url.
This is what I wrote.
/api/v1/invoices/<invoiceid>/email/

so yeah, I had the invoice ID in there.
Just tried the POST api and that one worked, but that requires the information for the email text and I don’t want to hardcode that into my API script.

The other option would be to get the text being sent in the POST request via API. The question would then be how do I get the Information for the email body and subject via API?

You can also use the /invoices/bulk route to email invoices.

You need to pass an array of ids and the action set to email.

Thanks! That did the trick.

body of the POST req needs to look like this

{
  "action": "email",
  "ids": [
    "GELe31Mb69",
    "yJrb2kKdWL"
  ]
}

Heya

is this still working?
When I use the following:

curl -kX POST 'https://ninjatest.xxx.yyy/api/v1/invoices/bulk' \
-H "X-API-TOKEN: OT2734saPyATPuFn3Odi2hzZUhxK<<key>>Mq3DboNRZxfBJaA7z9Sd3uC" \
-H "Content-Type: application/json" \
-H "X-Requested-With: XMLHttpRequest" \
-d '{"action":"email","ids":["wMvbmYAbYA", "VolejRRejN", "4open5Rd7A", "WJxbo2jagw", "k8mepY2aMy", "l4zbqx2apr", "4w9aADOevM", "Volej0zbjN", "WpmbkrYazJ"]}'

all I get is an array of all invoices?
Nothing gets send?

I also tried using

curl -kX 'GET' \
  'https://ninjatest.xxx.yyy/api/v1/invoices/Opnel2JbKB/email' \
  -H 'accept: application/json' \
  -H 'X-Api-Token: OT2734saPyATPuFn3Odi2hzZUhxK<<key>>Mq3DboNRZxfBJaA7z9Sd3uC" \' \
  -H 'X-Requested-With: XMLHttpRequest'

and the return is {"message":"email sent"}, but postmark does not show any attempts of delivery. lavarel.logs are also empty?

Has anything changed in the meantime?
Using v5.5.22-C93

Hi,

Are you able to send emails using the app?

1 Like

my bad… the company was not activated, therefore no emails are send
both api routes are working. thanks!