### List Guides with Go Source: https://invoicexpress.com/api-v2/guides/list-all-2 This Go code snippet shows how to retrieve a list of guides from the InvoiceXpress API v2. It utilizes the net/http package to make a GET request with specified headers and prints the response body. ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/guides.json?text=foo&type%5B%5D=Shipping&status%5B%5D=sent&loaded_at%5Bfrom%5D=30%2F09%2F2017&loaded_at%5Bto%5D=31%2F10%2F2017&non_archived=true&archived=false&page=1&per_page=10&api_key=YOUR%20API%20KEY%20HERE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("accept", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### List Guides with PHP Source: https://invoicexpress.com/api-v2/guides/list-all-2 This PHP code snippet demonstrates how to fetch a list of guides from the InvoiceXpress API v2 using cURL. It includes setting various query parameters for filtering and handling the API response. ```PHP "https://account_name.app.invoicexpress.com/guides.json?text=foo&type%5B%5D=Shipping&status%5B%5D=sent&loaded_at%5Bfrom%5D=30%2F09%2F2017&loaded_at%5Bto%5D=31%2F10%2F2017&non_archived=true&archived=false&page=1&per_page=10&api_key=YOUR%20API%20KEY%20HERE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "accept: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:"; echo $err; } else { echo $response; } ``` -------------------------------- ### List Guides with Filtering (API v2) Source: https://invoicexpress.com/api-v2/guides/list-all-2 Retrieves a list of guides (shippings, transports, devolutions) from the InvoiceXpress API v2. Supports filtering by text, type, status, date range, and pagination. ```curl curl --request GET \ --url 'https://account_name.app.invoicexpress.com/guides.json?text=foo&type%5B%5D=Shipping&status%5B%5D=sent&loaded_at%5Bfrom%5D=30%2F09%2F2017&loaded_at%5Bto%5D=31%2F10%2F2017&non_archived=true&archived=false&page=1&per_page=10&api_key=YOUR%20API%20KEY%20HERE' \ --header 'accept: application/json' ``` ```ruby require 'uri' require 'net/http' url = URI("https://account_name.app.invoicexpress.com/guides.json?text=foo&type%5B%5D=Shipping&status%5B%5D=sent&loaded_at%5Bfrom%5D=30%2F09%2F2017&loaded_at%5Bto%5D=31%2F10%2F2017&non_archived=true&archived=false&page=1&per_page=10&api_key=YOUR%20API%20KEY%20HERE") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["accept"] = 'application/json' response = http.request(request) puts response.read_body ``` ```node var http = require("https"); var options = { "method": "GET", "hostname": "account_name.app.invoicexpress.com", "port": null, "path": "/guides.json?text=foo&type%5B%5D=Shipping&status%5B%5D=sent&loaded_at%5Bfrom%5D=30%2F09%2F2017&loaded_at%5Bto%5D=31%2F10%2F2017&non_archived=true&archived=false&page=1&per_page=10&api_key=YOUR%20API%20KEY%20HERE", "headers": { "accept": "application/json" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` ```python import http.client conn = http.client.HTTPSConnection("account_name.app.invoicexpress.com") headers = { 'accept': "application/json" } conn.request("GET", "/guides.json?text=foo&type%5B%5D=Shipping&status%5B%5D=sent&loaded_at%5Bfrom%5D=30%2F09%2F2017&loaded_at%5Bto%5D=31%2F10%2F2017&non_archived=true&archived=false&page=1&per_page=10&api_key=YOUR%20API%20KEY%20HERE", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` -------------------------------- ### Get QR Code using cURL Source: https://invoicexpress.com/api-v2/invoices/get-qrcode Example request to get the QR Code PNG file URL for a specified document ID using cURL. ```curl curl --request GET \ --url 'https://account_name.app.invoicexpress.com/api/qr_codes/:document-id.json?api_key=YOUR%20API%20KEY%20HERE' \ --header 'accept: application/json' ``` -------------------------------- ### Get QR Code using Node.js Source: https://invoicexpress.com/api-v2/invoices/get-qrcode This Node.js example demonstrates fetching a QR code URL from the InvoiceXpress API v2. It uses the built-in 'https' module to construct and send a GET request, specifying the hostname, path, and headers. ```javascript var http = require("https"); var options = { "method": "GET", "hostname": "account_name.app.invoicexpress.com", "port": null, "path": "/api/qr_codes/:document-id.json?api_key=YOUR%20API%20KEY%20HERE", "headers": { "accept": "application/json" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Create Client using Go Source: https://invoicexpress.com/api-v2/clients/create-4 This Go snippet demonstrates creating a client with the InvoiceXpress API v2. It uses the `net/http` package to construct and send a POST request, including the API key and client data in the payload. ```go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/clients.json?api_key=YOUR%20API%20KEY%20HERE" payload := strings.NewReader("{\"client\":{\"name\":\"Client Name\",\"code\":\"12345\",\"email\":\"foo@bar.com\",\"language\":\"pt\",\"address\":\"Avenida da República, Lisboa\",\"city\":\"Lisboa\",\"postal_code\":\"1050-555\",\"country\":\"Portugal\",\"fiscal_id\":\"508025338\",\"website\":\"www.invoicexpress.com\",\"phone\":\"213456789\",\"fax\":\"213456788\",\"preferred_contact\":{\"name\":\"Bruce Norris\",\"email\":\"email@invoicexpress.com\",\"phone\":\"213456789\"},\"observations\":\"Observations\",\"send_options\":\"1\"}}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("accept", "application/json") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### List All Sequences (Go) Source: https://invoicexpress.com/api-v2/sequences/list-all-6 This Go program shows how to fetch sequences using the http package. It constructs the request, sets the 'accept' header, and prints the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/sequences.json?api_key=YOUR%20API%20KEY%20HERE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("accept", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get QR Code using Node.js Source: https://invoicexpress.com/api-v2/guides/get-qrcode-2 This Node.js example illustrates how to make a GET request to retrieve a QR Code PNG URL. It utilizes the 'https' module to send the request with specified options and headers, then logs the response. ```javascript var http = require("https"); var options = { "method": "GET", "hostname": "account_name.app.invoicexpress.com", "port": null, "path": "/api/qr_codes/:document-id.json?api_key=YOUR%20API%20KEY%20HERE", "headers": { "accept": "application/json" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Create Account with InvoiceXpress API v2 (Go) Source: https://invoicexpress.com/api-v2/accounts/create-8 This Go code snippet demonstrates how to create a new account using the InvoiceXpress API v2. It uses the `net/http` package to send a POST request with account details in JSON format and prints the response. ```Go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/api/accounts/create.json?api_key=YOUR%20API%20KEY%20HERE" payload := strings.NewReader("{\"account\":{\"first_name\":\"First name\",\"last_name\":\"Last name\",\"organization_name\":\"Company name\",\"phone\":\"213456789\",\"email\":\"someone@example.com\",\"password\":\"123456\",\"fiscal_id\":\"504123456\",\"tax_country\":\"1\",\"language\":\"pt\",\"terms\":\"1\",\"marketing\":\"foo\"}}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("accept", "application/json") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Client Balance using InvoiceXpress API V2 Source: https://invoicexpress.com/api-v2/treasury/get-client-balance This snippet demonstrates how to retrieve the balance of a specific client using the InvoiceXpress API V2. It includes examples for making a GET request and handling the JSON response. The required 'client-id' parameter is used in the URL. ```curl curl --request GET \ --url 'https://account_name.app.invoicexpress.com/api/v3/clients/:client-id/balance.json?api_key=YOUR%20API%20KEY%20HERE' \ --header 'accept: application/json' ``` ```Ruby require 'uri' require 'net/http' url = URI("https://account_name.app.invoicexpress.com/api/v3/clients/:client-id/balance.json?api_key=YOUR%20API%20KEY%20HERE") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["accept"] = 'application/json' response = http.request(request) puts response.read_body ``` ```Node.js var http = require("https"); var options = { "method": "GET", "hostname": "account_name.app.invoicexpress.com", "port": null, "path": "/api/v3/clients/:client-id/balance.json?api_key=YOUR%20API%20KEY%20HERE", "headers": { "accept": "application/json" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` ```Python import http.client conn = http.client.HTTPSConnection("account_name.app.invoicexpress.com") headers = { 'accept': "application/json" } conn.request("GET", "/api/v3/clients/:client-id/balance.json?api_key=YOUR%20API%20KEY%20HERE", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```PHP "https://account_name.app.invoicexpress.com/api/v3/clients/:client-id/balance.json?api_key=YOUR%20API%20KEY%20HERE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "accept: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/api/v3/clients/:client-id/balance.json?api_key=YOUR%20API%20KEY%20HERE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("accept", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Specific Document - API V2 Source: https://invoicexpress.com/api-v2/guides/get-2 This snippet demonstrates how to retrieve a specific document (like an invoice, estimate, or guide) from InvoiceXpress V2 using a GET request. It requires the document type and document ID as path parameters, along with an API key for authentication. The response is expected in JSON format. ```curl curl --request GET \ --url 'https://account_name.app.invoicexpress.com/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE' \ --header 'accept: application/json' ``` ```Ruby require 'uri' require 'net/http' url = URI("https://account_name.app.invoicexpress.com/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Get.new(url) request["accept"] = 'application/json' response = http.request(request) puts response.read_body ``` ```Node.js var http = require("https"); var options = { "method": "GET", "hostname": "account_name.app.invoicexpress.com", "port": null, "path": "/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE", "headers": { "accept": "application/json" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` ```Python import http.client conn = http.client.HTTPSConnection("account_name.app.invoicexpress.com") headers = { 'accept': "application/json" } conn.request("GET", "/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```PHP "https://account_name.app.invoicexpress.com/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "accept: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` ```Go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("accept", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Example Request Body for Account Creation Source: https://invoicexpress.com/api-v2/accounts/create-8 This JSON object represents the structure and example values for the request body when creating a new account via the InvoiceXpress API v2. It includes all necessary account details. ```JSON { "account": { "first_name": "First name", "last_name": "Last name", "organization_name": "Company name", "phone": "213456789", "email": "someone@example.com", "password": "123456", "fiscal_id": "504123456", "tax_country": "1", "language": "pt", "terms": "1", "marketing": "0" } } ``` -------------------------------- ### Retrieve Specific Document via API (PHP) Source: https://invoicexpress.com/api-v2/estimates/get-1 This PHP code example demonstrates how to get a specific document using the InvoiceXpress API V2. It utilizes cURL to send a GET request, setting various options for the request, including the URL, headers, and timeout, and then outputs the response or any cURL errors. ```php "https://account_name.app.invoicexpress.com/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( "accept: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` -------------------------------- ### Create InvoiceXpress Account (Go) Source: https://invoicexpress.com/api-v2/accounts/create-for-existing-user Go code for creating an account in InvoiceXpress API v2 for an existing user. It uses the `net/http` package to perform a POST request with the necessary account details and API key. ```Go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/api/accounts/create_already_user.json?api_key=YOUR%20API%20KEY%20HERE" payload := strings.NewReader("{\"account\":{\"first_name\":\"First name\",\"last_name\":\"Last name\",\"organization_name\":\"Company name\",\"phone\":\"213456789\",\"email\":\"someone@example.com\",\"password\":\"123456\",\"fiscal_id\":\"504123456\",\"tax_country\":\"1\",\"language\":\"pt\",\"terms\":\"1\",\"marketing\":\"foo\"}}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("accept", "application/json") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Invoice Example Response Body Source: https://invoicexpress.com/api-v2/sequences/get This JSON structure represents a successful response when retrieving an invoice from the InvoiceXpress API. It includes details such as invoice ID, status, dates, client information, and line items. ```json { "invoice": { "id": 2137287, "status": "final", "archived": false, "type": "Invoice", "sequence_number": "6/G", "inverted_sequence_number": "G/6", "atcud": "ABCD1234-6", "sequence_id": "12345", "tax_exemption": "M01", "date": "04/08/2016", "due_date": "19/08/2016", "reference": "foo", "observations": "foo", "retention": "foo", "permalink": "https://www.app.invoicexpress.com/documents/213728738ca780a8de4330cad4a5a556360304bd9c57011", "saft_hash": "J4ay", "sum": 24.39, "discount": 0, "before_taxes": 24.39, "taxes": 5.61, "total": 30, "currency": "Euro", "client": { "id": 628535, "name": "John", "country": "Portugal" }, "items": [ { "name": "Large", "description": "foo", "unit_price": "24.3902", "unit": "foo", "quantity": "1.0", "tax": { "id": 69166, "name": "IVA23", "value": 23 }, "discount": 0, "subtotal": 24.39, "tax_amount": 5.61, "discount_amount": 0, "total": 30 } ], "mb_reference": { "entity": "10611", "value": 30, "reference": "952000823" } } } ``` -------------------------------- ### Example Success Response Body for Account Creation Source: https://invoicexpress.com/api-v2/accounts/create-8 This JSON object shows an example of a successful response body when an account is created using the InvoiceXpress API v2. It includes the new account's ID, name, API key, and state. ```JSON { "account": { "id": "Account ID", "name": "Company name", "url": "https://companyname.app.invoicexpress.com", "api_key": "aa8e739bbcbb406c90eccbe0825e87c5c1c4c5a9", "state": "active" } } ``` -------------------------------- ### Generate PDF using Go Source: https://invoicexpress.com/api-v2/invoices/generate-pdf This Go program demonstrates how to perform an HTTP GET request to the InvoiceXpress API to generate a PDF. It includes setting headers and reading the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/api/pdf/:document-id.json?second_copy=false&api_key=YOUR%20API%20KEY%20HERE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("accept", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Invoice Example Response Body Source: https://invoicexpress.com/api-v2/invoices/get This JSON structure represents a successful response when retrieving an invoice from the InvoiceXpress API. It includes details such as invoice ID, status, dates, client information, and line items. ```json { "invoice": { "id": 2137287, "status": "final", "archived": false, "type": "Invoice", "sequence_number": "6/G", "inverted_sequence_number": "G/6", "atcud": "ABCD1234-6", "sequence_id": "12345", "tax_exemption": "M01", "date": "04/08/2016", "due_date": "19/08/2016", "reference": "foo", "observations": "foo", "retention": "foo", "permalink": "https://www.app.invoicexpress.com/documents/213728738ca780a8de4330cad4a5a556360304bd9c57011", "saft_hash": "J4ay", "sum": 24.39, "discount": 0, "before_taxes": 24.39, "taxes": 5.61, "total": 30, "currency": "Euro", "client": { "id": 628535, "name": "John", "country": "Portugal" }, "items": [ { "name": "Large", "description": "foo", "unit_price": "24.3902", "unit": "foo", "quantity": "1.0", "tax": { "id": 69166, "name": "IVA23", "value": 23 }, "discount": 0, "subtotal": 24.39, "tax_amount": 5.61, "discount_amount": 0, "total": 30 } ], "mb_reference": { "entity": "10611", "value": 30, "reference": "952000823" } } } ``` -------------------------------- ### Get Invoice Example Response Body Source: https://invoicexpress.com/api-v2/invoices/get/termos-condicoes This JSON structure represents a successful response when retrieving an invoice from the InvoiceXpress API. It includes details such as invoice ID, status, dates, client information, and line items. ```json { "invoice": { "id": 2137287, "status": "final", "archived": false, "type": "Invoice", "sequence_number": "6/G", "inverted_sequence_number": "G/6", "atcud": "ABCD1234-6", "sequence_id": "12345", "tax_exemption": "M01", "date": "04/08/2016", "due_date": "19/08/2016", "reference": "foo", "observations": "foo", "retention": "foo", "permalink": "https://www.app.invoicexpress.com/documents/213728738ca780a8de4330cad4a5a556360304bd9c57011", "saft_hash": "J4ay", "sum": 24.39, "discount": 0, "before_taxes": 24.39, "taxes": 5.61, "total": 30, "currency": "Euro", "client": { "id": 628535, "name": "John", "country": "Portugal" }, "items": [ { "name": "Large", "description": "foo", "unit_price": "24.3902", "unit": "foo", "quantity": "1.0", "tax": { "id": 69166, "name": "IVA23", "value": 23 }, "discount": 0, "subtotal": 24.39, "tax_amount": 5.61, "discount_amount": 0, "total": 30 } ], "mb_reference": { "entity": "10611", "value": 30, "reference": "952000823" } } } ``` -------------------------------- ### Fetch Estimates with Filters (Go) Source: https://invoicexpress.com/api-v2/estimates/list-all-1 This Go code snippet demonstrates how to fetch estimates from the InvoiceXpress API v2 using the net/http package. It constructs a URL with various query parameters for filtering and pagination, sets the 'accept' header to 'application/json', and prints the response body. ```go package main import ( "fmt" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/estimates.json?text=foo&type%5B%5D=Quote&status%5B%5D=sent&date%5Bfrom%5D=30%2F09%2F2017&date%5Bto%5D=31%2F10%2F2017&due_date%5Bfrom%5D=30%2F09%2F2017&due_date%5Bto%5D=31%2F10%2F2017&total_before_taxes%5Bfrom%5D=100.00&total_before_taxes%5Bto%5D=500.00&non_archived=true&archived=false&page=1&per_page=30&api_key=YOUR%20API%20KEY%20HERE" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("accept", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Retrieve Specific Document via API (Node.js) Source: https://invoicexpress.com/api-v2/estimates/get-1 This Node.js example demonstrates fetching a specific document using the InvoiceXpress API V2. It utilizes the built-in 'https' module to construct and send a GET request, including necessary headers and parameters for authentication and content type. ```javascript var http = require("https"); var options = { "method": "GET", "hostname": "account_name.app.invoicexpress.com", "port": null, "path": "/:document-type/:document-id.json?api_key=YOUR%20API%20KEY%20HERE", "headers": { "accept": "application/json" } }; var req = http.request(options, function (res) { var chunks = []; res.on("data", function (chunk) { chunks.push(chunk); }); res.on("end", function () { var body = Buffer.concat(chunks); console.log(body.toString()); }); }); req.end(); ``` -------------------------------- ### Create Document via InvoiceXpress API v2 Source: https://invoicexpress.com/api-v2/invoices/create This snippet demonstrates how to create a document (e.g., invoice) using the InvoiceXpress API v2. It shows how to construct the POST request with the necessary headers and JSON payload, including document details like date, client information, and items. The examples cover Python, PHP, and Go. ```Python import http.client conn = http.client.HTTPSConnection("account_name.app.invoicexpress.com") payload = "{\"invoice\":{\"date\":\"03/12/2017\",\"due_date\":\"03/12/2017\",\"client\":{\"name\":\"Client Name\",\"code\":\"A1\"},\"items\":[{\"name\":\"Item Name\",\"description\":\"Item Description\",\"unit_price\":\"100\",\"quantity\":\"5\"}]}}" headers = { 'accept': "application/json", 'content-type': "application/json" } conn.request("POST", "/:document-type.json?api_key=YOUR%20API%20KEY%20HERE", payload, headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8")) ``` ```PHP "https://account_name.app.invoicexpress.com/:document-type.json?api_key=YOUR%20API%20KEY%20HERE", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => "{\"invoice\":{\"date\":\"03/12/2017\",\"due_date\":\"03/12/2017\",\"client\":{\"name\":\"Client Name\",\"code\":\"A1\"},\"items\":[{\"name\":\"Item Name\",\"description\":\"Item Description\",\"unit_price\":\"100\",\"quantity\":\"5\"}]}}", CURLOPT_HTTPHEADER => array( "accept: application/json", "content-type: application/json" ), )); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } ``` ```Go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/:document-type.json?api_key=YOUR%20API%20KEY%20HERE" payload := strings.NewReader("{\"invoice\":{\"date\":\"03/12/2017\",\"due_date\":\"03/12/2017\",\"client\":{\"name\":\"Client Name\",\"code\":\"A1\"},\"items\":[{\"name\":\"Item Name\",\"description\":\"Item Description\",\"unit_price\":\"100\",\"quantity\":\"5\"}]}}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("accept", "application/json") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### InvoiceXpress API v2 Client Request Body Example Source: https://invoicexpress.com/api-v2/clients/update-4 An example JSON payload demonstrating the structure and data required for creating or updating a client via the InvoiceXpress API v2. It includes all possible fields for client details, contact information, and send options. ```json { "client": { "name": "Client Name", "code": "12345", "email": "foo@bar.com", "language": "pt", "address": "Avenida da República, Lisboa", "city": "Lisboa", "postal_code": "1050-555", "country": "Portugal", "fiscal_id": "508025338", "website": "www.invoicexpress.com", "phone": "213456789", "fax": "213456788", "preferred_contact": { "name": "Bruce Norris", "email": "email@invoicexpress.com", "phone": "213456789" }, "observations": "Observations", "send_options": "1" } } ``` -------------------------------- ### Get Related Documents Example Response Source: https://invoicexpress.com/api-v2/invoices/related-documents This JSON object represents a successful response when retrieving related documents for a specific invoice or document in the InvoiceXpress API. It includes details about the document, its items, and associated tax information. ```json { "documents": [ { "id": 541793, "status": "final", "archived": true, "type": "Invoice", "sequence_number": "28/A", "inverted_sequence_number": "A/28", "atcud": "ABCD1234-28", "date": "27/06/2017", "due_date": "27/06/2017", "reference": "foo", "observations": "foo", "retention": "foo", "permalink": "https://www.app.invoicexpress.com/documents/541793e1ab2ebd5c06def40c346ffbe0ff2b463eb1c0f0", "saft_hash": "Tdik", "sum": 1, "discount": 0, "before_taxes": 1, "taxes": 0.07, "total": 1.07, "currency": "Euro", "client": { "id": 1310176, "name": "John", "country": "Portugal" }, "items": [ { "name": " iPhone ", "description": "foo", "unit_price": "1.0", "unit": "foo", "quantity": "1.0", "tax": { "id": 31597, "name": "IVA7", "value": 7 }, "discount": 0, "subtotal": 1, "tax_amount": 0.07, "discount_amount": 0, "total": 1.07 } ], "sequence_id": "12345", "tax_exemption": "M01" } ] } ``` -------------------------------- ### Create InvoiceXpress Sequence (Go) Source: https://invoicexpress.com/api-v2/sequences/create-6 This Go code snippet demonstrates how to create a new sequence in InvoiceXpress by making a POST request to the API. It includes setting up the request payload, headers, and handling the response. ```Go package main import ( "fmt" "strings" "net/http" "io/ioutil" ) func main() { url := "https://account_name.app.invoicexpress.com/sequences.json?api_key=YOUR%20API%20KEY%20HERE" payload := strings.NewReader("{\"sequence\":{\"serie\":\"2017\",\"default_sequence\":\"1\"}}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("accept", "application/json") req.Header.Add("content-type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := ioutil.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ```