Sales
Create a sale
POST
/
v1
/
sales
Create a sale
curl --request POST \
--url https://dev.flextell.ai/api/v1/sales \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"customer_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"items": [
{
"staff_id": 123,
"itemable_id": 2,
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"sub_total": 1,
"total_discount": 1,
"total_tax": 1,
"total_price": 1,
"cost_price": 1,
"warehouse_id": 123,
"order": 1
}
],
"appointment_id": 123,
"user_id": 123,
"notes": "<string>"
}
'import requests
url = "https://dev.flextell.ai/api/v1/sales"
payload = {
"customer_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"items": [
{
"staff_id": 123,
"itemable_id": 2,
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"sub_total": 1,
"total_discount": 1,
"total_tax": 1,
"total_price": 1,
"cost_price": 1,
"warehouse_id": 123,
"order": 1
}
],
"appointment_id": 123,
"user_id": 123,
"notes": "<string>"
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
customer_id: 123,
currency_id: 123,
exchange_rate: 1,
items: [
{
staff_id: 123,
itemable_id: 2,
quantity: 1.0001,
unit_price: 1,
discount_amount: 1,
discount_percentage: 50,
sub_total: 1,
total_discount: 1,
total_tax: 1,
total_price: 1,
cost_price: 1,
warehouse_id: 123,
order: 1
}
],
appointment_id: 123,
user_id: 123,
notes: '<string>'
})
};
fetch('https://dev.flextell.ai/api/v1/sales', 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://dev.flextell.ai/api/v1/sales",
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([
'customer_id' => 123,
'currency_id' => 123,
'exchange_rate' => 1,
'items' => [
[
'staff_id' => 123,
'itemable_id' => 2,
'quantity' => 1.0001,
'unit_price' => 1,
'discount_amount' => 1,
'discount_percentage' => 50,
'sub_total' => 1,
'total_discount' => 1,
'total_tax' => 1,
'total_price' => 1,
'cost_price' => 1,
'warehouse_id' => 123,
'order' => 1
]
],
'appointment_id' => 123,
'user_id' => 123,
'notes' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$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://dev.flextell.ai/api/v1/sales"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"items\": [\n {\n \"staff_id\": 123,\n \"itemable_id\": 2,\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"sub_total\": 1,\n \"total_discount\": 1,\n \"total_tax\": 1,\n \"total_price\": 1,\n \"cost_price\": 1,\n \"warehouse_id\": 123,\n \"order\": 1\n }\n ],\n \"appointment_id\": 123,\n \"user_id\": 123,\n \"notes\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
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://dev.flextell.ai/api/v1/sales")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"items\": [\n {\n \"staff_id\": 123,\n \"itemable_id\": 2,\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"sub_total\": 1,\n \"total_discount\": 1,\n \"total_tax\": 1,\n \"total_price\": 1,\n \"cost_price\": 1,\n \"warehouse_id\": 123,\n \"order\": 1\n }\n ],\n \"appointment_id\": 123,\n \"user_id\": 123,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev.flextell.ai/api/v1/sales")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"items\": [\n {\n \"staff_id\": 123,\n \"itemable_id\": 2,\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"sub_total\": 1,\n \"total_discount\": 1,\n \"total_tax\": 1,\n \"total_price\": 1,\n \"cost_price\": 1,\n \"warehouse_id\": 123,\n \"order\": 1\n }\n ],\n \"appointment_id\": 123,\n \"user_id\": 123,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"id": 123,
"tenant_id": 123,
"user_id": 123,
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 123,
"notes": "<string>",
"status": "<string>",
"total_price": 123,
"remaining_balance": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"customer": {
"id": 123,
"first_name": "<string>",
"last_name": "<string>",
"phone_number": "<string>",
"email": "<string>"
},
"user": {
"id": 123,
"name": "<string>"
},
"currency": {
"id": 123,
"code": "<string>",
"symbol": "<string>",
"name": "<string>"
},
"items": [
{
"id": 123,
"sale_id": 123,
"staff_id": 123,
"order": 123,
"itemable_type": "<string>",
"itemable_id": 123,
"warehouse_id": 123,
"quantity": 123,
"tax_rate": 123,
"unit_price": 123,
"cost_price": 123,
"discount_amount": 123,
"discount_percentage": 123,
"sub_total": 123,
"total_discount": 123,
"total_tax": 123,
"total_price": 123,
"staff": {
"id": 123,
"name": "<string>"
},
"itemable": {
"id": "<string>",
"name": "<string>"
}
}
]
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}Authorizations
oauth2bearer
The access token received from the authorization server in the OAuth 2.0 flow.
Headers
Tenant identifier. Send the Tenant ID in the X-Tenant header to scope API requests to a specific tenant.
Body
application/json
Filter by customer ID.
Filter by currency ID.
Currency exchange rate.
Required range:
x >= 0Filter by status.
Available options:
draft, completed, cancelled, invoiced, pending List of items.
Minimum array length:
1Show child attributes
Show child attributes
The appointment ID.
Filter by user ID.
Internal notes.
Maximum string length:
65535⌘I
Create a sale
curl --request POST \
--url https://dev.flextell.ai/api/v1/sales \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"customer_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"items": [
{
"staff_id": 123,
"itemable_id": 2,
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"sub_total": 1,
"total_discount": 1,
"total_tax": 1,
"total_price": 1,
"cost_price": 1,
"warehouse_id": 123,
"order": 1
}
],
"appointment_id": 123,
"user_id": 123,
"notes": "<string>"
}
'import requests
url = "https://dev.flextell.ai/api/v1/sales"
payload = {
"customer_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"items": [
{
"staff_id": 123,
"itemable_id": 2,
"quantity": 1.0001,
"unit_price": 1,
"discount_amount": 1,
"discount_percentage": 50,
"sub_total": 1,
"total_discount": 1,
"total_tax": 1,
"total_price": 1,
"cost_price": 1,
"warehouse_id": 123,
"order": 1
}
],
"appointment_id": 123,
"user_id": 123,
"notes": "<string>"
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
customer_id: 123,
currency_id: 123,
exchange_rate: 1,
items: [
{
staff_id: 123,
itemable_id: 2,
quantity: 1.0001,
unit_price: 1,
discount_amount: 1,
discount_percentage: 50,
sub_total: 1,
total_discount: 1,
total_tax: 1,
total_price: 1,
cost_price: 1,
warehouse_id: 123,
order: 1
}
],
appointment_id: 123,
user_id: 123,
notes: '<string>'
})
};
fetch('https://dev.flextell.ai/api/v1/sales', 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://dev.flextell.ai/api/v1/sales",
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([
'customer_id' => 123,
'currency_id' => 123,
'exchange_rate' => 1,
'items' => [
[
'staff_id' => 123,
'itemable_id' => 2,
'quantity' => 1.0001,
'unit_price' => 1,
'discount_amount' => 1,
'discount_percentage' => 50,
'sub_total' => 1,
'total_discount' => 1,
'total_tax' => 1,
'total_price' => 1,
'cost_price' => 1,
'warehouse_id' => 123,
'order' => 1
]
],
'appointment_id' => 123,
'user_id' => 123,
'notes' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Tenant: <x-tenant>"
],
]);
$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://dev.flextell.ai/api/v1/sales"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"items\": [\n {\n \"staff_id\": 123,\n \"itemable_id\": 2,\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"sub_total\": 1,\n \"total_discount\": 1,\n \"total_tax\": 1,\n \"total_price\": 1,\n \"cost_price\": 1,\n \"warehouse_id\": 123,\n \"order\": 1\n }\n ],\n \"appointment_id\": 123,\n \"user_id\": 123,\n \"notes\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Tenant", "<x-tenant>")
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://dev.flextell.ai/api/v1/sales")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"items\": [\n {\n \"staff_id\": 123,\n \"itemable_id\": 2,\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"sub_total\": 1,\n \"total_discount\": 1,\n \"total_tax\": 1,\n \"total_price\": 1,\n \"cost_price\": 1,\n \"warehouse_id\": 123,\n \"order\": 1\n }\n ],\n \"appointment_id\": 123,\n \"user_id\": 123,\n \"notes\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev.flextell.ai/api/v1/sales")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"items\": [\n {\n \"staff_id\": 123,\n \"itemable_id\": 2,\n \"quantity\": 1.0001,\n \"unit_price\": 1,\n \"discount_amount\": 1,\n \"discount_percentage\": 50,\n \"sub_total\": 1,\n \"total_discount\": 1,\n \"total_tax\": 1,\n \"total_price\": 1,\n \"cost_price\": 1,\n \"warehouse_id\": 123,\n \"order\": 1\n }\n ],\n \"appointment_id\": 123,\n \"user_id\": 123,\n \"notes\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"id": 123,
"tenant_id": 123,
"user_id": 123,
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 123,
"notes": "<string>",
"status": "<string>",
"total_price": 123,
"remaining_balance": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"customer": {
"id": 123,
"first_name": "<string>",
"last_name": "<string>",
"phone_number": "<string>",
"email": "<string>"
},
"user": {
"id": 123,
"name": "<string>"
},
"currency": {
"id": 123,
"code": "<string>",
"symbol": "<string>",
"name": "<string>"
},
"items": [
{
"id": 123,
"sale_id": 123,
"staff_id": 123,
"order": 123,
"itemable_type": "<string>",
"itemable_id": 123,
"warehouse_id": 123,
"quantity": 123,
"tax_rate": 123,
"unit_price": 123,
"cost_price": 123,
"discount_amount": 123,
"discount_percentage": 123,
"sub_total": 123,
"total_discount": 123,
"total_tax": 123,
"total_price": 123,
"staff": {
"id": 123,
"name": "<string>"
},
"itemable": {
"id": "<string>",
"name": "<string>"
}
}
]
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}