Create Expense
curl --request POST \
--url https://api.royalti.io/expense/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "Mavins sabi girl",
"type": "product",
"transactionDate": "2023-03-14",
"currency": "USD",
"amount": 100,
"amountUSD": 100,
"id": "77ec1367-be7e-4c3c-a57f-79f6b7349952",
"conversionRate": 1,
"memo": "Some memo",
"files": {
"file1": "file1.pdf",
"file2": "file2.pdf"
},
"split": [
{
"user": "91f1d1bd-ef25-4990-bd4f-aeee696c73a9",
"share": 30
},
{
"user": "9ea08acc-e135-4bd9-b159-48339ff65061",
"share": 50
},
{
"user": "b369dabe-b4e0-4787-91a5-b561c98601e5",
"share": 20
}
]
}
'import requests
url = "https://api.royalti.io/expense/"
payload = {
"title": "Mavins sabi girl",
"type": "product",
"transactionDate": "2023-03-14",
"currency": "USD",
"amount": 100,
"amountUSD": 100,
"id": "77ec1367-be7e-4c3c-a57f-79f6b7349952",
"conversionRate": 1,
"memo": "Some memo",
"files": {
"file1": "file1.pdf",
"file2": "file2.pdf"
},
"split": [
{
"user": "91f1d1bd-ef25-4990-bd4f-aeee696c73a9",
"share": 30
},
{
"user": "9ea08acc-e135-4bd9-b159-48339ff65061",
"share": 50
},
{
"user": "b369dabe-b4e0-4787-91a5-b561c98601e5",
"share": 20
}
]
}
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({
title: 'Mavins sabi girl',
type: 'product',
transactionDate: '2023-03-14',
currency: 'USD',
amount: 100,
amountUSD: 100,
id: '77ec1367-be7e-4c3c-a57f-79f6b7349952',
conversionRate: 1,
memo: 'Some memo',
files: {file1: 'file1.pdf', file2: 'file2.pdf'},
split: [
{user: '91f1d1bd-ef25-4990-bd4f-aeee696c73a9', share: 30},
{user: '9ea08acc-e135-4bd9-b159-48339ff65061', share: 50},
{user: 'b369dabe-b4e0-4787-91a5-b561c98601e5', share: 20}
]
})
};
fetch('https://api.royalti.io/expense/', 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.royalti.io/expense/",
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([
'title' => 'Mavins sabi girl',
'type' => 'product',
'transactionDate' => '2023-03-14',
'currency' => 'USD',
'amount' => 100,
'amountUSD' => 100,
'id' => '77ec1367-be7e-4c3c-a57f-79f6b7349952',
'conversionRate' => 1,
'memo' => 'Some memo',
'files' => [
'file1' => 'file1.pdf',
'file2' => 'file2.pdf'
],
'split' => [
[
'user' => '91f1d1bd-ef25-4990-bd4f-aeee696c73a9',
'share' => 30
],
[
'user' => '9ea08acc-e135-4bd9-b159-48339ff65061',
'share' => 50
],
[
'user' => 'b369dabe-b4e0-4787-91a5-b561c98601e5',
'share' => 20
]
]
]),
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.royalti.io/expense/"
payload := strings.NewReader("{\n \"title\": \"Mavins sabi girl\",\n \"type\": \"product\",\n \"transactionDate\": \"2023-03-14\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"amountUSD\": 100,\n \"id\": \"77ec1367-be7e-4c3c-a57f-79f6b7349952\",\n \"conversionRate\": 1,\n \"memo\": \"Some memo\",\n \"files\": {\n \"file1\": \"file1.pdf\",\n \"file2\": \"file2.pdf\"\n },\n \"split\": [\n {\n \"user\": \"91f1d1bd-ef25-4990-bd4f-aeee696c73a9\",\n \"share\": 30\n },\n {\n \"user\": \"9ea08acc-e135-4bd9-b159-48339ff65061\",\n \"share\": 50\n },\n {\n \"user\": \"b369dabe-b4e0-4787-91a5-b561c98601e5\",\n \"share\": 20\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.royalti.io/expense/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Mavins sabi girl\",\n \"type\": \"product\",\n \"transactionDate\": \"2023-03-14\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"amountUSD\": 100,\n \"id\": \"77ec1367-be7e-4c3c-a57f-79f6b7349952\",\n \"conversionRate\": 1,\n \"memo\": \"Some memo\",\n \"files\": {\n \"file1\": \"file1.pdf\",\n \"file2\": \"file2.pdf\"\n },\n \"split\": [\n {\n \"user\": \"91f1d1bd-ef25-4990-bd4f-aeee696c73a9\",\n \"share\": 30\n },\n {\n \"user\": \"9ea08acc-e135-4bd9-b159-48339ff65061\",\n \"share\": 50\n },\n {\n \"user\": \"b369dabe-b4e0-4787-91a5-b561c98601e5\",\n \"share\": 20\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.royalti.io/expense/")
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 \"title\": \"Mavins sabi girl\",\n \"type\": \"product\",\n \"transactionDate\": \"2023-03-14\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"amountUSD\": 100,\n \"id\": \"77ec1367-be7e-4c3c-a57f-79f6b7349952\",\n \"conversionRate\": 1,\n \"memo\": \"Some memo\",\n \"files\": {\n \"file1\": \"file1.pdf\",\n \"file2\": \"file2.pdf\"\n },\n \"split\": [\n {\n \"user\": \"91f1d1bd-ef25-4990-bd4f-aeee696c73a9\",\n \"share\": 30\n },\n {\n \"user\": \"9ea08acc-e135-4bd9-b159-48339ff65061\",\n \"share\": 50\n },\n {\n \"user\": \"b369dabe-b4e0-4787-91a5-b561c98601e5\",\n \"share\": 20\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Expense created successfully",
"expense": {
"id": "expense-uuid-123",
"title": "Mavins sabi girl",
"type": "product",
"amount": 100,
"amountUSD": 100,
"currency": "USD",
"transactionDate": "2023-03-14",
"createdAt": "2023-03-14T10:30:00.000Z",
"updatedAt": "2023-03-14T10:30:00.000Z"
}
}{
"msg": "product does not exist."
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}Expense
Create Expense
Create Expense
POST
/
expense
/
Create Expense
curl --request POST \
--url https://api.royalti.io/expense/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "Mavins sabi girl",
"type": "product",
"transactionDate": "2023-03-14",
"currency": "USD",
"amount": 100,
"amountUSD": 100,
"id": "77ec1367-be7e-4c3c-a57f-79f6b7349952",
"conversionRate": 1,
"memo": "Some memo",
"files": {
"file1": "file1.pdf",
"file2": "file2.pdf"
},
"split": [
{
"user": "91f1d1bd-ef25-4990-bd4f-aeee696c73a9",
"share": 30
},
{
"user": "9ea08acc-e135-4bd9-b159-48339ff65061",
"share": 50
},
{
"user": "b369dabe-b4e0-4787-91a5-b561c98601e5",
"share": 20
}
]
}
'import requests
url = "https://api.royalti.io/expense/"
payload = {
"title": "Mavins sabi girl",
"type": "product",
"transactionDate": "2023-03-14",
"currency": "USD",
"amount": 100,
"amountUSD": 100,
"id": "77ec1367-be7e-4c3c-a57f-79f6b7349952",
"conversionRate": 1,
"memo": "Some memo",
"files": {
"file1": "file1.pdf",
"file2": "file2.pdf"
},
"split": [
{
"user": "91f1d1bd-ef25-4990-bd4f-aeee696c73a9",
"share": 30
},
{
"user": "9ea08acc-e135-4bd9-b159-48339ff65061",
"share": 50
},
{
"user": "b369dabe-b4e0-4787-91a5-b561c98601e5",
"share": 20
}
]
}
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({
title: 'Mavins sabi girl',
type: 'product',
transactionDate: '2023-03-14',
currency: 'USD',
amount: 100,
amountUSD: 100,
id: '77ec1367-be7e-4c3c-a57f-79f6b7349952',
conversionRate: 1,
memo: 'Some memo',
files: {file1: 'file1.pdf', file2: 'file2.pdf'},
split: [
{user: '91f1d1bd-ef25-4990-bd4f-aeee696c73a9', share: 30},
{user: '9ea08acc-e135-4bd9-b159-48339ff65061', share: 50},
{user: 'b369dabe-b4e0-4787-91a5-b561c98601e5', share: 20}
]
})
};
fetch('https://api.royalti.io/expense/', 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.royalti.io/expense/",
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([
'title' => 'Mavins sabi girl',
'type' => 'product',
'transactionDate' => '2023-03-14',
'currency' => 'USD',
'amount' => 100,
'amountUSD' => 100,
'id' => '77ec1367-be7e-4c3c-a57f-79f6b7349952',
'conversionRate' => 1,
'memo' => 'Some memo',
'files' => [
'file1' => 'file1.pdf',
'file2' => 'file2.pdf'
],
'split' => [
[
'user' => '91f1d1bd-ef25-4990-bd4f-aeee696c73a9',
'share' => 30
],
[
'user' => '9ea08acc-e135-4bd9-b159-48339ff65061',
'share' => 50
],
[
'user' => 'b369dabe-b4e0-4787-91a5-b561c98601e5',
'share' => 20
]
]
]),
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.royalti.io/expense/"
payload := strings.NewReader("{\n \"title\": \"Mavins sabi girl\",\n \"type\": \"product\",\n \"transactionDate\": \"2023-03-14\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"amountUSD\": 100,\n \"id\": \"77ec1367-be7e-4c3c-a57f-79f6b7349952\",\n \"conversionRate\": 1,\n \"memo\": \"Some memo\",\n \"files\": {\n \"file1\": \"file1.pdf\",\n \"file2\": \"file2.pdf\"\n },\n \"split\": [\n {\n \"user\": \"91f1d1bd-ef25-4990-bd4f-aeee696c73a9\",\n \"share\": 30\n },\n {\n \"user\": \"9ea08acc-e135-4bd9-b159-48339ff65061\",\n \"share\": 50\n },\n {\n \"user\": \"b369dabe-b4e0-4787-91a5-b561c98601e5\",\n \"share\": 20\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.royalti.io/expense/")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Mavins sabi girl\",\n \"type\": \"product\",\n \"transactionDate\": \"2023-03-14\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"amountUSD\": 100,\n \"id\": \"77ec1367-be7e-4c3c-a57f-79f6b7349952\",\n \"conversionRate\": 1,\n \"memo\": \"Some memo\",\n \"files\": {\n \"file1\": \"file1.pdf\",\n \"file2\": \"file2.pdf\"\n },\n \"split\": [\n {\n \"user\": \"91f1d1bd-ef25-4990-bd4f-aeee696c73a9\",\n \"share\": 30\n },\n {\n \"user\": \"9ea08acc-e135-4bd9-b159-48339ff65061\",\n \"share\": 50\n },\n {\n \"user\": \"b369dabe-b4e0-4787-91a5-b561c98601e5\",\n \"share\": 20\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.royalti.io/expense/")
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 \"title\": \"Mavins sabi girl\",\n \"type\": \"product\",\n \"transactionDate\": \"2023-03-14\",\n \"currency\": \"USD\",\n \"amount\": 100,\n \"amountUSD\": 100,\n \"id\": \"77ec1367-be7e-4c3c-a57f-79f6b7349952\",\n \"conversionRate\": 1,\n \"memo\": \"Some memo\",\n \"files\": {\n \"file1\": \"file1.pdf\",\n \"file2\": \"file2.pdf\"\n },\n \"split\": [\n {\n \"user\": \"91f1d1bd-ef25-4990-bd4f-aeee696c73a9\",\n \"share\": 30\n },\n {\n \"user\": \"9ea08acc-e135-4bd9-b159-48339ff65061\",\n \"share\": 50\n },\n {\n \"user\": \"b369dabe-b4e0-4787-91a5-b561c98601e5\",\n \"share\": 20\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"message": "Expense created successfully",
"expense": {
"id": "expense-uuid-123",
"title": "Mavins sabi girl",
"type": "product",
"amount": 100,
"amountUSD": 100,
"currency": "USD",
"transactionDate": "2023-03-14",
"createdAt": "2023-03-14T10:30:00.000Z",
"updatedAt": "2023-03-14T10:30:00.000Z"
}
}{
"msg": "product does not exist."
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": [
"<string>"
]
}
}This endpoint requires authentication. Include your Bearer token in the Authorization header.
Description
Create Expense Description: The/expense/ endpoint allows creation of expense records with detailed information including type, amount, splits, and associated files.
Method:
POST
Authorization:
- Required role:
adminor higher
| Parameter | Type | Description |
|---|---|---|
| title | string | Title/description of the expense |
| type | string | Type of expense (product, artist, asset, general) |
| transactionDate | string | Date of the expense transaction |
| currency | string | Currency code (e.g., USD, EUR) |
| amount | number | Expense amount in specified currency |
| amountUSD | number | Expense amount converted to USD |
| conversionRate | number | Exchange rate used for conversion |
| id | string | Associated entity ID (product, artist, or asset) |
| memo | string | Additional notes about the expense |
| files | object | Associated files/receipts |
| split | array | Expense split information among users |
Code Examples
const response = await fetch('https://api.royalti.io/expense/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
"title": "sample-title",
"type": "sample-type",
"transactionDate": "2024-01-21",
"currency": "sample-currency",
"amount": 1,
"amountUSD": 1,
"conversionRate": 1,
"id": "sample-id",
"artist": "sample-artist",
"product": "sample-product",
"asset": "sample-asset",
"memo": "sample-memo",
"files": "sample-files",
"split": [
{
"user": "sample-user",
"share": 1
}
]
})
});
const data = await response.json();
console.log(data);
import requests
response = requests.post(
'https://api.royalti.io/expense/',
headers={
'Authorization': f'Bearer {token}'
},
json={"title":"sample-title","type":"sample-type","transactionDate":"2024-01-21","currency":"sample-currency","amount":1,"amountUSD":1,"conversionRate":1,"id":"sample-id","artist":"sample-artist","product":"sample-product","asset":"sample-asset","memo":"sample-memo","files":"sample-files","split":[{"user":"sample-user","share":1}]}
)
data = response.json()
print(data)
curl -X POST https://api.royalti.io/expense/ \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"sample-title","type":"sample-type","transactionDate":"2024-01-21","currency":"sample-currency","amount":1,"amountUSD":1,"conversionRate":1,"id":"sample-id","artist":"sample-artist","product":"sample-product","asset":"sample-asset","memo":"sample-memo","files":"sample-files","split":[{"user":"sample-user","share":1}]}'
Authorizations
JWT Authorization header using the Bearer scheme. Format: "Bearer {token}"
Body
application/json
Title/description of the expense
Type of expense
Available options:
product, artist, asset, general, marketing, production, legal, administrative Date of the expense transaction
Currency code (e.g., USD, EUR)
Expense amount in specified currency
Expense amount converted to USD
Exchange rate used for conversion
Associated entity ID (product, artist, or asset)
Associated artist ID (when type is artist)
Associated product ID (when type is product)
Associated asset ID (when type is asset)
Additional notes about the expense
Associated files/receipts
Expense split information among users
Show child attributes
Show child attributes
⌘I