API-документация
YOUR_API_KEY — этот текст следует заменить на ваш ключ API
Пример 1. Получение списка документов или информации о документе:
// ************ Python code Example:
import requests
import json
# Prepare data
data = {
"action": "get",
"ids": "", # Идентификатор документаs separated by commas (if empty — all documents)
"status": "", # Filter by document statuses (возможные значения — new, sent, revoked, completed)
"object": "invoice"
}
# Prepare request
url = 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/'
headers = {'Content-Type': 'application/json'}
post_data = {'data': json.dumps(data)}
# Send POST request
response = requests.post(url, headers=headers, data=post_data)
# Handle response
if response.status_code == 200:
try:
result = response.json()
print(json.dumps(result, indent=4, ensure_ascii=False))
except json.JSONDecodeОшибка:
print("Ошибка parsing JSON response:")
print(response.text)
else:
print(f"Ошибка: {response.status_code}")
print(response.text)
// ************ PHP code Example:
$data = <<<JSON
{
"action": "get",
"ids": "",
"status": "",
"object": "invoice"
}
JSON;
// ids — идентификатор документа, разделенный запятыми (если параметр пропущен, то все документы)
// status — фильтр по статусам документов (возможные значения - new, sent, revoked, completed)
$post = array(
'data' => $data,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response,true);
print_r($result);
// Пример возвращаемых данных:
{
"status": "OK",
"documents": [
{
"id": "101324",
"savetime": "1745532856",
"transfer_type": "swift",
"payagent": "1",
"amount": "19200.00",
"currency": "EUR",
"description": "Payment for container delivery services",
"status": "revoked",
"from": {
"accounttype": "Legal entity",
"name": "QWERTY NETWORKS D.O.O.",
"tax_id": "PIB 03173232",
"country_code": "ME",
"bank": {
"name": "CRNOGORSKA KOMERCIJALNA BANKA AD PODGORICA",
"bicswift": "CKBCMEPGXXX",
"account": "ME25510000000012106125"
}
},
"to": {
"accounttype": "Legal entity",
"name": "Test Company",
"tax_id": "12345678",
"country_code": "CZ",
"bank": {
"name": "Test Bank",
"bicswift": "3746283674782",
"account": "21847623846723846237"
}
}
},
{
"id": "101325",
"savetime": "1745532878",
"transfer_type": "swift",
"payagent": "1",
"amount": "25000.00",
"currency": "EUR",
"description": "Payment for container delivery services",
"status": "new",
"from": {
"accounttype": "Legal entity",
"name": "QWERTY NETWORKS D.O.O.",
"tax_id": "PIB 03173232",
"country_code": "ME",
"bank": {
"name": "CRNOGORSKA KOMERCIJALNA BANKA AD PODGORICA",
"bicswift": "CKBCMEPGXXX",
"account": "ME25510000000012106125"
}
},
"to": {
"accounttype": "Legal entity",
"name": "Test Company",
"tax_id": "12345678",
"country_code": "CZ",
"bank": {
"name": "Test Bank",
"bicswift": "3746283674782",
"account": "21847623846723846237"
}
}
},
{
"id": "101326",
"savetime": "1746720335",
"transfer_type": "internal",
"payagent": "1",
"amount": "34.00",
"currency": "EUR",
"description": "Nice green grass",
"status": "new",
"from": {
"accounttype": "Physical person",
"name": "John Week",
"tax_id": "",
"country_code": "TR",
"bank": {
"name": "Aktif Yatırım Bankası A.Ş.",
"bicswift": "CAYTTRIS",
"account": "TR 4700 0100 9010 0574 2710 4505 "
}
},
"to": {
"accounttype": "Physical person",
"name": "Peter Pen",
"tax_id": "",
"country_code": "NL",
"bank": {
"name": "ING Bank N.V.",
"bicswift": "INGBNL2A",
"account": "NL 1234 5457 4455 1874 1210 3245 "
}
}
},
{
"id": "101327",
"savetime": "1746720421",
"transfer_type": "swift",
"payagent": "1",
"amount": "256.65",
"currency": "TRY",
"description": "Cep telefonu rebate",
"status": "completed",
"from": {
"accounttype": "Physical person",
"name": "John Week",
"tax_id": "",
"country_code": "TR",
"bank": {
"name": "Ziraat Bankası A.Ş.",
"bicswift": "TCZBTR2A",
"account": "TR 5800 0100 9010 1874 1210 7001 "
}
},
"to": {
"accounttype": "Legal entity",
"name": "TURKCELL",
"tax_id": "1234567890",
"country_code": "TR",
"bank": {
"name": "Türkiye İş Bankası A.Ş.",
"bicswift": " ISBKTRIS",
"account": "TR 5800 0100 9010 1334 1360 5001 "
}
}
}
]
}
Пример 2. Создание нового документа.
// IMPORTANT! Before using the API, the client must create
// a directory of their own bank details, as well as
// a directory of counterparties’ details, in the
// «Settings» section at the following address:
// https://ps.anahatholding.com/u_settings
// ************ Python code Example:
import requests
import json
# Prepare data
data = {
"action": "new", # Action type: "new" — creating a new document
"object": "invoice", # Document type: "invoice" or "payorder"
"from": 1742, # Идентификатор ваших собственных банковских реквизитов (из настроек)
"to": 9677, # Идентификатор банковских реквизитов получателя (из настроек)
"payagent": 1, # Идентификатор платежного агента
"amount": 100000, # Document amount
"currency": "USD", # Document currency
"description": "Payment by invoice for IT services" # Payment description
}
# Prepare request
url = 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/'
headers = {'Content-Type': 'application/json'}
post_data = {'data': json.dumps(data)}
# Send POST request
response = requests.post(url, headers=headers, data=post_data)
# Handle response
if response.status_code == 200:
try:
result = response.json()
print(json.dumps(result, indent=4, ensure_ascii=False))
except json.JSONDecodeОшибка:
print("Ошибка parsing JSON response:")
print(response.text)
else:
print(f"Ошибка: {response.status_code}")
print(response.text)
// ************ PHP code Example:
$data = <<<JSON
{
"action": "new",
"object": "invoice",
"from": 1742,
"to": 9677,
"payagent": 1,
"amount": 100000,
"currency": "USD",
"description": "Payment by invoice for IT services"
}
JSON;
// object — Тип создаваемого документа. Возможные значения: "invoice", "payorder".
// from — Идентификатор ваших собственных банковских реквизитов (из настроек)
// to — Идентификатор банковских реквизитов получателя (из настроек)
// payagent — Идентификатор платежного агента
// amount — сумма документа
// currency — валюта документа
// description — описание платежа
$post = array(
'data' => $data,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response,true);
print_r($result);
// Пример возвращаемых данных:
//
// ["status": "OK", "id": 926632 ]
//
// Если сохранение прошло успешно, система вернет идентификатор нового документа.
Пример 3. Отзыв документа:
// ************ Python code Example:
import requests
import json
# Prepare data
data = {
"action": "revoke", # Action type: "revoke" — revoking a document
"object": "invoice", # Document type: "invoice" or "payorder"
"id": 711 # Идентификатор документа to be revoked
}
# Prepare request
url = 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/'
headers = {'Content-Type': 'application/json'}
post_data = {'data': json.dumps(data)}
# Send POST request
response = requests.post(url, headers=headers, data=post_data)
# Handle response
if response.status_code == 200:
try:
result = response.json()
print(json.dumps(result, indent=4, ensure_ascii=False))
except json.JSONDecodeОшибка:
print("Ошибка parsing JSON response:")
print(response.text)
else:
print(f"Ошибка: {response.status_code}")
print(response.text)
// ************ PHP code Example:
$data = <<<JSON
{
"action": "revoke",
"object": "invoice",
"id": 711
}
JSON;
// object — Тип создаваемого документа. Возможные значения: "invoice", "payorder".
// id — Идентификатор документа
$post = array(
'data' => $data,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response,true);
print_r($result);
// Пример возвращаемых данных:
//
// В случае успеха: ["status": "OK" ]
//
// В случае ошибки: ["status": "ERROR", "type": "invoice", "descr": "Описание ошибки" ]
Пример 4. Отправка документа на обработку:
// ************ Python code Example:
import requests
import json
# Prepare data
data = {
"action": "sent", # Action type: "sent" — mark document as sent
"object": "invoice", # Document type: "invoice" or "payorder"
"id": 711 # Идентификатор документа to be marked as sent
}
# Prepare request
url = 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/'
headers = {'Content-Type': 'application/json'}
post_data = {'data': json.dumps(data)}
# Send POST request
response = requests.post(url, headers=headers, data=post_data)
# Handle response
if response.status_code == 200:
try:
result = response.json()
print(json.dumps(result, indent=4, ensure_ascii=False))
except json.JSONDecodeОшибка:
print("Ошибка parsing JSON response:")
print(response.text)
else:
print(f"Ошибка: {response.status_code}")
print(response.text)
// ************ PHP code Example:
$data = <<<JSON
{
"action": "sent",
"object": "invoice",
"id": 711
}
JSON;
// object — Тип создаваемого документа. Возможные значения: "invoice", "payorder".
// id — Идентификатор документа
$post = array(
'data' => $data,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response,true);
print_r($result);
// Пример возвращаемых данных:
//
// В случае успеха: ["status": "OK" ]
//
// В случае ошибки: ["status": "ERROR", "type": "invoice", "descr": "Описание ошибки" ]
Пример 5. Подтверждение исполнения документа:
// ************ Python code Example:
import requests
import json
# Prepare data
data = {
"action": "done", # Action type: "done" — mark document as completed
"object": "invoice", # Document type: "invoice" or "payorder"
"id": 711 # Идентификатор документа to be marked as completed
}
# Prepare request
url = 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/'
headers = {'Content-Type': 'application/json'}
post_data = {'data': json.dumps(data)}
# Send POST request
response = requests.post(url, headers=headers, data=post_data)
# Handle response
if response.status_code == 200:
try:
result = response.json()
print(json.dumps(result, indent=4, ensure_ascii=False))
except json.JSONDecodeОшибка:
print("Ошибка parsing JSON response:")
print(response.text)
else:
print(f"Ошибка: {response.status_code}")
print(response.text)
// ************ PHP code Example:
$data = <<<JSON
{
"action": "done",
"object": "invoice",
"id": 711
}
JSON;
// object — Тип создаваемого документа. Возможные значения: "invoice", "payorder".
// id — Идентификатор документа
$post = array(
'data' => $data,
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://demo.sorbi.ai/userapi/ps/YOUR_API_KEY/');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response,true);
print_r($result);
// Пример возвращаемых данных:
//
// В случае успеха: ["status": "OK" ]
//
// В случае ошибки: ["status": "ERROR", "type": "invoice", "descr": "Описание ошибки" ]