Batch update InvoiceLineItems for an Invoice for a Company
curl --request PATCH \
--url https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"rate_type": "RatePerHour",
"invoice_line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"_destroy": 123,
"quantity": 123,
"rate": 123,
"pay_start_time": "2023-11-07T05:31:56Z",
"pay_end_time": "2023-11-07T05:31:56Z",
"billing_adjustment_minutes": 123,
"load_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}
'import requests
url = "https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items"
payload = {
"rate_type": "RatePerHour",
"invoice_line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"_destroy": 123,
"quantity": 123,
"rate": 123,
"pay_start_time": "2023-11-07T05:31:56Z",
"pay_end_time": "2023-11-07T05:31:56Z",
"billing_adjustment_minutes": 123,
"load_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
rate_type: 'RatePerHour',
invoice_line_items: [
{
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
_destroy: 123,
quantity: 123,
rate: 123,
pay_start_time: '2023-11-07T05:31:56Z',
pay_end_time: '2023-11-07T05:31:56Z',
billing_adjustment_minutes: 123,
load_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
]
})
};
fetch('https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'rate_type' => 'RatePerHour',
'invoice_line_items' => [
[
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'_destroy' => 123,
'quantity' => 123,
'rate' => 123,
'pay_start_time' => '2023-11-07T05:31:56Z',
'pay_end_time' => '2023-11-07T05:31:56Z',
'billing_adjustment_minutes' => 123,
'load_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items"
payload := strings.NewReader("{\n \"rate_type\": \"RatePerHour\",\n \"invoice_line_items\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"_destroy\": 123,\n \"quantity\": 123,\n \"rate\": 123,\n \"pay_start_time\": \"2023-11-07T05:31:56Z\",\n \"pay_end_time\": \"2023-11-07T05:31:56Z\",\n \"billing_adjustment_minutes\": 123,\n \"load_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rate_type\": \"RatePerHour\",\n \"invoice_line_items\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"_destroy\": 123,\n \"quantity\": 123,\n \"rate\": 123,\n \"pay_start_time\": \"2023-11-07T05:31:56Z\",\n \"pay_end_time\": \"2023-11-07T05:31:56Z\",\n \"billing_adjustment_minutes\": 123,\n \"load_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rate_type\": \"RatePerHour\",\n \"invoice_line_items\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"_destroy\": 123,\n \"quantity\": 123,\n \"rate\": 123,\n \"pay_start_time\": \"2023-11-07T05:31:56Z\",\n \"pay_end_time\": \"2023-11-07T05:31:56Z\",\n \"billing_adjustment_minutes\": 123,\n \"load_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": "<string>",
"total_amount": "<string>",
"revenue_rate_value": "<string>",
"revenue_cost_rate_type": "RateForEach",
"billing_adjustment_minutes": 123,
"pay_start_time": "2023-11-07T05:31:56Z",
"pay_end_time": "2023-11-07T05:31:56Z",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"delivered_quantity": "<string>",
"line_item_type": "InvoiceLineItem",
"rate": "<string>",
"rate_type": "<string>",
"material_rate_unit_of_measure": "Load",
"load": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": "<string>",
"unit_of_measure": "Load",
"load_id": "<string>",
"ordinality": 123,
"ticket": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"ticket_number": "<string>",
"preview_url": "<string>"
}
}
}
]
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>",
"error_type": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
{
"model": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}
}Invoices
Batch update InvoiceLineItems for an Invoice for a Company
Batch update `InvoiceLineItems` for an `Invoice` for a `Company`.
This endpoint allows updating, creating, deleting `InvoiceLineItems` all at once.
If updating existing records:
- must provide the `id` for each record to be updated
- only provide the fields to be updated
- no need to provide the `rate_type` field
e.g.
```json
invoice_line_items: [
{
"id": "some-uuid"
"quantity": 20.25,
"rate": 15.75
}
]
```
If deleting existing records:
- must provide the `id` and the property `_destroy: 1`
e.g.
```json
invoice_line_items: [
{
"id": "some-uuid"
"_destroy": 1
}
]
```
<hr>
## This section is deprecated
#### We are still accepting `rate_type` but it will have no effect. It will be removed in one of the next releases.
If creating new records (for cases where the `Invoice` `rate_type` grouping changes):
- must provide the `rate_type`
- must not provide the `id` for each record to be created
- provide all the fields needed for the record
e.g.
```json
rate_type: "RatePerTon",
invoice_line_items: [
{
"quantity": 20.25,
"rate": 12.5
},
{
"quantity": 22.50,
"rate": 12.5
}
]
```
PATCH
/
v1
/
companies
/
{company-id}
/
invoices
/
{invoice-id}
/
invoice_line_items
Batch update InvoiceLineItems for an Invoice for a Company
curl --request PATCH \
--url https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"rate_type": "RatePerHour",
"invoice_line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"_destroy": 123,
"quantity": 123,
"rate": 123,
"pay_start_time": "2023-11-07T05:31:56Z",
"pay_end_time": "2023-11-07T05:31:56Z",
"billing_adjustment_minutes": 123,
"load_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}
'import requests
url = "https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items"
payload = {
"rate_type": "RatePerHour",
"invoice_line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"_destroy": 123,
"quantity": 123,
"rate": 123,
"pay_start_time": "2023-11-07T05:31:56Z",
"pay_end_time": "2023-11-07T05:31:56Z",
"billing_adjustment_minutes": 123,
"load_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
rate_type: 'RatePerHour',
invoice_line_items: [
{
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
_destroy: 123,
quantity: 123,
rate: 123,
pay_start_time: '2023-11-07T05:31:56Z',
pay_end_time: '2023-11-07T05:31:56Z',
billing_adjustment_minutes: 123,
load_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
]
})
};
fetch('https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'rate_type' => 'RatePerHour',
'invoice_line_items' => [
[
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'_destroy' => 123,
'quantity' => 123,
'rate' => 123,
'pay_start_time' => '2023-11-07T05:31:56Z',
'pay_end_time' => '2023-11-07T05:31:56Z',
'billing_adjustment_minutes' => 123,
'load_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items"
payload := strings.NewReader("{\n \"rate_type\": \"RatePerHour\",\n \"invoice_line_items\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"_destroy\": 123,\n \"quantity\": 123,\n \"rate\": 123,\n \"pay_start_time\": \"2023-11-07T05:31:56Z\",\n \"pay_end_time\": \"2023-11-07T05:31:56Z\",\n \"billing_adjustment_minutes\": 123,\n \"load_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"rate_type\": \"RatePerHour\",\n \"invoice_line_items\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"_destroy\": 123,\n \"quantity\": 123,\n \"rate\": 123,\n \"pay_start_time\": \"2023-11-07T05:31:56Z\",\n \"pay_end_time\": \"2023-11-07T05:31:56Z\",\n \"billing_adjustment_minutes\": 123,\n \"load_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tread-horizon.com/v1/companies/{company-id}/invoices/{invoice-id}/invoice_line_items")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"rate_type\": \"RatePerHour\",\n \"invoice_line_items\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"_destroy\": 123,\n \"quantity\": 123,\n \"rate\": 123,\n \"pay_start_time\": \"2023-11-07T05:31:56Z\",\n \"pay_end_time\": \"2023-11-07T05:31:56Z\",\n \"billing_adjustment_minutes\": 123,\n \"load_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": "<string>",
"total_amount": "<string>",
"revenue_rate_value": "<string>",
"revenue_cost_rate_type": "RateForEach",
"billing_adjustment_minutes": 123,
"pay_start_time": "2023-11-07T05:31:56Z",
"pay_end_time": "2023-11-07T05:31:56Z",
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"delivered_quantity": "<string>",
"line_item_type": "InvoiceLineItem",
"rate": "<string>",
"rate_type": "<string>",
"material_rate_unit_of_measure": "Load",
"load": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"quantity": "<string>",
"unit_of_measure": "Load",
"load_id": "<string>",
"ordinality": 123,
"ticket": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"ticket_number": "<string>",
"preview_url": "<string>"
}
}
}
]
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>",
"error_type": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>"
}
}{
"error": {
"code": "<string>",
"errors": [
{
"model": "<string>",
"field": "<string>",
"message": "<string>"
}
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
The Accept-Language request HTTP header indicates the natural language and locale that the client prefers.
Example:
"en"
Body
application/json
Response
OK
Show child attributes
Show child attributes
Retrieve all InvoiceLineItems that belongs to an Invoice for a CompanyGenerate InvoiceLineItems for an Invoice for a Company
⌘I