Skip to content

AI voice assistant, PBX and messaging in one dashboard.Explore services

SocialRoute
Get a Quote
Developers

Connect Your Own Software

46 endpoints for customer profiles, tickets, calls, payments and verification codes, all called with a private API key. When something happens on the platform, an event is sent to your server.

Getting started

Authentication, Limits and Errors

The endpoints and examples on this page are generated from the API's own schema; when the code changes, the documentation changes with it.

Authentication

Create a private key on the API keys page of the dashboard and send it in the Authorization header of every request. The full key is shown only when it's created.

A key belongs to one organization and works with member permissions: it sees and changes only that organization's data. Admin tasks such as managing members and keys or deleting, and actions that need confirmation in the dashboard, can't be done with a key.

Limits

60 requests a minute per organization (default). Past that, the API returns 429; try again in a minute.

Some endpoints have their own limits too: a verification code goes to the same number once every 30 seconds and at most 5 times an hour; saying a sentence or adding a note in a call in progress is 20 requests a minute per organization.

Errors

Error responses are JSON, and the detail field says the cause and what to do.

401
The key is invalid or has been revoked.
403
This can't be done with a key: admin tasks and actions that need confirmation in the dashboard are done only in the dashboard.
404
The record doesn't exist or belongs to another organization.
409
Conflict: the record changed after you read it, or the same record already exists.
422
The data sent is invalid; detail says which field wasn't accepted and why.
429
The request limit was exceeded; try again in a minute.

A first request: the profile of the number that's calling

curl "https://socialroute.tr/api/contacts/by-number/05321112233" \
  -H "Authorization: Bearer sa_..."
  • Request and response bodies are JSON; times are ISO 8601 in UTC.
  • Phone numbers can be sent in any usual format (0532 111 22 33, +905321112233); responses always start them with +90.
  • When you update a ticket, send the revision you read; if the record changed in the meantime, the API returns 409 and nothing is written.
  • Amounts are in minor units (1/100 of a lira): 125000 is 1,250.00 TRY.
Endpoints

Endpoints You Can Call With an API Key

Replace <…_id> in the examples with the record's ID. Query parameters that aren't required can be left out.

Contacts

Customer profiles in your contacts. A phone number has one profile; everyone who calls is added automatically.

GET/api/contacts

List and search profiles

Parameters

FieldInTypeRequired
qquerystringNo
limitqueryintegerNo
offsetqueryintegerNo

curl

curl "https://socialroute.tr/api/contacts?q=Elif" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

POST/api/contacts

Create a profile

Request body (JSON)

FieldTypeRequired
numberstringYes
namestring · 0…160No
companystring · 0…160No
emailstring · 0…254No
codestring · 1…60No
tagsstring[]No
custom_fieldsobjectNo

Example body

{
  "number": "0532 111 22 33",
  "name": "Elif Kaya",
  "company": "Kaya Travel",
  "email": "elif@example.com",
  "code": "M-1001",
  "tags": [
    "vip"
  ]
}

curl

curl -X POST "https://socialroute.tr/api/contacts" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"number": "0532 111 22 33", "name": "Elif Kaya", "company": "Kaya Travel", "email": "elif@example.com", "code": "M-1001", "tags": ["vip"]}'

Documented responses: 201, 422

GET/api/contacts/by-number/{number}

Find a profile by phone number

Parameters

FieldInTypeRequired
numberpathstringYes

curl

curl "https://socialroute.tr/api/contacts/by-number/<number>" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/contacts/{contact_id}

Read a profile and its history

Parameters

FieldInTypeRequired
contact_idpathstring (uuid)Yes

curl

curl "https://socialroute.tr/api/contacts/<contact_id>" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

PUT/api/contacts/{contact_id}

Update a profile

Parameters

FieldInTypeRequired
contact_idpathstring (uuid)Yes

Request body (JSON)

FieldTypeRequired
numberstringYes
namestring · 0…160No
companystring · 0…160No
emailstring · 0…254No
codestring · 1…60No
tagsstring[]No
custom_fieldsobjectNo

Example body

{
  "number": "0532 111 22 33",
  "name": "Elif Kaya",
  "company": "Kaya Travel",
  "email": "elif@example.com",
  "code": "M-1001",
  "tags": [
    "vip",
    "visa"
  ]
}

curl

curl -X PUT "https://socialroute.tr/api/contacts/<contact_id>" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"number": "0532 111 22 33", "name": "Elif Kaya", "company": "Kaya Travel", "email": "elif@example.com", "code": "M-1001", "tags": ["vip", "visa"]}'

