curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"line_items": [
{
"amount": 123,
"revenue_account_identifier": {
"type": "AccountId",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
]
}
],
"external_id": "<string>",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
],
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits"
payload = {
"line_items": [
{
"amount": 123,
"revenue_account_identifier": {
"type": "AccountId",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
]
}
],
"external_id": "<string>",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
],
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
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({
line_items: [
{
amount: 123,
revenue_account_identifier: {type: 'AccountId', id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'},
memo: '<string>',
metadata: {
custom_field: 'value',
'any valid json': 'below 1kb',
nested: {'meaning of life': 42, array: []}
},
reference_number: '<string>',
tags: [
{
key: 'department',
value: 'sales',
dimension_display_name: 'Department',
value_display_name: 'Sales Department'
}
]
}
],
external_id: '<string>',
customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
customer_external_id: '<string>',
sent_at: '2023-11-07T05:31:56Z',
allocations: [{amount: 123, invoice_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'}],
tags: [
{
key: 'department',
value: 'sales',
dimension_display_name: 'Department',
value_display_name: 'Sales Department'
}
],
memo: '<string>',
metadata: {
custom_field: 'value',
'any valid json': 'below 1kb',
nested: {'meaning of life': 42, array: []}
},
reference_number: '<string>'
})
};
fetch('https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits', 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://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits",
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([
'line_items' => [
[
'amount' => 123,
'revenue_account_identifier' => [
'type' => 'AccountId',
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'memo' => '<string>',
'metadata' => [
'custom_field' => 'value',
'any valid json' => 'below 1kb',
'nested' => [
'meaning of life' => 42,
'array' => [
]
]
],
'reference_number' => '<string>',
'tags' => [
[
'key' => 'department',
'value' => 'sales',
'dimension_display_name' => 'Department',
'value_display_name' => 'Sales Department'
]
]
]
],
'external_id' => '<string>',
'customer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'customer_external_id' => '<string>',
'sent_at' => '2023-11-07T05:31:56Z',
'allocations' => [
[
'amount' => 123,
'invoice_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
],
'tags' => [
[
'key' => 'department',
'value' => 'sales',
'dimension_display_name' => 'Department',
'value_display_name' => 'Sales Department'
]
],
'memo' => '<string>',
'metadata' => [
'custom_field' => 'value',
'any valid json' => 'below 1kb',
'nested' => [
'meaning of life' => 42,
'array' => [
]
]
],
'reference_number' => '<string>'
]),
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://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits"
payload := strings.NewReader("{\n \"line_items\": [\n {\n \"amount\": 123,\n \"revenue_account_identifier\": {\n \"type\": \"AccountId\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\",\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ]\n }\n ],\n \"external_id\": \"<string>\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_external_id\": \"<string>\",\n \"sent_at\": \"2023-11-07T05:31:56Z\",\n \"allocations\": [\n {\n \"amount\": 123,\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ],\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\"\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://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"line_items\": [\n {\n \"amount\": 123,\n \"revenue_account_identifier\": {\n \"type\": \"AccountId\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\",\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ]\n }\n ],\n \"external_id\": \"<string>\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_external_id\": \"<string>\",\n \"sent_at\": \"2023-11-07T05:31:56Z\",\n \"allocations\": [\n {\n \"amount\": 123,\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ],\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits")
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 \"line_items\": [\n {\n \"amount\": 123,\n \"revenue_account_identifier\": {\n \"type\": \"AccountId\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\",\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ]\n }\n ],\n \"external_id\": \"<string>\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_external_id\": \"<string>\",\n \"sent_at\": \"2023-11-07T05:31:56Z\",\n \"allocations\": [\n {\n \"amount\": 123,\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ],\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"type": "CustomerData",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"external_id": "31415926535",
"individual_name": "<string>",
"company_name": "<string>",
"email": "<string>",
"mobile_phone": "<string>",
"office_phone": "<string>",
"address_string": "<string>",
"memo": "<string>",
"status": "ACTIVE",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
},
"line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"ledger_account": {
"id": "c4007474-f604-4d57-9690-b7f40f7a1cee",
"name": "Sales tax: CALIFORNIA",
"stable_name": "SALES_TAXES_PAYABLE:CALIFORNIA",
"normality": "CREDIT",
"account_type": {
"value": "LIABILITY",
"display_name": "Liabilities"
},
"account_subtype": {
"value": "SALES_TAXES_PAYABLE",
"display_name": "Sales Taxes Payable"
}
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
],
"type": "Customer_Credit",
"external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_credit_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"deleted_at": "2023-11-07T05:31:56Z",
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"type": "CustomerData",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"external_id": "31415926535",
"individual_name": "<string>",
"company_name": "<string>",
"email": "<string>",
"mobile_phone": "<string>",
"office_phone": "<string>",
"address_string": "<string>",
"memo": "<string>",
"status": "ACTIVE",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
},
"line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"ledger_account": {
"id": "c4007474-f604-4d57-9690-b7f40f7a1cee",
"name": "Sales tax: CALIFORNIA",
"stable_name": "SALES_TAXES_PAYABLE:CALIFORNIA",
"normality": "CREDIT",
"account_type": {
"value": "LIABILITY",
"display_name": "Liabilities"
},
"account_subtype": {
"value": "SALES_TAXES_PAYABLE",
"display_name": "Sales Taxes Payable"
}
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
],
"type": "Customer_Credit",
"external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_credit_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"deleted_at": "2023-11-07T05:31:56Z",
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
}Create customer credit
Creates a new customer credit for a business.
curl --request POST \
--url https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"line_items": [
{
"amount": 123,
"revenue_account_identifier": {
"type": "AccountId",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
]
}
],
"external_id": "<string>",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
],
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
'import requests
url = "https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits"
payload = {
"line_items": [
{
"amount": 123,
"revenue_account_identifier": {
"type": "AccountId",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
]
}
],
"external_id": "<string>",
"customer_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"tags": [
{
"key": "department",
"value": "sales",
"dimension_display_name": "Department",
"value_display_name": "Sales Department"
}
],
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
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({
line_items: [
{
amount: 123,
revenue_account_identifier: {type: 'AccountId', id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'},
memo: '<string>',
metadata: {
custom_field: 'value',
'any valid json': 'below 1kb',
nested: {'meaning of life': 42, array: []}
},
reference_number: '<string>',
tags: [
{
key: 'department',
value: 'sales',
dimension_display_name: 'Department',
value_display_name: 'Sales Department'
}
]
}
],
external_id: '<string>',
customer_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
customer_external_id: '<string>',
sent_at: '2023-11-07T05:31:56Z',
allocations: [{amount: 123, invoice_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'}],
tags: [
{
key: 'department',
value: 'sales',
dimension_display_name: 'Department',
value_display_name: 'Sales Department'
}
],
memo: '<string>',
metadata: {
custom_field: 'value',
'any valid json': 'below 1kb',
nested: {'meaning of life': 42, array: []}
},
reference_number: '<string>'
})
};
fetch('https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits', 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://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits",
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([
'line_items' => [
[
'amount' => 123,
'revenue_account_identifier' => [
'type' => 'AccountId',
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'memo' => '<string>',
'metadata' => [
'custom_field' => 'value',
'any valid json' => 'below 1kb',
'nested' => [
'meaning of life' => 42,
'array' => [
]
]
],
'reference_number' => '<string>',
'tags' => [
[
'key' => 'department',
'value' => 'sales',
'dimension_display_name' => 'Department',
'value_display_name' => 'Sales Department'
]
]
]
],
'external_id' => '<string>',
'customer_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'customer_external_id' => '<string>',
'sent_at' => '2023-11-07T05:31:56Z',
'allocations' => [
[
'amount' => 123,
'invoice_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
],
'tags' => [
[
'key' => 'department',
'value' => 'sales',
'dimension_display_name' => 'Department',
'value_display_name' => 'Sales Department'
]
],
'memo' => '<string>',
'metadata' => [
'custom_field' => 'value',
'any valid json' => 'below 1kb',
'nested' => [
'meaning of life' => 42,
'array' => [
]
]
],
'reference_number' => '<string>'
]),
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://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits"
payload := strings.NewReader("{\n \"line_items\": [\n {\n \"amount\": 123,\n \"revenue_account_identifier\": {\n \"type\": \"AccountId\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\",\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ]\n }\n ],\n \"external_id\": \"<string>\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_external_id\": \"<string>\",\n \"sent_at\": \"2023-11-07T05:31:56Z\",\n \"allocations\": [\n {\n \"amount\": 123,\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ],\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\"\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://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"line_items\": [\n {\n \"amount\": 123,\n \"revenue_account_identifier\": {\n \"type\": \"AccountId\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\",\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ]\n }\n ],\n \"external_id\": \"<string>\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_external_id\": \"<string>\",\n \"sent_at\": \"2023-11-07T05:31:56Z\",\n \"allocations\": [\n {\n \"amount\": 123,\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ],\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.layerfi.com/v1/businesses/{businessId}/invoices/customer-credits")
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 \"line_items\": [\n {\n \"amount\": 123,\n \"revenue_account_identifier\": {\n \"type\": \"AccountId\",\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\",\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ]\n }\n ],\n \"external_id\": \"<string>\",\n \"customer_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"customer_external_id\": \"<string>\",\n \"sent_at\": \"2023-11-07T05:31:56Z\",\n \"allocations\": [\n {\n \"amount\": 123,\n \"invoice_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"tags\": [\n {\n \"key\": \"department\",\n \"value\": \"sales\",\n \"dimension_display_name\": \"Department\",\n \"value_display_name\": \"Sales Department\"\n }\n ],\n \"memo\": \"<string>\",\n \"metadata\": {\n \"custom_field\": \"value\",\n \"any valid json\": \"below 1kb\",\n \"nested\": {\n \"meaning of life\": 42,\n \"array\": []\n }\n },\n \"reference_number\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"type": "CustomerData",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"external_id": "31415926535",
"individual_name": "<string>",
"company_name": "<string>",
"email": "<string>",
"mobile_phone": "<string>",
"office_phone": "<string>",
"address_string": "<string>",
"memo": "<string>",
"status": "ACTIVE",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
},
"line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"ledger_account": {
"id": "c4007474-f604-4d57-9690-b7f40f7a1cee",
"name": "Sales tax: CALIFORNIA",
"stable_name": "SALES_TAXES_PAYABLE:CALIFORNIA",
"normality": "CREDIT",
"account_type": {
"value": "LIABILITY",
"display_name": "Liabilities"
},
"account_subtype": {
"value": "SALES_TAXES_PAYABLE",
"display_name": "Sales Taxes Payable"
}
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
],
"type": "Customer_Credit",
"external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_credit_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"deleted_at": "2023-11-07T05:31:56Z",
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
}{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer": {
"type": "CustomerData",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"external_id": "31415926535",
"individual_name": "<string>",
"company_name": "<string>",
"email": "<string>",
"mobile_phone": "<string>",
"office_phone": "<string>",
"address_string": "<string>",
"memo": "<string>",
"status": "ACTIVE",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
},
"line_items": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"ledger_account": {
"id": "c4007474-f604-4d57-9690-b7f40f7a1cee",
"name": "Sales tax: CALIFORNIA",
"stable_name": "SALES_TAXES_PAYABLE:CALIFORNIA",
"normality": "CREDIT",
"account_type": {
"value": "LIABILITY",
"display_name": "Liabilities"
},
"account_subtype": {
"value": "SALES_TAXES_PAYABLE",
"display_name": "Sales Taxes Payable"
}
},
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
]
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"transaction_tags": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"key": "ExampleTagKey",
"value": "ExampleTagValue",
"dimension_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"definition_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"dimension_display_name": "<string>",
"value_display_name": "<string>",
"archived_at": "2023-11-07T05:31:56Z"
}
],
"type": "Customer_Credit",
"external_id": "<string>",
"sent_at": "2023-11-07T05:31:56Z",
"allocations": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"customer_credit_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"amount": 123,
"invoice_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"deleted_at": "2023-11-07T05:31:56Z",
"memo": "<string>",
"metadata": {
"custom_field": "value",
"any valid json": "below 1kb",
"nested": {
"meaning of life": 42,
"array": []
}
},
"reference_number": "<string>"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
The UUID of the business to create the customer credit for.
Body
List of line items for this customer credit.
Show child attributes
Show child attributes
External identifier for the customer credit.
UUID of the customer this credit is associated with.
External identifier of the customer this credit is associated with.
Timestamp when the customer credit was sent.
List of allocations for this customer credit.
Show child attributes
Show child attributes
List of tags associated with this customer credit.
Show child attributes
Show child attributes
Memo for any text you would like to associate with the customer credit (for example, to display to end users).
Arbitrary custom metadata in JSON format with a size limit of 1KB.
{ "custom_field": "value", "any valid json": "below 1kb", "nested": { "meaning of life": 42, "array": [] } }
Any (typically user-visible) identifier you would like to associate with the customer credit. Can be used to filter when listing customer credits.
Response
Existing customer credit found or updated.
Show child attributes
Show child attributes