curl --request POST \
--url https://api.togai.com/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"accountId": "ACC001",
"invoiceDate": "2020-07-04T12:00:00.000Z",
"idempotencyKey": "1234567890",
"status": "DRAFT",
"lineItems": [
{
"description": "Payout IMPS",
"type": "CUSTOM_AMOUNT",
"valuePerQuantity": 0.001,
"quantity": 32109,
"units": "USD"
}
]
}
'import requests
url = "https://api.togai.com/invoices"
payload = {
"accountId": "ACC001",
"invoiceDate": "2020-07-04T12:00:00.000Z",
"idempotencyKey": "1234567890",
"status": "DRAFT",
"lineItems": [
{
"description": "Payout IMPS",
"type": "CUSTOM_AMOUNT",
"valuePerQuantity": 0.001,
"quantity": 32109,
"units": "USD"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
accountId: 'ACC001',
invoiceDate: '2020-07-04T12:00:00.000Z',
idempotencyKey: '1234567890',
status: 'DRAFT',
lineItems: [
{
description: 'Payout IMPS',
type: 'CUSTOM_AMOUNT',
valuePerQuantity: 0.001,
quantity: 32109,
units: 'USD'
}
]
})
};
fetch('https://api.togai.com/invoices', 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.togai.com/invoices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => 'ACC001',
'invoiceDate' => '2020-07-04T12:00:00.000Z',
'idempotencyKey' => '1234567890',
'status' => 'DRAFT',
'lineItems' => [
[
'description' => 'Payout IMPS',
'type' => 'CUSTOM_AMOUNT',
'valuePerQuantity' => 0.001,
'quantity' => 32109,
'units' => 'USD'
]
]
]),
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.togai.com/invoices"
payload := strings.NewReader("{\n \"accountId\": \"ACC001\",\n \"invoiceDate\": \"2020-07-04T12:00:00.000Z\",\n \"idempotencyKey\": \"1234567890\",\n \"status\": \"DRAFT\",\n \"lineItems\": [\n {\n \"description\": \"Payout IMPS\",\n \"type\": \"CUSTOM_AMOUNT\",\n \"valuePerQuantity\": 0.001,\n \"quantity\": 32109,\n \"units\": \"USD\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.togai.com/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"accountId\": \"ACC001\",\n \"invoiceDate\": \"2020-07-04T12:00:00.000Z\",\n \"idempotencyKey\": \"1234567890\",\n \"status\": \"DRAFT\",\n \"lineItems\": [\n {\n \"description\": \"Payout IMPS\",\n \"type\": \"CUSTOM_AMOUNT\",\n \"valuePerQuantity\": 0.001,\n \"quantity\": 32109,\n \"units\": \"USD\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/invoices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"accountId\": \"ACC001\",\n \"invoiceDate\": \"2020-07-04T12:00:00.000Z\",\n \"idempotencyKey\": \"1234567890\",\n \"status\": \"DRAFT\",\n \"lineItems\": [\n {\n \"description\": \"Payout IMPS\",\n \"type\": \"CUSTOM_AMOUNT\",\n \"valuePerQuantity\": 0.001,\n \"quantity\": 32109,\n \"units\": \"USD\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "inv.hkgkgyh.ghg",
"sequenceId": "2020-07-2958",
"customerId": "7VcRw9xZDIqsC5E",
"accountId": "ACC001",
"usageInfo": [
{
"description": "rides - local",
"type": "USAGE_METER_USAGE",
"value": 15,
"units": "USAGE_UNITS"
},
{
"description": "rides - pro",
"type": "USAGE_METER_USAGE",
"value": 5,
"units": "USAGE_UNITS"
}
],
"revenueInfo": {
"description": "Total amount due",
"type": "NET_REVENUE",
"units": "USD",
"value": 881.94,
"lineItems": [
{
"description": "Sum Total",
"type": "GROSS_REVENUE",
"units": "USD",
"value": 981.94,
"lineItems": [
{
"description": "Payout_NEFT",
"type": "USAGE_RATE_CARD_REVENUE",
"units": "USD",
"value": 392.1,
"lineItems": [
{
"description": "Slab 1",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
},
{
"description": "Slab 2",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
}
]
},
{
"description": "Payout IMPS",
"type": "USAGE_RATE_CARD_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 32109,
"units": "USD",
"value": 589.94,
"lineItems": [
{
"description": "Slab 1",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
},
{
"description": "Slab 2",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
}
]
}
]
}
]
},
"invoiceDetails": {
"customer": {
"name": "John Doe",
"primaryEmail": "john@togai.com",
"billingAddress": {
"line1": "2281 Broadway Street",
"line2": "G-31",
"postalCode": "29501",
"city": "Florence",
"state": "South Carolina",
"country": "US"
}
},
"account": {
"name": "Togai",
"invoiceCurrency": "USD"
},
"pricePlanName": "Togai Basic"
},
"status": "DUE",
"startDate": "2020-07-04T12:00:00.000Z",
"endDate": "2020-07-04T12:00:00.000Z",
"invoiceDate": "2020-07-04T12:00:00.000Z",
"generatedAt": "2020-07-04T12:00:00.000Z",
"updatedAt": "2020-07-04T12:00:00.000Z"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}Create a custom invoice for an account
Create a custom invoice for an account.
curl --request POST \
--url https://api.togai.com/invoices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"accountId": "ACC001",
"invoiceDate": "2020-07-04T12:00:00.000Z",
"idempotencyKey": "1234567890",
"status": "DRAFT",
"lineItems": [
{
"description": "Payout IMPS",
"type": "CUSTOM_AMOUNT",
"valuePerQuantity": 0.001,
"quantity": 32109,
"units": "USD"
}
]
}
'import requests
url = "https://api.togai.com/invoices"
payload = {
"accountId": "ACC001",
"invoiceDate": "2020-07-04T12:00:00.000Z",
"idempotencyKey": "1234567890",
"status": "DRAFT",
"lineItems": [
{
"description": "Payout IMPS",
"type": "CUSTOM_AMOUNT",
"valuePerQuantity": 0.001,
"quantity": 32109,
"units": "USD"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
accountId: 'ACC001',
invoiceDate: '2020-07-04T12:00:00.000Z',
idempotencyKey: '1234567890',
status: 'DRAFT',
lineItems: [
{
description: 'Payout IMPS',
type: 'CUSTOM_AMOUNT',
valuePerQuantity: 0.001,
quantity: 32109,
units: 'USD'
}
]
})
};
fetch('https://api.togai.com/invoices', 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.togai.com/invoices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'accountId' => 'ACC001',
'invoiceDate' => '2020-07-04T12:00:00.000Z',
'idempotencyKey' => '1234567890',
'status' => 'DRAFT',
'lineItems' => [
[
'description' => 'Payout IMPS',
'type' => 'CUSTOM_AMOUNT',
'valuePerQuantity' => 0.001,
'quantity' => 32109,
'units' => 'USD'
]
]
]),
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.togai.com/invoices"
payload := strings.NewReader("{\n \"accountId\": \"ACC001\",\n \"invoiceDate\": \"2020-07-04T12:00:00.000Z\",\n \"idempotencyKey\": \"1234567890\",\n \"status\": \"DRAFT\",\n \"lineItems\": [\n {\n \"description\": \"Payout IMPS\",\n \"type\": \"CUSTOM_AMOUNT\",\n \"valuePerQuantity\": 0.001,\n \"quantity\": 32109,\n \"units\": \"USD\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.togai.com/invoices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"accountId\": \"ACC001\",\n \"invoiceDate\": \"2020-07-04T12:00:00.000Z\",\n \"idempotencyKey\": \"1234567890\",\n \"status\": \"DRAFT\",\n \"lineItems\": [\n {\n \"description\": \"Payout IMPS\",\n \"type\": \"CUSTOM_AMOUNT\",\n \"valuePerQuantity\": 0.001,\n \"quantity\": 32109,\n \"units\": \"USD\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.togai.com/invoices")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"accountId\": \"ACC001\",\n \"invoiceDate\": \"2020-07-04T12:00:00.000Z\",\n \"idempotencyKey\": \"1234567890\",\n \"status\": \"DRAFT\",\n \"lineItems\": [\n {\n \"description\": \"Payout IMPS\",\n \"type\": \"CUSTOM_AMOUNT\",\n \"valuePerQuantity\": 0.001,\n \"quantity\": 32109,\n \"units\": \"USD\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "inv.hkgkgyh.ghg",
"sequenceId": "2020-07-2958",
"customerId": "7VcRw9xZDIqsC5E",
"accountId": "ACC001",
"usageInfo": [
{
"description": "rides - local",
"type": "USAGE_METER_USAGE",
"value": 15,
"units": "USAGE_UNITS"
},
{
"description": "rides - pro",
"type": "USAGE_METER_USAGE",
"value": 5,
"units": "USAGE_UNITS"
}
],
"revenueInfo": {
"description": "Total amount due",
"type": "NET_REVENUE",
"units": "USD",
"value": 881.94,
"lineItems": [
{
"description": "Sum Total",
"type": "GROSS_REVENUE",
"units": "USD",
"value": 981.94,
"lineItems": [
{
"description": "Payout_NEFT",
"type": "USAGE_RATE_CARD_REVENUE",
"units": "USD",
"value": 392.1,
"lineItems": [
{
"description": "Slab 1",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
},
{
"description": "Slab 2",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
}
]
},
{
"description": "Payout IMPS",
"type": "USAGE_RATE_CARD_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 32109,
"units": "USD",
"value": 589.94,
"lineItems": [
{
"description": "Slab 1",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
},
{
"description": "Slab 2",
"type": "USAGE_RATE_CARD_SLAB_REVENUE",
"valuePerQuantity": 0.001,
"quantity": 10000,
"units": "USD",
"value": 10
}
]
}
]
}
]
},
"invoiceDetails": {
"customer": {
"name": "John Doe",
"primaryEmail": "john@togai.com",
"billingAddress": {
"line1": "2281 Broadway Street",
"line2": "G-31",
"postalCode": "29501",
"city": "Florence",
"state": "South Carolina",
"country": "US"
}
},
"account": {
"name": "Togai",
"invoiceCurrency": "USD"
},
"pricePlanName": "Togai Basic"
},
"status": "DUE",
"startDate": "2020-07-04T12:00:00.000Z",
"endDate": "2020-07-04T12:00:00.000Z",
"invoiceDate": "2020-07-04T12:00:00.000Z",
"generatedAt": "2020-07-04T12:00:00.000Z",
"updatedAt": "2020-07-04T12:00:00.000Z"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}{
"message": "<Reason message>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Payload to create invoice
Payload to create invoice
"ACC001"
"2020-07-04T12:00:00.000Z"
Status to create an invoice in.
DRAFT, DUE, PAID "DUE"
1 - 50 elementsShow child attributes
Show child attributes
"1234567890"
Response
Response for Get invoice requests
Structure of invoice
Identifier of invoice
50Status of the invoice
DRAFT, DUE, PAID, VOID, UN_COLLECTIBLE, INITIATE_REFUND, REFUND_COMPLETED, MERGED, PARTIALLY_PAID "DUE"
Represents the class of entity( INVOICE/ORDER/BILLABLE)
INVOICE, ORDER, BILLABLE "INVOICE"
Represents the type of entity(STANDARD/AD_HOC/COMPOSITE)
STANDARD, AD_HOC, COMPOSITE "STANDARD"
Invoice date of the invoice
"2020-07-04T12:00:00.000Z"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Start date of the invoice
"2020-07-04T12:00:00.000Z"
End date of the invoice
"2020-07-04T12:00:00.000Z"
Inclusive end date of the invoice
"2020-07-03T11:59:59.999Z"
Due date of the invoice
"2020-07-04T12:00:00.000Z"
Show child attributes
Show child attributes
Sequence id of the invoice
Download URL of the pdf file corresponding to the invoice
