POST /api/v1/webhooks/endpoints
المصادقة / الصلاحيات: webhooks:write · HTTP 201
{
"url": "https://your-merchant.example/webhooks/ruya",
"events": [
"payment.succeeded",
"payment.failed"
]
}curl -X POST 'https://ruya.site/api/v1/webhooks/endpoints'
-H 'Authorization: Bearer YOUR_SERVER_SIDE_TEST_KEY'
-H 'Content-Type: application/json'
--data '{"url":"https://your-merchant.example/webhooks/ruya","events":["payment.succeeded","payment.failed"]}'const response = await fetch("https://ruya.site/api/v1/webhooks/endpoints", {
method: 'POST',
headers: { Authorization: 'Bearer ' + process.env.RUYA_TEST_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
"url": "https://your-merchant.example/webhooks/ruya",
"events": [
"payment.succeeded",
"payment.failed"
]
})
});
if (!response.ok) throw new Error('RUYA HTTP ' + response.status);
const result = await response.json();مخططات الطلب والرد الناجح
{
"request": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"url": {
"type": "string",
"maxLength": 2000,
"format": "starts_with",
"pattern": "^https:\\/\\/.*"
},
"events": {
"minItems": 1,
"type": "array",
"items": {
"type": "string",
"enum": [
"payment.created",
"payment.succeeded",
"payment.failed",
"payment.cancelled",
"payment.refunded",
"payment.expired"
]
}
}
},
"required": [
"url",
"events"
]
},
"response": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"url": {
"type": "string"
},
"secret": {
"type": "string"
},
"events": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"id",
"url",
"secret",
"events"
]
}
}استبدل معاملات المسار بمعرف سجلك. اتبع قسم الأخطاء للردود الفاشلة. لا تحتوي الأمثلة على مفاتيح حقيقية أو نتائج دفع فعلية.
جرّب في Sandbox