Documented responses: 200, 422

POST/api/contacts/{contact_id}/notes

Add a note to a profile

Parameters

FieldInTypeRequired
contact_idpathstring (uuid)Yes

Request body (JSON)

FieldTypeRequired
textstring · 1…2000Yes

Example body

{
  "text": "Call back on Friday."
}

curl

curl -X POST "https://socialroute.tr/api/contacts/<contact_id>/notes" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"text": "Call back on Friday."}'

Documented responses: 201, 422

DELETE/api/contacts/{contact_id}/notes/{note_id}

Delete a note

Parameters

FieldInTypeRequired
contact_idpathstring (uuid)Yes
note_idpathstring (uuid)Yes

curl

curl -X DELETE "https://socialroute.tr/api/contacts/<contact_id>/notes/<note_id>" \
  -H "Authorization: Bearer sa_..."

Documented responses: 204, 422

POST/api/contacts/{contact_id}/kimlikler

Add another number or email to a profile

Parameters

FieldInTypeRequired
contact_idpathstring (uuid)Yes

Request body (JSON)

FieldTypeRequired
tur"telefon" | "eposta"Yes
degerstring · 1…254Yes

Example body

{
  "tur": "telefon",
  "deger": "0533 444 55 66"
}

curl

curl -X POST "https://socialroute.tr/api/contacts/<contact_id>/kimlikler" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"tur": "telefon", "deger": "0533 444 55 66"}'

Documented responses: 201, 422

DELETE/api/contacts/{contact_id}/kimlikler/{kimlik_id}

Remove a number or email from a profile

Parameters

FieldInTypeRequired
contact_idpathstring (uuid)Yes
kimlik_idpathstring (uuid)Yes

curl

curl -X DELETE "https://socialroute.tr/api/contacts/<contact_id>/kimlikler/<kimlik_id>" \
  -H "Authorization: Bearer sa_..."

Documented responses: 204, 422

Tickets

What a customer asked for and who is handling it. Send the revision you read when you change one.

GET/api/tickets

List tickets

Parameters

FieldInTypeRequired
statusquerystringNo
assigneequerystringNo
contact_idquerystring (uuid)No
qquerystringNo
latequerybooleanNo
sourcequerystringNo
limitqueryintegerNo
offsetqueryintegerNo

curl

curl "https://socialroute.tr/api/tickets?status=open&late=true" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

POST/api/tickets

Open a ticket

Request body (JSON)

FieldTypeRequired
titlestring · 1…200Yes
descriptionstring · 0…10000No
priority"low" | "normal" | "high" | "urgent"No
customer_numberstringNo
contact_idstring (uuid)No
assignee_user_idstring (uuid)No
tagsstring[]No
due_atstring (date-time)No
source"pazaryeri" | "sosyal"No

Example body

{
  "title": "Passport pickup",
  "description": "Will collect it from the office on Friday.",
  "priority": "high",
  "customer_number": "0532 111 22 33",
  "tags": [
    "visa"
  ],
  "due_at": "2026-11-20T09:00:00Z"
}

curl

curl -X POST "https://socialroute.tr/api/tickets" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"title": "Passport pickup", "description": "Will collect it from the office on Friday.", "priority": "high", "customer_number": "0532 111 22 33", "tags": ["visa"], "due_at": "2026-11-20T09:00:00Z"}'

Documented responses: 201, 422

GET/api/tickets/report

Ticket summary

Parameters

FieldInTypeRequired
daysqueryintegerNo

curl

curl "https://socialroute.tr/api/tickets/report?days=30" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/tickets/{ticket_id}

Read a ticket

Parameters

FieldInTypeRequired
ticket_idpathstring (uuid)Yes

curl

curl "https://socialroute.tr/api/tickets/<ticket_id>" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

PUT/api/tickets/{ticket_id}

Update a ticket

Parameters

FieldInTypeRequired
ticket_idpathstring (uuid)Yes

Request body (JSON)

FieldTypeRequired
titlestring · 1…200Yes
descriptionstring · 0…10000No
priority"low" | "normal" | "high" | "urgent"No
customer_numberstringNo
contact_idstring (uuid)No
assignee_user_idstring (uuid)No
tagsstring[]No
due_atstring (date-time)No
sourcestringNo
status"open" | "in_progress" | "waiting" | "solved" | "closed"Yes
revisionintegerYes

Example body

