Sales
Update a sale
PUT
/
v1
/
sales
/
{id}
Update a sale
curl --request PUT \
--url https://dev.flextell.ai/api/v1/sales/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"user_id": 123,
"notes": "<string>",
"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
}
]
}
'import requests
url = "https://dev.flextell.ai/api/v1/sales/{id}"
payload = {
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"user_id": 123,
"notes": "<string>",
"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
}
]
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
customer_id: 123,
appointment_id: 123,
currency_id: 123,
exchange_rate: 1,
user_id: 123,
notes: '<string>',
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
}
]
})
};
fetch('https://dev.flextell.ai/api/v1/sales/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => 123,
'appointment_id' => 123,
'currency_id' => 123,
'exchange_rate' => 1,
'user_id' => 123,
'notes' => '<string>',
'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
]
]
]),
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/{id}"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"appointment_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"user_id\": 123,\n \"notes\": \"<string>\",\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}")
req, _ := http.NewRequest("PUT", 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.put("https://dev.flextell.ai/api/v1/sales/{id}")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"appointment_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"user_id\": 123,\n \"notes\": \"<string>\",\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}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev.flextell.ai/api/v1/sales/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 123,\n \"appointment_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"user_id\": 123,\n \"notes\": \"<string>\",\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}"
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>"
}{
"success": true,
"error": "<string>",
"data": {
"message": "<string>"
},
"errors": null
}{
"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.
Path Parameters
The sale identifier
Body
application/json
Filter by customer ID.
The appointment ID.
Filter by currency ID.
Currency exchange rate.
Required range:
x >= 0Filter by status.
Available options:
draft, completed, cancelled, invoiced, pending Filter by user ID.
Internal notes.
Maximum string length:
65535List of items.
Minimum array length:
1Show child attributes
Show child attributes
⌘I
Update a sale
curl --request PUT \
--url https://dev.flextell.ai/api/v1/sales/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Tenant: <x-tenant>' \
--data '
{
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"user_id": 123,
"notes": "<string>",
"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
}
]
}
'import requests
url = "https://dev.flextell.ai/api/v1/sales/{id}"
payload = {
"customer_id": 123,
"appointment_id": 123,
"currency_id": 123,
"exchange_rate": 1,
"user_id": 123,
"notes": "<string>",
"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
}
]
}
headers = {
"X-Tenant": "<x-tenant>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {
'X-Tenant': '<x-tenant>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
customer_id: 123,
appointment_id: 123,
currency_id: 123,
exchange_rate: 1,
user_id: 123,
notes: '<string>',
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
}
]
})
};
fetch('https://dev.flextell.ai/api/v1/sales/{id}', 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/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'customer_id' => 123,
'appointment_id' => 123,
'currency_id' => 123,
'exchange_rate' => 1,
'user_id' => 123,
'notes' => '<string>',
'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
]
]
]),
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/{id}"
payload := strings.NewReader("{\n \"customer_id\": 123,\n \"appointment_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"user_id\": 123,\n \"notes\": \"<string>\",\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}")
req, _ := http.NewRequest("PUT", 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.put("https://dev.flextell.ai/api/v1/sales/{id}")
.header("X-Tenant", "<x-tenant>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"customer_id\": 123,\n \"appointment_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"user_id\": 123,\n \"notes\": \"<string>\",\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}")
.asString();require 'uri'
require 'net/http'
url = URI("https://dev.flextell.ai/api/v1/sales/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-Tenant"] = '<x-tenant>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"customer_id\": 123,\n \"appointment_id\": 123,\n \"currency_id\": 123,\n \"exchange_rate\": 1,\n \"user_id\": 123,\n \"notes\": \"<string>\",\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}"
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>"
}{
"success": true,
"error": "<string>",
"data": {
"message": "<string>"
},
"errors": null
}{
"message": "<string>",
"errors": {}
}