Update-Invoice
This API is used to update merchant’s invoice By providing correct/required request data/fields with the correct access token, merchant user will be able to update invoice.
Status Description 1 - Draft 2 - Unpaid 3 - Paid 4 - Overdue 5 - Cancelled
sentviaId Description 1 - None 2 - Whatsapp 3 - Email 4 - SMS
- PATCH
Sandbox
https://api-sandbox.sadad.qa/api/invoices/updateInvoice
Live
https://api-s.sadad.qa/api/invoices/updateInvoice
Permission: Merchant
- Curl
- Ruby
- Python
- PHP
- Java
- Node.js
- Go
- .NET
curl -d "@data.json" -H "Content-Type: application/json" -H "Authorization: {ACCESS_TOKEN}" -X PATCH https://api-s.sadad.qa/api/invoices/updateInvoice
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("https://api-s.sadad.qa/api/invoices/updateInvoice")
request = Net::HTTP::Patch.new(uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "{ACCESS_TOKEN}"
request.body = File.read("data.json")
req_options = {
use_ssl: uri.scheme == "https",
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
puts response.body
import requests
url = "https://api-s.sadad.qa/api/invoices/updateInvoice"
headers = {
"Content-Type": "application/json",
"Authorization": "{ACCESS_TOKEN}"
}
with open("data.json") as f:
data = f.read()
response = requests.patch(url, headers=headers, data=data)
print(response.text)
<?php
$url = "https://api-s.sadad.qa/api/invoices/updateInvoice";
$data = file_get_contents("data.json");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: {ACCESS_TOKEN}"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
import java.nio.file.Path;
public class SadadAPI {
public static void main(String[] args) throws Exception {
String body = Files.readString(Path.of("data.json"));
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://api-s.sadad.qa/api/invoices/updateInvoice"))
.header("Content-Type", "application/json")
.header("Authorization", "{ACCESS_TOKEN}")
.method("PATCH", HttpRequest.BodyPublishers.ofString(body))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response =
client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
const fs = require("fs");
const fetch = require("node-fetch");
const url = "https://api-s.sadad.qa/api/invoices/updateInvoice";
const data = fs.readFileSync("data.json", "utf8");
fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
"Authorization": "{ACCESS_TOKEN}"
},
body: data
})
.then(res => res.text())
.then(data => console.log(data))
.catch(err => console.error(err));
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
data, _ := ioutil.ReadFile("data.json")
req, _ := http.NewRequest("PATCH", "https://api-s.sadad.qa/api/invoices/updateInvoice", bytes.NewBuffer(data))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "{ACCESS_TOKEN}")
client := &http.Client{}
resp, _ := client.Do(req)
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}
using System;
using System.Net.Http;
using System.Text;
using System.IO;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "{ACCESS_TOKEN}");
var json = File.ReadAllText("data.json");
var request = new HttpRequestMessage(new HttpMethod("PATCH"),
"https://api-s.sadad.qa/api/invoices/updateInvoice")
{
Content = new StringContent(json, Encoding.UTF8, "application/json")
};
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
}
}
Header
| Field | Type | Description |
|---|---|---|
| Authorization | String | User's unique access-token |
- Header-Example:
{
"Authorization": "BN79o6YNrY4IPP60UF4JmNEM6O8hX9HVUq0e0HWNyo2tt1jqCT9IWnXSBhfr7Mws"
}
Parameter
| Field | Type | Description |
|---|---|---|
| id | Number | Id of the invoice to update |
| clientname | String | Name of thee client on invoice |
| status (optional) | Number | Status of invoice |
| remarks (optional) | String | Remarks of invoice |
| amount (optional) | Number | Amount of invoice |
| invoicedetails (optional) | ArrayObject | Invoice is read or not |
- Request-Example:
{
"clientname": "test test",
"invoicedetails": [
{
"description": "invoice test 3",
"quantity": 3,
"amount": 10,
"invoiceId": 8888
}
],
"amount": 15,
"id": 8888
}
Success 200
| Field | Type | Description |
|---|---|---|
| count | Number | Indicates number of updated items. |
- Success-Response:
{
"count": 1
}
Error 4xx
| Name | Description |
|---|---|
| 401 | Authorization Required |
| 400 | Invalid data |
| 404 | Data not found |
- Response (example):
{
"error": {
"statusCode": 401,
"name": "Error",
"message": "Authorization Required"
}
}