{
  "title": "Passport pickup",
  "description": "Collected it from the office on Friday.",
  "priority": "normal",
  "customer_number": "0532 111 22 33",
  "assignee_user_id": null,
  "tags": [
    "visa"
  ],
  "due_at": null,
  "status": "solved",
  "revision": 3
}

curl

curl -X PUT "https://socialroute.tr/api/tickets/<ticket_id>" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"title": "Passport pickup", "description": "Collected it from the office on Friday.", "priority": "normal", "customer_number": "0532 111 22 33", "assignee_user_id": null, "tags": ["visa"], "due_at": null, "status": "solved", "revision": 3}'

Documented responses: 200, 422

POST/api/tickets/{ticket_id}/comments

Add a comment

Parameters

FieldInTypeRequired
ticket_idpathstring (uuid)Yes

Request body (JSON)

FieldTypeRequired
textstring · 1…5000Yes

Example body

{
  "text": "Called the customer; the documents are ready."
}

curl

curl -X POST "https://socialroute.tr/api/tickets/<ticket_id>/comments" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"text": "Called the customer; the documents are ready."}'

Documented responses: 201, 422

Calls

The assistant's calls, outbound calls and acting on a call in progress.

GET/api/calls

The assistant's calls

Parameters

FieldInTypeRequired
kindquerystringNo
statusquerystringNo
assistant_idquerystring (uuid)No
date_fromquerystring (date-time)No
date_toquerystring (date-time)No
call_idquerystringNo
squad_idquerystring (uuid)No
phone_number_idquerystring (uuid)No
customerquerystringNo
ended_reasonquerystringNo
assistant_version_idquerystring (uuid)No
successquerybooleanNo
min_scorequeryintegerNo
max_scorequeryintegerNo
sortquery"started_at" | "duration" | "cost"No
orderquery"asc" | "desc"No
pagequeryintegerNo
per_pagequeryintegerNo

curl

curl "https://socialroute.tr/api/calls?per_page=20" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/calls/{call_id}

A call with its transcript

Parameters

FieldInTypeRequired
call_idpathstring (uuid)Yes

curl

curl "https://socialroute.tr/api/calls/<call_id>" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/calls/{call_id}/recording

The call's recording (WAV)

Parameters

FieldInTypeRequired
call_idpathstring (uuid)Yes
downloadquerybooleanNo
channelquery"stereo" | "mono" | "caller" | "assistant"No

curl

curl "https://socialroute.tr/api/calls/<call_id>/recording?channel=stereo" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/calls/{call_id}/transcript.txt

The call's transcript (plain text)

Parameters

FieldInTypeRequired
call_idpathstring (uuid)Yes

curl

curl "https://socialroute.tr/api/calls/<call_id>/transcript.txt" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

POST/api/calls/{call_id}/end

End a call in progress

Parameters

FieldInTypeRequired
call_idpathstring (uuid)Yes

curl

curl -X POST "https://socialroute.tr/api/calls/<call_id>/end" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

POST/api/calls/{call_id}/say

Have the assistant say a sentence in a call in progress

Parameters

FieldInTypeRequired
call_idpathstring (uuid)Yes

Request body (JSON)

FieldTypeRequired
textstring · 1…300Yes

Example body

{
  "text": "Your request is open; you will get an SMS shortly."
}

curl

curl -X POST "https://socialroute.tr/api/calls/<call_id>/say" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"text": "Your request is open; you will get an SMS shortly."}'

Documented responses: 200, 422

POST/api/calls/{call_id}/context

Add a note to a call in progress (not said to the caller)

Parameters

FieldInTypeRequired
call_idpathstring (uuid)Yes

Request body (JSON)

FieldTypeRequired
textstring · 1…1000Yes

Example body

{
  "text": "The caller is a VIP customer."
}

curl

curl -X POST "https://socialroute.tr/api/calls/<call_id>/context" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"text": "The caller is a VIP customer."}'

Documented responses: 200, 422

POST/api/calls/outbound

Call with the assistant

Request body (JSON)

FieldTypeRequired
assistant_idstring (uuid)Yes
phone_number_idstring (uuid)Yes
tostringYes
variablesobjectNo
voicemail_detectionbooleanNo
purposestring · 0…200No

Example body

{
  "assistant_id": "…",
  "phone_number_id": "…",
  "to": "0532 111 22 33",
  "purpose": "following up on your visa application",
  "variables": {
    "customer_name": "Elif"
  }
}

curl

