Create invoice

Create an invoice using the following parameters


Endpoint


Method URI
POST https://apiv2.keliweb.it/api/v2/keliweb/create-invoice

Request Parameters


Parameter Type Description Required
HTTP headers: Authorization string Bearer + the token to access APIs Required
status string The status of the invoice being created (Defaults to Unpaid) Optional
draft boolean Should the invoice be created in draft status (No need to pass $status also) Optional
taxrate float The first level tax rate to apply to the invoice to override the system default Optional
taxrate2 float The second level tax rate to apply to the invoice to override the system default Optional
date date The date that the invoice should show as created YYYY-mm-dd Optional
duedate date The due date of the newly created invoice YYYY-mm-dd Optional
notes string The notes to appear on the created invoice Optional
itemdescriptionx string The line items description X is an integer to add multiple invoice items Optional
itemamountx float The line items amount Optional
itemtaxedx boolean The line items is taxed value Optional

Response Parameters


Parameter Type Description
result string The result of the operation: success or error
invoiceid integer The ID of the newly created invoice
status string The status of the newly created invoice

Example Request (PHP Curl)

            

                    $curl = curl_init();
                    
                    curl_setopt_array($curl, array(
                      CURLOPT_URL => "https://apiv2.keliweb.it/api/v2/keliweb/create-invoice",
                      CURLOPT_RETURNTRANSFER => true,
                      CURLOPT_ENCODING => "",
                      CURLOPT_MAXREDIRS => 10,
                      CURLOPT_TIMEOUT => 0,
                      CURLOPT_FOLLOWLOCATION => false,
                      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
                      CURLOPT_CUSTOMREQUEST => "POST",
                      CURLOPT_POSTFIELDS =>
                        http_build_query(
                                array(
                                    'status'           => 'Unpaid',
                                    'taxrate'          => '10.00',
                                    'date'             => '2016-01-01',
                                    'duedate'          => '2016-01-08',
                                    'itemdescription1' => 'Sample Invoice Item',
                                    'itemamount1'      => '15.95',
                                    'itemtaxed1'       => '0',
                                    'itemdescription2' => 'Sample Second Invoice Item',
                                    'itemamount2'      => '1.00',
                                    'itemtaxed2'       => '1',
                                )
                            ),
                      CURLOPT_HTTPHEADER => array(
                        "Content-Type: multipart/form-data",
                        "X-Requested-With: XMLHttpRequest",
                        "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NhMmNlNkNjNhMmU2MmUxIzZDRkODY5MS1mMDMzLTQ1MWMtYjU-3EHc",
                      ),
                    ));
                    
                    $response = curl_exec($curl);
                    $err = curl_error($curl);
                    
                    curl_close($curl);
                    
                    if ($err) {
                      echo "cURL Error #:" . $err;
                    } else {
                      echo $response;
                    }

            
        

Example Request (jQuery AJAX)

            
                    var form = new FormData();
                    form.append("status", "Unpaid");
                    form.append("taxrate", "10.00");
                    form.append("date", "2016-01-01");
                    form.append("duedate", "2016-01-08");
                    form.append("itemdescription1", "Sample Invoice Item");
                    form.append("itemamount1", "15.95");
                    form.append("itemtaxed1", "0");
                    form.append("itemdescription2", "Sample Second Invoice Item");
                    form.append("itemamount2", "1.00");
                    form.append("itemtaxed2", "1");

                    var settings = {
                        "async": true,
                        "crossDomain": true,
                        "url": "https://apiv2.keliweb.it/api/v2/keliweb/create-invoice",
                        "method": "POST",
                        "headers": {
                            "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImNjMDEwYWVlYmUzMjMxMmZlZjBiNzRjYTBhMmNlNDc2MjNjNhMMTA1MzJjODk1In0",
                            "cache-control": "no-cache",
                        },
                        "processData": false,
                        "contentType": false,
                        "mimeType": "multipart/form-data",
                        "data": form
                    }

                    $.ajax(settings).done(function (response) {
                        console.log(response);
                    });
            
        

Example Response (JSON payload)

            
                    {
                        "result"   : "success",
                        "invoiceid": "1",
                        "status"   : "Unpaid"
                    }