Create a sale
curl --request POST \
--url https://app.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,
"assistants": [
{
"staff_id": 123,
"duty": "<string>"
}
]
}
],
"appointment_id": 123,
"sale_date": "2023-11-07T05:31:56Z",
"user_id": 123,
"notes": "<string>",
"is_installment_sale": true,
"installments": [
{
"amount": 1.01,
"due_date": "2023-11-07T05:31:56Z",
"description": "<string>"
}
]
}
'import requests
url = "https://app.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,
"assistants": [
{
"staff_id": 123,
"duty": "<string>"
}
]
}
],
"appointment_id": 123,
"sale_date": "2023-11-07T05:31:56Z",
"user_id": 123,
"notes": "<string>",
"is_installment_sale": True,
"installments": [
{
"amount": 1.01,
"due_date": "2023-11-07T05:31:56Z",
"description": "<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,
assistants: [{staff_id: 123, duty: '<string>'}]
}
],
appointment_id: 123,
sale_date: '2023-11-07T05:31:56Z',
user_id: 123,
notes: '<string>',
is_installment_sale: true,
installments: [{amount: 1.01, due_date: '2023-11-07T05:31:56Z', description: '<string>'}]
})
};
fetch('https://app.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://app.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,
'assistants' => [
[
'staff_id' => 123,
'duty' => '<string>'
]
]
]
],
'appointment_id' => 123,
'sale_date' => '2023-11-07T05:31:56Z',
'user_id' => 123,
'notes' => '<string>',
'is_installment_sale' => true,
'installments' => [
[
'amount' => 1.01,
'due_date' => '2023-11-07T05:31:56Z',
'description' => '<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://app.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 \"assistants\": [\n {\n \"staff_id\": 123,\n \"duty\": \"<string>\"\n }\n ]\n }\n ],\n \"appointment_id\": 123,\n \"sale_date\": \"2023-11-07T05:31:56Z\",\n \"user_id\": 123,\n \"notes\": \"<string>\",\n \"is_installment_sale\": true,\n \"installments\": [\n {\n \"amount\": 1.01,\n \"due_date\": \"2023-11-07T05:31:56Z\",\n \"description\": \"<string>\"\n }\n ]\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://app.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 \"assistants\": [\n {\n \"staff_id\": 123,\n \"duty\": \"<string>\"\n }\n ]\n }\n ],\n \"appointment_id\": 123,\n \"sale_date\": \"2023-11-07T05:31:56Z\",\n \"user_id\": 123,\n \"notes\": \"<string>\",\n \"is_installment_sale\": true,\n \"installments\": [\n {\n \"amount\": 1.01,\n \"due_date\": \"2023-11-07T05:31:56Z\",\n \"description\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.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 \"assistants\": [\n {\n \"staff_id\": 123,\n \"duty\": \"<string>\"\n }\n ]\n }\n ],\n \"appointment_id\": 123,\n \"sale_date\": \"2023-11-07T05:31:56Z\",\n \"user_id\": 123,\n \"notes\": \"<string>\",\n \"is_installment_sale\": true,\n \"installments\": [\n {\n \"amount\": 1.01,\n \"due_date\": \"2023-11-07T05:31:56Z\",\n \"description\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"id": 123,
"record_state": {
"is_read_only": true,
"reason_code": "<string>"
},
"tenant_id": 123,
"user_id": 123,
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 123,
"notes": "<string>",
"status": "<string>",
"sale_date": "2023-11-07T05:31:56Z",
"total_price": 123,
"remaining_balance": 123,
"payments": {
"cash": 123,
"credit_card": 123,
"bank_account": 123,
"other": 123,
"total_collected": 123
},
"items": [
{
"order": 123,
"itemable_type": "<string>",
"itemable_id": 123,
"quantity": 123,
"total_price": 123,
"itemable_name": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"default_invoice_account_id": "<string>",
"customer": {
"id": 123,
"record_state": {
"is_read_only": true,
"reason_code": "<string>"
},
"first_name": "<string>",
"last_name": "<string>",
"phone_number": "<string>",
"email": "<string>",
"is_masked": true,
"is_lead_stage": true,
"lead_id": 123
},
"user": {
"id": 123,
"name": "<string>",
"avatar_url": "<string>"
},
"currency": {
"id": 123,
"code": "<string>",
"symbol": "<string>",
"name": "<string>"
},
"import_source": {
"id": 123,
"name": "<string>",
"company_logo": null
}
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"success": false,
"error_code": "CUSTOMER_ERASED",
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"success": false,
"error_code": "SETUP_REQUIRED",
"message": "Complete the required setup steps to continue.",
"data": {
"next_step": "clinic_info"
}
}Satışlar ve teklifler
Create a sale
POST
/
v1
/
sales
Create a sale
curl --request POST \
--url https://app.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,
"assistants": [
{
"staff_id": 123,
"duty": "<string>"
}
]
}
],
"appointment_id": 123,
"sale_date": "2023-11-07T05:31:56Z",
"user_id": 123,
"notes": "<string>",
"is_installment_sale": true,
"installments": [
{
"amount": 1.01,
"due_date": "2023-11-07T05:31:56Z",
"description": "<string>"
}
]
}
'import requests
url = "https://app.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,
"assistants": [
{
"staff_id": 123,
"duty": "<string>"
}
]
}
],
"appointment_id": 123,
"sale_date": "2023-11-07T05:31:56Z",
"user_id": 123,
"notes": "<string>",
"is_installment_sale": True,
"installments": [
{
"amount": 1.01,
"due_date": "2023-11-07T05:31:56Z",
"description": "<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,
assistants: [{staff_id: 123, duty: '<string>'}]
}
],
appointment_id: 123,
sale_date: '2023-11-07T05:31:56Z',
user_id: 123,
notes: '<string>',
is_installment_sale: true,
installments: [{amount: 1.01, due_date: '2023-11-07T05:31:56Z', description: '<string>'}]
})
};
fetch('https://app.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://app.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,
'assistants' => [
[
'staff_id' => 123,
'duty' => '<string>'
]
]
]
],
'appointment_id' => 123,
'sale_date' => '2023-11-07T05:31:56Z',
'user_id' => 123,
'notes' => '<string>',
'is_installment_sale' => true,
'installments' => [
[
'amount' => 1.01,
'due_date' => '2023-11-07T05:31:56Z',
'description' => '<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://app.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 \"assistants\": [\n {\n \"staff_id\": 123,\n \"duty\": \"<string>\"\n }\n ]\n }\n ],\n \"appointment_id\": 123,\n \"sale_date\": \"2023-11-07T05:31:56Z\",\n \"user_id\": 123,\n \"notes\": \"<string>\",\n \"is_installment_sale\": true,\n \"installments\": [\n {\n \"amount\": 1.01,\n \"due_date\": \"2023-11-07T05:31:56Z\",\n \"description\": \"<string>\"\n }\n ]\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://app.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 \"assistants\": [\n {\n \"staff_id\": 123,\n \"duty\": \"<string>\"\n }\n ]\n }\n ],\n \"appointment_id\": 123,\n \"sale_date\": \"2023-11-07T05:31:56Z\",\n \"user_id\": 123,\n \"notes\": \"<string>\",\n \"is_installment_sale\": true,\n \"installments\": [\n {\n \"amount\": 1.01,\n \"due_date\": \"2023-11-07T05:31:56Z\",\n \"description\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.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 \"assistants\": [\n {\n \"staff_id\": 123,\n \"duty\": \"<string>\"\n }\n ]\n }\n ],\n \"appointment_id\": 123,\n \"sale_date\": \"2023-11-07T05:31:56Z\",\n \"user_id\": 123,\n \"notes\": \"<string>\",\n \"is_installment_sale\": true,\n \"installments\": [\n {\n \"amount\": 1.01,\n \"due_date\": \"2023-11-07T05:31:56Z\",\n \"description\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": "<string>",
"data": {
"id": 123,
"record_state": {
"is_read_only": true,
"reason_code": "<string>"
},
"tenant_id": 123,
"user_id": 123,
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 123,
"notes": "<string>",
"status": "<string>",
"sale_date": "2023-11-07T05:31:56Z",
"total_price": 123,
"remaining_balance": 123,
"payments": {
"cash": 123,
"credit_card": 123,
"bank_account": 123,
"other": 123,
"total_collected": 123
},
"items": [
{
"order": 123,
"itemable_type": "<string>",
"itemable_id": 123,
"quantity": 123,
"total_price": 123,
"itemable_name": "<string>"
}
],
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"deleted_at": "2023-11-07T05:31:56Z",
"default_invoice_account_id": "<string>",
"customer": {
"id": 123,
"record_state": {
"is_read_only": true,
"reason_code": "<string>"
},
"first_name": "<string>",
"last_name": "<string>",
"phone_number": "<string>",
"email": "<string>",
"is_masked": true,
"is_lead_stage": true,
"lead_id": 123
},
"user": {
"id": 123,
"name": "<string>",
"avatar_url": "<string>"
},
"currency": {
"id": 123,
"code": "<string>",
"symbol": "<string>",
"name": "<string>"
},
"import_source": {
"id": 123,
"name": "<string>",
"company_logo": null
}
}
}{
"message": "<string>"
}{
"message": "<string>"
}{
"success": false,
"error_code": "CUSTOMER_ERASED",
"message": "<string>"
}{
"message": "<string>",
"errors": {}
}{
"success": false,
"error_code": "SETUP_REQUIRED",
"message": "Complete the required setup steps to continue.",
"data": {
"next_step": "clinic_info"
}
}Yetkilendirmeler
oauth2bearer
The access token received from the authorization server in the OAuth 2.0 flow.
Başlıklar
Tenant identifier. Send the Tenant ID in the X-Tenant header to scope API requests to a specific tenant.
Gövde
application/json
Customer ID.
Currency ID.
Exchange rate (e.g. 1 or 34.5).
Gerekli aralık:
x >= 0Sale status: draft, completed, cancelled, invoiced, pending.
Mevcut seçenekler:
draft, completed, cancelled, invoiced, pending Sale line items. At least one item required.
Minimum array length:
1Show child attributes
Show child attributes
Related appointment ID (optional). Must belong to current tenant and the provided customer.
When the sale happened. Defaults to now when omitted. A naive value is read in the tenant timezone.
User ID (optional, defaults to authenticated user).
Notes (optional).
Maximum string length:
65535Whether this sale is paid in installments.
Installment plan rows. Required when is_installment_sale is true.
Minimum array length:
1Show child attributes
Show child attributes