curl -X POST "https://socialroute.tr/api/calls/outbound" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"assistant_id": "…", "phone_number_id": "…", "to": "0532 111 22 33", "purpose": "following up on your visa application", "variables": {"customer_name": "Elif"}}'

Documented responses: 201, 422

GET/api/calls/outbound

Outbound call requests

curl

curl "https://socialroute.tr/api/calls/outbound" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

GET/api/calls/outbound/{outbound_id}

An outbound call request

Parameters

FieldInTypeRequired
outbound_idpathstring (uuid)Yes

curl

curl "https://socialroute.tr/api/calls/outbound/<outbound_id>" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/campaigns/{campaign_id}/progress

A campaign's progress

Parameters

FieldInTypeRequired
campaign_idpathstring (uuid)Yes

curl

curl "https://socialroute.tr/api/campaigns/<campaign_id>/progress" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

Switchboard

Extension calls, live status, reports and departments.

GET/api/extensions/calls

Switchboard calls

Parameters

FieldInTypeRequired
limitqueryintegerNo
beforequerystring (date-time)No
extensionquerystringNo
kindquerystringNo
statusquerystringNo

curl

curl "https://socialroute.tr/api/extensions/calls?limit=50" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/extensions/calls/{call_id}/recording

A switchboard call's recording

Parameters

FieldInTypeRequired
call_idpathstring (uuid)Yes
downloadquerybooleanNo

curl

curl "https://socialroute.tr/api/extensions/calls/<call_id>/recording" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/extensions/live

Live status of extensions

curl

curl "https://socialroute.tr/api/extensions/live" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

GET/api/extensions/board

Today's summary and live board

curl

curl "https://socialroute.tr/api/extensions/board" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

GET/api/extensions/report

Report by day and extension

Parameters

FieldInTypeRequired
daysqueryintegerNo
targetqueryintegerNo

curl

curl "https://socialroute.tr/api/extensions/report?days=7" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/extensions/presence

Work and break times

Parameters

FieldInTypeRequired
daysqueryintegerNo

curl

curl "https://socialroute.tr/api/extensions/presence?days=7" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/departments

Departments and their members

curl

curl "https://socialroute.tr/api/departments" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

Call rules

Working hours, holidays, block list and transfer settings (read only; saving is done in the dashboard).

GET/api/org/call-rules

Working hours, holidays and recording retention

curl

curl "https://socialroute.tr/api/org/call-rules" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

GET/api/call-blocks

Call block list

curl

curl "https://socialroute.tr/api/call-blocks" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

GET/api/org/transfer-settings

External numbers calls can be transferred to

curl

curl "https://socialroute.tr/api/org/transfer-settings" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

GET/api/org/outbound-settings

Outbound call settings

curl

curl "https://socialroute.tr/api/org/outbound-settings" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200

Payments

Payment links. Amounts are in minor units (1/100 of a lira).

GET/api/payments

List payments

Parameters

FieldInTypeRequired
statusquerystringNo
limitqueryintegerNo

curl

curl "https://socialroute.tr/api/payments" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

POST/api/payments

Create a payment link

Request body (JSON)

FieldTypeRequired
amount_minorinteger · 100…100000000Yes
currency"TRY" | "USD" | "EUR"No
descriptionstring · 2…200Yes
payer_namestring · 2…120Yes
customer_numberstringNo
ticket_idstring (uuid)No
send_smsbooleanNo

Example body

{
  "amount_minor": 125000,
  "currency": "TRY",
  "description": "Consulting fee",
  "payer_name": "Elif Kaya",
  "customer_number": "0532 111 22 33",
  "send_sms": true
}

curl

curl -X POST "https://socialroute.tr/api/payments" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"amount_minor": 125000, "currency": "TRY", "description": "Consulting fee", "payer_name": "Elif Kaya", "customer_number": "0532 111 22 33", "send_sms": true}'

Documented responses: 201, 422

POST/api/payments/{payment_id}/refresh

Check now whether it was paid

Parameters

FieldInTypeRequired
payment_idpathstring (uuid)Yes

curl

curl -X POST "https://socialroute.tr/api/payments/<payment_id>/refresh" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

POST/api/payments/{payment_id}/cancel

Stop waiting for a payment

Parameters

FieldInTypeRequired
payment_idpathstring (uuid)Yes

curl

curl -X POST "https://socialroute.tr/api/payments/<payment_id>/cancel" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

Verification codes

A code by SMS or WhatsApp for signing in to your own app or confirming an action.

POST/api/otp/send

Send a code

Request body (JSON)

FieldTypeRequired
tostringYes
channel"sms" | "whatsapp"No
purposestring · 0…40No
lengthinteger · 4…6No
ttl_secondsinteger · 60…600No
textstring · 0…140No
language"tr" | "en"No
sms_fallbackbooleanNo

Example body

{
  "to": "0532 111 22 33",
  "channel": "sms",
  "purpose": "login",
  "length": 6,
  "ttl_seconds": 180
}

curl

curl -X POST "https://socialroute.tr/api/otp/send" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"to": "0532 111 22 33", "channel": "sms", "purpose": "login", "length": 6, "ttl_seconds": 180}'

Documented responses: 201, 422

POST/api/otp/verify

Verify a code

Request body (JSON)

FieldTypeRequired
idstring (uuid)Yes
codestring · 4…6Yes

Example body

{
  "id": "…",
  "code": "123456"
}

curl

curl -X POST "https://socialroute.tr/api/otp/verify" \
  -H "Authorization: Bearer sa_..." \
  -H "Content-Type: application/json" \
  -d '{"id": "…", "code": "123456"}'

Documented responses: 200, 422

Knowledge base and tools

Uploading files to a knowledge base, exporting an assistant and tool history.

POST/api/knowledge-bases/{base_id}/documents/upload

Upload a file to a knowledge base

Parameters

FieldInTypeRequired
base_idpathstring (uuid)Yes

The body is sent as multipart/form-data; the file's field name is file.

Form fields

FieldTypeRequired
filestringYes

curl

curl -X POST "https://socialroute.tr/api/knowledge-bases/<base_id>/documents/upload" \
  -H "Authorization: Bearer sa_..." \
  -F "file=@document.pdf"

Documented responses: 201, 422

GET/api/assistants/{assistant_id}/export

Export an assistant to a file

Parameters

FieldInTypeRequired
assistant_idpathstring (uuid)Yes
include_documentsquerybooleanNo

curl

curl "https://socialroute.tr/api/assistants/<assistant_id>/export" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

GET/api/tools/{tool_id}/versions

A tool's earlier settings

Parameters

FieldInTypeRequired
tool_idpathstring (uuid)Yes

curl

curl "https://socialroute.tr/api/tools/<tool_id>/versions" \
  -H "Authorization: Bearer sa_..."

Documented responses: 200, 422

Webhook

Event Notifications (Webhooks)

If you enter your server's address on the Settings page of the dashboard, a POST is sent to it when the events below happen. A 2xx response is enough.

EventWhenIn the body
call.startedWhen a call starts (if CALL_CONTROL is on for the server)call
call.endedWhen one of the assistant's calls endscall
call.analyzedWhen the post-call analysis is done (if turned on in Settings)call
campaign.completedWhen every contact of a campaign is donecampaign
monitor.triggeredWhen a monitoring rule breaks (if turned on in Settings)monitor
monitor.resolvedWhen a broken monitoring rule recovers (if turned on in Settings)monitor
eval.failedWhen a scheduled evaluation fails (if turned on in Settings)eval
switchboard_call.endedWhen a switchboard call endscall
ticket.createdWhen a ticket is opened (by a person, an integration or a call)ticket
ticket.updatedWhen a ticket changes or gets a commentticket, comment
form.submittedWhen a web form built in the dashboard is filled in and sentform, response
contact.createdWhen a profile is created in the dashboard or through the APIcontact
payment.paidWhen the bank confirms a paymentpayment
payment.refundedWhen a payment is refunded in full or in partpayment, refunded_now_minor
order.createdWhen a connected online store reports a new orderorder
order.updatedWhen a connected online store reports a changed orderorder
testWhen the test button on the Settings page is pressedmessage

Signature and retries

Every request carries the X-Sesli-Zaman (time in seconds) and X-Sesli-Imza (starts with sha256=) headers. The signature is the HMAC-SHA256 of time + . + the body, with the secret key from the Settings page. Compute it yourself, compare, and reject requests older than a few minutes.

If retries are on in Settings, an event that didn't arrive for a temporary reason is sent again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours. The X-Sesli-Olay header is the same on every attempt: if you see the same ID twice, don't process it again.

Verifying the signature (Python)

import hashlib, hmac

def is_genuine(secret: str, timestamp: str, signature: str, body: bytes) -> bool:
    expected = "sha256=" + hmac.new(secret.encode(), timestamp.encode() + b"." + body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)

Have a question? Write to us